How sand-box-dev/notepad-ai works
Notepad AI turns uploaded learning documents into locally grounded concept maps, cited chat, and study materials. The main user flow is authenticate, upload/select a document, process its passages, then explore the resulting map, ask streaming questions, or generate quizzes, flashcards, and essay tasks. The graph also includes project/workspace navigation and the offline-first authentication, database failover, and sync layers. Some route and UI links are documented or indexed but not excerpted; those relationships are identified by their available evidence rather than inferred from naming alone.
Main entry points: main.py FastAPI app · database.py DB failover · Workspace.tsx Workspace · api.ts API client
Components 28
Workspace client
- App shell
frontend/src/App.tsx - Workspace
frontend/src/pages/Workspace.tsx - API client
frontend/src/services/api.ts - Reviewer chat
frontend/src/components/ReviewerChat.tsx - Concept map
frontend/src/components/ConceptMap.tsx - Study mode
frontend/src/components/StudyMode.tsx - Cover storage
frontend/src/services/coverStorage.ts
API and domain workflows
- FastAPI app
backend/app/main.py - Document routes
backend/app/routers/documents.py - Chat routes
backend/app/routers/chat.py - Concept routes
backend/app/routers/concepts.py - Study routes
backend/app/routers/study.py - Project routes
backend/app/routers/projects.py
Local AI processing
- Document processing
backend/app/services/document_service.py - Passage vectors
backend/app/services/vector_service.py - Concept extraction
backend/app/services/concept_service.py - Grounded chat
backend/app/services/chat_service.py - Study generation
backend/app/services/study_service.py - Ollama model
Persistence and sync
- DB failover
backend/app/database.py - Domain records
backend/app/models.py - Cloud sync
backend/app/services/sync_service.py - Supabase Postgres
- Offline SQLite
Identity
- Auth routes
backend/app/routers/auth.py - Online auth
backend/app/auth.py - Offline credentials
backend/app/offline_auth.py
Other components
- Learner
Connections 41
- Learner → App shell: uses
frontend/src/App.tsx - App shell → Workspace: opens workspace
frontend/src/App.tsx - App shell → API client: checks session
frontend/src/App.tsx - Workspace → API client: requests data
frontend/src/pages/Workspace.tsx - Workspace → Reviewer chat: renders
frontend/src/pages/Workspace.tsx - Workspace → Concept map: renders
frontend/src/pages/Workspace.tsx - Workspace → Study mode: renders
frontend/src/pages/Workspace.tsx - Workspace → Cover storage: removes cover
frontend/src/pages/Workspace.tsx - Reviewer chat → API client: streams questions
frontend/src/components/ReviewerChat.tsx - Study mode → API client: requests study
frontend/src/components/StudyMode.tsx - API client → FastAPI app: HTTP and SSE
README.md - FastAPI app → Document routes: registers
backend/app/main.py - FastAPI app → Chat routes: registers
backend/app/main.py - FastAPI app → Concept routes: registers
backend/app/main.py - FastAPI app → Study routes: registers
backend/app/main.py - FastAPI app → Project routes: registers
backend/app/main.py - FastAPI app → Auth routes: registers
backend/app/main.py - Document routes → Document processing: processes uploads
backend/app/routers/documents.py - Document processing → Passage vectors: vectorizes passages
backend/app/services/document_service.py - Document routes → Concept extraction: generates map
backend/app/routers/documents.py - Concept routes → Concept extraction: requests concepts
backend/app/routers/concepts.py - Concept extraction → Passage vectors: selects passages
backend/app/services/concept_service.py - Concept extraction → Ollama model: prompts model
backend/app/services/concept_service.py - Chat routes → Grounded chat: handles chat
backend/app/routers/chat.py - Grounded chat → Ollama model: streams response
backend/app/services/chat_service.py - Study routes → Study generation: generates study
backend/app/routers/study.py - Study generation → Ollama model: generates material
backend/app/services/study_service.py - Auth routes → Online auth: authenticates
backend/app/routers/auth.py - Auth routes → Offline credentials: checks fallback
backend/app/routers/auth.py - Online auth → Offline credentials: caches credentials
backend/app/auth.py - Auth routes → Cloud sync: syncs after login
backend/app/routers/auth.py - FastAPI app → Cloud sync: starts sync
backend/app/main.py - DB failover → Supabase Postgres: uses primary
README.md - DB failover → Offline SQLite: falls back
README.md - DB failover → Domain records: provides sessions
backend/app/models.py - Cloud sync → DB failover: opens sessions
backend/app/services/sync_service.py - Cloud sync → Domain records: copies records
backend/app/services/sync_service.py - Document routes → DB failover: uses session
backend/app/routers/documents.py - Chat routes → DB failover: uses session
backend/app/routers/chat.py - Study routes → DB failover: uses session
backend/app/routers/study.py - Project routes → DB failover: uses session
backend/app/routers/projects.py