How maadhu938/neuroweave works
1. High-level shape
- Neuroweave is a split architecture: a React/Vite single-page frontend in src/ and a FastAPI backend in backend/app/.
- The frontend handles interaction and visualization; the backend owns all domain logic, AI calls, graph processing, and persistence.
2. Frontend presentation layer
- src/pages/ defines the main user surfaces: Dashboard, Brain Map, Ask Your Brain, Upload Knowledge, Study Planner, Insights, Settings, Login, Landing.
- src/components/ contains reusable UI tied to core product features, especially the knowledge/memory visualizations such as AI insight cards, memory heatmap, memory decay chart, review quiz, sidebar, top bar.
- This layer is mostly a client-side orchestration and rendering layer, not where business logic lives.
3. Frontend-to-backend boundary
- The frontend talks to the backend through src/lib/api.ts and the useApi hook.
- Authentication is handled separately through Firebase client setup in src/lib/firebase.ts and the useAuth hook, so the app has a distinct identity boundary before API access.
- The frontend appears to be a pure client app; the backend is the source of truth for learning state, graph data, and memory scoring.
4. Backend API surface
- backend/app/api/ is organized by domain, not by generic CRUD: ask, dashboard, insights, knowledge_graph, memory, metrics, review, settings, study_planner, upload.
- This implies the backend is a feature-oriented API, where each router returns data shaped for a specific product surface rather than exposing low-level tables.
- backend/app/main.py likely assembles these routers and applies middleware/CORS/auth.
5. Core domain services
- backend/app/services/ contains the real architecture center:
- ingestion.py for turning source material into structured knowledge
- embedding.py for vectorization
- graph.py for knowledge graph construction/updates
- retrieval.py for semantic and graph-aware lookup
- llm.py for model interaction
- nama.py for the memory-strength algorithm
- planner.py for study scheduling
- insights.py for analytics generation
- These services are the main computational layer between API endpoints and the database.
6. Knowledge ingestion pipeline
- The upload API feeds the ingestion service, which likely parses documents, extracts chunks, generates embeddings, and stores graph-relevant entities/relations.
- PyMuPDF is listed in the stack, so PDF handling is a material part of ingestion.
- The output of ingestion is not just files in storage; it becomes structured graph + vector data used by retrieval, planning, and analytics.
7. Knowledge graph and retrieval path
- The knowledge_graph API plus graph.py represent the system’s canonical “brain map” model.
- retrieval.py likely combines pgvector semantic search with graph neighborhood/context expansion so Ask Your Brain can answer in context, not from embeddings alone.
- This is the main path for the “Ask Your Brain” experience: user query → retrieval → LLM → grounded answer.
8. Memory model and adaptive learning loop
- nama.py implements the proprietary NAMA Algorithm, which updates memory strength from review history, performance, connectivity, and time decay.
- The memory and review APIs likely drive this loop by accepting quiz/review outcomes and writing updated memory state back to the database.
- This loop is what differentiates the app from a static knowledge base: user interactions continuously reshape future review priority.
9. Study planning and prioritization
- planner.py and the study_planner API turn memory state into a schedule or prioritized queue of study actions.
- The planner depends on the memory model and graph context, so scheduling is an output of accumulated usage history, not just fixed calendar rules.
- This subsystem sits between analytics and action: it translates learning state into next steps.
10. Analytics and dashboarding
- insights.py, metrics, and dashboard provide higher-level summaries such as retention, decay, coverage, and learning progress.
- The frontend charts in MemoryDecayChart, MemoryHeatmap, and AIInsightCards are visual consumers of these aggregated outputs.
- This layer is read-heavy and optimizes for quick interpretation rather than raw data entry.
11. Persistence model
- backend/app/database.py and backend/app/models/models.py indicate a SQLAlchemy-backed relational schema.
- PostgreSQL with pgvector is a key architectural choice: it stores both normal relational state and vector embeddings in the same system.
- That means the core data store supports three concerns together: user/content records, graph/memory state, and semantic retrieval.
12. External services and deployment boundaries
- The backend integrates with Groq for Llama-class LLM access and likely Hugging Face embeddings for vector generation, so model inference is external to the app runtime.
- Firebase is used on the frontend for auth identity.
- The repo layout and config files suggest a typical split deployment: frontend on Vercel, backend on Render/Railway, and Postgres on Supabase or similar managed Postgres.
13. What to show in an architecture diagram
- Draw the main flow as: User/UI → Frontend pages/components → API client → FastAPI routers → domain services → Postgres/pgvector + external AI services.
- Then show feedback loops from review/quiz interactions back into memory/NAMA/planner, and from upload/ingestion into graph/retrieval/insights.
- The most important boundaries are: presentation vs backend, API routing vs domain services, domain services vs persistence, and internal logic vs external model providers.
Main entry points: api API Routers · database.py Database · pages Pages · retrieval.py Retrieval
Components 24
Frontend
React/Vite client for interaction, visualization, and auth gating.
- Pages · Main product screens: dashboard, brain map, ask, upload, planner, insights, settings, login, landing.
src/pages - UI Components · Reusable presentation pieces for insight cards, charts, quizzes, and shell navigation.
src/components - API Client · Typed browser API access used by hooks and pages.
src/lib/api.ts - Auth Client · Firebase-backed frontend authentication and session state.
src/lib/firebase.ts - useApi · Frontend hook that wraps backend requests and shared loading/error state.
src/hooks/useApi.ts - useAuth · Frontend hook for login state and auth gating.
src/hooks/useAuth.tsx - App Shell · Top-level React composition and routing entrypoint.
src/app/App.tsx
Backend
FastAPI app with routers, domain services, and persistence.
- FastAPI App · Assembles routers, middleware, and application-wide backend setup.
backend/app/main.py - API Routers · Domain-oriented endpoints for ask, dashboard, insights, knowledge graph, memory, metrics, review, settings, study planner, and upload.
backend/app/api - Ingestion · Parses uploads, extracts structure, chunks content, and prepares graph/vector inputs.
backend/app/services/ingestion.py - Retrieval · Combines semantic search with graph-aware context expansion for grounded answers.
backend/app/services/retrieval.py - Graph Service · Builds and updates the canonical knowledge graph used by the brain map.
backend/app/services/graph.py - Embedding · Generates vector representations for semantic retrieval and similarity.
backend/app/services/embedding.py - LLM Service · Handles model prompts and response generation for assistant-style features.
backend/app/services/llm.py - NAMA Engine · Computes adaptive memory strength from reviews, time decay, and connectivity.
backend/app/services/nama.py - Planner · Turns memory state and graph context into study priorities and schedules.
backend/app/services/planner.py - Insights Service · Produces retention, decay, coverage, and progress summaries.
backend/app/services/insights.py - Database · SQLAlchemy-backed relational store for app state and domain records.
backend/app/database.py - Data Models · ORM models defining persisted users, knowledge, memory, and review state.
backend/app/models/models.py
External
Third-party identity, model, and data services.
- Firebase · External identity provider used by the frontend.
- Groq · External model provider for LLM inference.
- Hugging Face · External embedding provider used for vector generation.
- Postgres/pgvector · Primary database layer with relational tables plus vector search support.
Other components
- User · Learner using the app to ask, upload, review, and plan.
Connections 29
- User → Pages: uses · Interacts with product screens.
- Pages → UI Components: renders · Composes reusable UI widgets.
- Pages → useApi: queries · Fetches product data through the API hook.
- Pages → useAuth: auth gates · Checks session state for protected views.
- useApi → API Client: calls · Delegates network requests to the client layer.
- useAuth → Auth Client: uses · Reads and updates frontend auth state.
- Auth Client → Firebase: authenticates · Relies on Firebase identity services.
- API Client → FastAPI App: requests · Sends browser requests to the backend app.
- FastAPI App → API Routers: mounts · Registers feature-oriented routers.
- API Routers → Ingestion: upload · Turns source material into structured knowledge.
- API Routers → Retrieval: ask · Serves contextual question answering.
- API Routers → Graph Service: brain map · Exposes graph views and updates.
- API Routers → NAMA Engine: memory · Reads and writes adaptive memory state.
- API Routers → Planner: study plan · Produces prioritized study actions.
- API Routers → Insights Service: insights · Returns analytics and summaries.
- API Routers → Database: stores · Persists domain state and reads it back.
- Ingestion → Embedding: vectorizes · Creates embeddings for uploaded content.
- Ingestion → Graph Service: extracts graph · Converts content into entities and relations.
- Retrieval → Graph Service: expands context · Uses graph neighborhoods to ground answers.
- Retrieval → Embedding: searches vectors · Finds semantically related content.
- Retrieval → LLM Service: grounds reply · Builds contextual answers from retrieved evidence.
- NAMA Engine → Database: updates state · Persists memory scores and review history.
- Planner → NAMA Engine: depends on · Uses memory strength and decay signals.
- Planner → Graph Service: uses context · Factors in knowledge connectivity and structure.
- Insights Service → Database: aggregates · Reads persisted records to compute metrics.
- Database → Data Models: maps to · Implements the relational schema through ORM models.
- Embedding → Hugging Face: calls · Uses external embedding models.
- LLM Service → Groq: calls · Uses external LLM inference.
- Database → Postgres/pgvector: backed by · Primary persistent store with pgvector support.