How rameshkunwar/aidanskvocabularybuilder works
Purpose and Entry Points
AIDanskVocabularyBuilder is a child-focused Danish vocabulary-learning system. It accepts book-page images, uses AI to extract vocabulary and kid-friendly definitions, stores learning progress, and supports spelling practice, gamification, and Danish audio pronunciation.
Backend startup is FastAPI at backend/app/main.py; its HTTP surface is organized in backend/app/api/endpoints.py. The browser client starts from frontend/src/main.tsx and composes the application in frontend/src/App.tsx.
Frontend Learning Experience
The React/TypeScript frontend provides distinct upload, practice, progress, and dashboard views:
• frontend/src/pages/UploadPage.tsx
• frontend/src/pages/PracticePage.tsx
• frontend/src/pages/DashboardPage.tsx
• frontend/src/pages/ProgressPage.tsx
Reusable learning UI includes word cards, point display, badges, and celebration feedback in frontend/src/components/WordCard.tsx, frontend/src/components/PointsDisplay.tsx, and frontend/src/components/Celebration.tsx.
Client/API Boundary
frontend/src/lib/api.ts is the primary browser-to-backend boundary. UI pages call this client to submit page images, retrieve vocabulary/progress, and record practice outcomes. Shared API/domain shapes are represented by frontend/src/types/index.ts.
The frontend is independently containerized (frontend/Dockerfile) and should remain decoupled from backend implementation details beyond the API contract.
API and Application Orchestration
backend/app/api/endpoints.py owns request handling and coordinates the main workflow: image upload, vocabulary extraction, persistence, practice/progress updates, and text-to-speech access. backend/app/main.py initializes the FastAPI application and mounts this API layer.
This is the principal control boundary: HTTP handlers translate client requests into extraction, LLM, database, and audio-service operations.
AI Extraction Pipeline
Book-page processing is implemented in backend/app/extractor.py. It receives uploaded imagery/content and drives structured vocabulary extraction. backend/app/llm_adapter.py abstracts the model provider layer, allowing Pydantic AI orchestration to use Google Gemini by default or an Ollama-backed model.
The extraction boundary should produce validated vocabulary data rather than expose raw model output to API consumers or persistence.
Persistence and Learning State
SQLModel/PostgreSQL integration is centralized in backend/app/db.py; persistent entity definitions live in backend/app/models.py. These models represent the durable boundary for extracted words and learner progression/gamification state.
Database initialization or maintenance is supported by backend/update_db.py. PostgreSQL is infrastructure rather than a frontend concern.
Speech and Deployment Infrastructure
backend/app/tts.py integrates Danish pronunciation through the external DR.dk API. It is a separate service boundary from word extraction and should tolerate external API failures independently.
The full stack is deployable with docker-compose.yml, using service-specific images from backend/Dockerfile and frontend/Dockerfile. Caddyfile indicates Caddy is the intended edge proxy/static-serving layer in a composed deployment.
Main entry points: endpoints.py HTTP API · docker-compose.yml Compose deployment · UploadPage.tsx Learning views · api.ts API client
Components 19
Browser client
- React entry
frontend/src/main.tsx - App composition
frontend/src/App.tsx - Learning views · Upload, practice, dashboard, and progress views.
frontend/src/pages/UploadPage.tsx - Learning UI · Word cards, points, and celebration feedback.
frontend/src/components/WordCard.tsx - API client
frontend/src/lib/api.ts - API domain shapes
frontend/src/types/index.ts
FastAPI application
- FastAPI startup
backend/app/main.py - HTTP API · Coordinates uploads, learning state, and pronunciation access.
backend/app/api/endpoints.py - Database integration
backend/app/db.py - Learning state models · Words, progress, and gamification state.
backend/app/models.py - Danish pronunciation · Independent DR.dk API boundary.
backend/app/tts.py
AI extraction
- Vocabulary extractor · Produces validated vocabulary from book-page content.
backend/app/extractor.py - Model adapter · Uses Gemini by default or an Ollama-backed model.
backend/app/llm_adapter.py
Infrastructure
- PostgreSQL
- Caddy edge proxy
Caddyfile - Compose deployment
docker-compose.yml - Backend image
backend/Dockerfile - Frontend image
frontend/Dockerfile
Other components
- DR.dk API
Connections 21
- React entry → App composition: boots
- App composition → Learning views: composes
- Learning views → Learning UI: renders
- Learning views → API client: uses
- API client → API domain shapes: uses
- API client → HTTP API: HTTP requests
- FastAPI startup → HTTP API: mounts
- HTTP API → Vocabulary extractor: processes uploads
- Vocabulary extractor → Model adapter: requests extraction
- HTTP API → Database integration: reads and updates state
- Database integration → Learning state models: persists
- Database integration → PostgreSQL: connects
- HTTP API → Danish pronunciation: requests pronunciation
- Danish pronunciation → DR.dk API: calls
- Compose deployment → Caddy edge proxy: deploys
- Compose deployment → Backend image: builds
- Compose deployment → Frontend image: builds
- Caddy edge proxy → Frontend image: serves
- Caddy edge proxy → FastAPI startup: proxies API
- Frontend image → App composition: packages
- Backend image → FastAPI startup: packages