Project Info
Inspiration
Many students, especially those with dyslexia or reading challenges, are taught to memorize words instead of understanding how they are built. Structured Word Inquiry teaches students to analyze words scientifically by breaking them into bases, prefixes, and suffixes, but these tools are currently manual, slow, and difficult to scale. We wanted to make SWI interactive, visual, and accessible so that students can explore language in a more intuitive and engaging way.
What it does
Our software allows a user to upload a book or text and click any word to explore it in depth. When a word is selected, the system generates a word sum, identifies the base and affixes, and displays a word family matrix. The user can also view definitions, listen to the pronunciation of the word, hear the word broken down into syllables, and see a simple visual icon representing the concept. In some cases, the user can also access an AI-generated explanation of the word’s history or etymology. The goal is to turn reading into an interactive learning experience that builds real linguistic understanding, particularly for students who may otherwise feel more averse to reading.
How we built it
The frontend was built using Next.js and React to create an interactive reading interface where individual words can be selected and analyzed dynamically. The backend was written in Python, and Claude API to extract base morphemes, generate word matrices, verify derived words, and produce etymology explanations. Additional features such as text-to-speech for pronunciation and syllable breakdown were integrated using OpenAI's API, and we used the Noun Project API to source the images that accompany the definitions and provide a simple visual representation of each word.
Challenges we ran into
One of the biggest challenges we had was integrating the front- and backend, since we all split up our work based on our strengths, and then had to merge all of our separate work into our cohesive final product. The time constraint was another challenge, since there were numerous features we would have loved to incorporate before the deadline, but we do plan to implement them in the future. We also encountered difficulty with parsing PDFs into clean text and when designing word matrices that display clearly and dynamically.
Accomplishments we're proud of
We are proud that we built a working Structured Word Inquiry matrix generator and a click-to-analyze reading experience. We successfully implemented an AI-driven morphology pipeline that produces structured linguistic analysis in real time. We also built a robust backend with caching to improve performance and integrated pronunciation and visual aids to make the learning experience more accessible and engaging.
What we learned
Through this project, we learned that linguistics and morphology are more complex than they initially appear. We also discovered how important prompt engineering is when structured outputs are required. Designing tools for education requires clarity, reliability, and thoughtful constraints to ensure that students receive accurate and meaningful information. We also gained experience coordinating a full-stack system that integrates frontend interaction with backend AI services.
What's next
In the future, we would like to add a student reading analytics dashboard that helps teachers track progress and identify areas of difficulty. We also plan to build a classroom mode designed specifically for educators and to develop a prebuilt matrix library for commonly taught curriculum words. We have also considered adding gamified learning exercises, a mobile version for classroom use, and the possibility of combining AI with curated linguistic databases to improve reliability and speed. Why this matters: Reading struggles affect millions of students, particularly those with dyslexia. Tools that explain how language works, rather than relying on memorization, can dramatically improve literacy outcomes. By making Structured Word Inquiry interactive and scalable, we hope to make deeper language understanding accessible to many more learners.
Reading SWItch
An interactive picture book app that uses Structured Word Inquiry (SWI) to help kids learn to read. Upload a PDF of a picture book, tap any word, and see its morphological breakdown — prefixes, bases, suffixes, etymology, and word families.
Built at TreeHacks 2025.
Setup
Prerequisites:
- Node.js 18+
- Python 3
# Install Node.js dependencies
npm install
# Install Python dependencies
pip install -r requirements.txt
Create .env.local with your Anthropic API key:
ANTHROPIC_API_KEY=sk-ant-...
Initialize data directories:
mkdir -p data/users data/recommended
echo "[]" > data/users/users.json
Running
npm run dev
Open http://localhost:3000, create an account, and start reading!
Adding Recommended Books
- Place PDF files in the
data/recommended/folder - Visit the library page (PDFs auto-process on first load)
That's it! PDFs are automatically processed when you first access the library. Pages render on-demand for instant display. Manual processing is also available with npm run setup-recommended.
How It Works
- Authentication — File-based user accounts with bcrypt password hashing and HTTP-only cookie sessions
- Library — Two collections: "My Library" (user's personal books) and "Recommended Library" (pre-processed PDFs)
- Recommended Processing — PDFs in
data/recommended/auto-process when library page loads:- Copy PDF to book directory
- Extract word bounding boxes using
pdfminer.six - Create book metadata (runs once, cached after)
- Upload — Users can add their own PDFs via the web interface:
- Server saves PDF and extracts word positions
- Book is added to user's library
- Read — Reader renders PDF pages on-demand using
pdfjs-distwith invisible, clickable word overlays - Analyze — Tapping a word calls
/api/analyzewhich uses Claude AI (Anthropic API) to return an SWI breakdown (word sum, morphemes, etymology, word family) - Display — Right-side panel shows color-coded morpheme chips and analysis at the selected depth level
Project Structure
src/
├── app/
│ ├── page.tsx # Login / registration page
│ ├── library/page.tsx # Library with My Library and Recommended carousels
│ ├── upload/page.tsx # PDF upload page
│ ├── reader/page.tsx # Book reader with SWI panel
│ └── api/
│ ├── auth/ # Authentication endpoints (login, register, logout, session)
│ ├── library/route.ts # User library management
│ ├── recommended/route.ts # Recommended books with auto-processing
│ ├── analyze/route.ts # SWI word analysis via Claude AI
│ └── upload/route.ts # PDF processing and storage
├── components/
│ ├── DropZone.tsx # Drag-and-drop file upload
│ ├── BookCard.tsx # Book thumbnail card
│ ├── BookCarousel.tsx # Horizontal scrolling carousel
│ ├── BookPage.tsx # Page image + word overlays
│ ├── WordOverlay.tsx # Clickable word button
│ ├── SWIPanel.tsx # Right-side analysis panel
│ ├── DepthSelector.tsx # Analysis depth toggle
│ └── PageSearch.tsx # In-book page search
├── contexts/
│ └── AuthContext.tsx # Authentication state provider
├── lib/
│ ├── userManager.ts # User CRUD operations
│ ├── sessionManager.ts # Session management
│ ├── bookManager.ts # Book metadata and auto-processing
│ └── wordCache.ts # In-memory SWI analysis cache
└── types/
├── auth.ts # User and Session types
└── book.ts # Book, WordPosition, SWIAnalysis types
scripts/
├── extract_words.py # Extract word bounding boxes from PDF
└── setup-recommended.mjs # One-time script to process recommended PDFs
data/
├── users/
│ └── users.json # User accounts
└── recommended/
├── index.json # Processed recommended books index
└── *.pdf # Source PDFs (user-populated)
Key Integration Points
SWI Analysis Logic — Replace the mock analyzeWithClaude() function in src/app/api/analyze/route.ts. It should return data conforming to the SWIAnalysis type from src/types/book.ts.
Frontend Styling — Components have semantic structure ready for restyling. Morpheme color coding (blue=prefix, green=base, orange=suffix) is functional, everything else is open for design changes.
Scripts
npm run dev # Dev server at localhost:3000
npm run build # Production build
npm run lint # ESLint
Analysis
View
Metric
- 12
- 7
- 6
- 4
Figures cover GitHub contributors during the hackathon window. A co-authored commit counts in full for each author, so per-member totals add up to more than the whole-team figures.
Technology
- AnthropicIn code
- CSSIn code
- Next.jsIn code
- OpenAIIn code
- PythonIn code
- ReactIn code
- Tailwind CSSIn code
- TypeScriptIn code
8 of 8 appear in the indexed code.
AI coding agents
- Claude CodeConfig · Commits
Detected from committed agent config files and commit authorship. Absence of a signal is not proof an agent was unused.
Codebase size
Source size
180 KB
Source files
52
Counts recognized source files only; vendored directories, binaries and lockfiles are excluded, so this is smaller than the repository on disk.
Repository
onwaneri/reading-switch
723 files · 1302.1 MB · @ f0280e3
Structure
Interface
18 files · 2%Screens, components and styles rendered to the user.
API & routing
14 files · 2%Request entry points: routes, handlers and controllers.
Application logic
18 files · 2%Domain rules, services and shared utilities.
+2 more
Supporting
Layers are inferred from where files sit in the tree, not from reading the code. A project that names its directories unconventionally will read oddly here — open the file browser to check anything the diagram implies.
Languages
- TypeScript80%
- Python18%
- Markdown3%
- CSS0%
Share of indexed source by file size. Binary and vendored files are excluded.
Dependencies
package.json
npm · 18- @anthropic-ai/sdk
- @types/bcryptjs
- bcryptjs
- next
- pdfjs-dist
- react
- react-dom
- sharp
- tesseract.js
- zod
- +8 more
requirements.txt
pypi · 7- anthropic
- openai
- pdf2image
- pdfminer.six
- python-dotenv
- requests
- requests-oauthlib
Declared in the repository’s manifests at the indexed commit. A declared package is not proof it is used, and runtime dependencies are listed first.
This project’s features have not been analysed yet.
Export this project's context (description, README, evidence, key source files) to chat with an AI agent elsewhere.