# priyanshudwivedi9068-eng/academicai architecture

> Architecture diagram of the GitHub repository priyanshudwivedi9068-eng/academicai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/priyanshudwivedi9068-eng/academicai
- Repository: https://github.com/priyanshudwivedi9068-eng/academicai

## Overview

1. **System shape**
   - This is a two-tier application: a **React/Vite frontend** and a **Node.js/Express backend**.
   - The backend is the system of record for users, uploaded documents, and AI interactions; the frontend is a single-page app that consumes the backend API.

2. **Frontend boundary**
   - The frontend lives under `frontend/src` and is organized into **pages**, **layouts**, **components**, and **React contexts**.
   - Key contexts are `AuthContext` and `ThemeContext`, which indicate that authentication state and UI theme are managed client-side and shared across the app.
   - `ProtectedRoute` and `DashboardLayout` suggest a gated dashboard area versus public entry pages like login/register/home.

3. **Primary user-facing areas**
   - Public entry points: `Home`, `Login`, and `Register`.
   - Authenticated workspace: `Dashboard` with feature pages for `Overview`, `AIChat`, `FileManager`, `StudyRoom`, `CalendarView`, `Billing`, and `Settings`.
   - The architecture strongly implies that most product value happens inside the authenticated dashboard, not as isolated public pages.

4. **Backend API structure**
   - The backend is a classic **Express controller-route-service** layout.
   - `routes/` maps HTTP endpoints to `controllers/`, and `middleware/` handles cross-cutting concerns like auth protection.
   - The main functional domains are:
     - `authController` / `authRoutes`
     - `fileController` / `fileRoutes`
     - `aiController` / `aiRoutes`
   - `server.js` is the entrypoint that wires the Express app together.

5. **Data model boundary**
   - MongoDB is accessed through Mongoose models in `backend/models`.
   - `User` holds identity/auth-related data.
   - `Document` likely tracks uploaded files, parsing metadata, ownership, and possibly vector/index references.
   - This makes MongoDB the durable application database, while the vector store is used for semantic retrieval rather than primary storage.

6. **Document ingestion pipeline**
   - The upload flow is centered around `fileController` and likely uses `multer` for file intake.
   - Supported document types in the README are PDF, DOCX, and TXT, which implies format-specific parsing before downstream processing.
   - The ingestion pipeline converts raw files into normalized text, then persists metadata in MongoDB and sends content into the retrieval layer.

7. **RAG and vector search subsystem**
   - `services/ragService.js` is the architectural core of the AI layer.
   - Documents are chunked and embedded using Google’s Gemini embedding model, then stored in **Pinecone**.
   - This creates a retrieval boundary: the system does not rely only on the language model’s memory; it first fetches relevant chunks from the user’s own uploaded documents.

8. **AI interaction flow**
   - `aiController` is the API surface for document-grounded AI features such as chat and quiz generation.
   - Request flow is likely: user question → backend retrieves relevant chunks from Pinecone → Gemini generates answer or quiz grounded in those chunks.
   - This means the AI subsystem depends on both the vector store and the original document corpus, with the backend orchestrating the whole response.

9. **Authentication and session boundary**
   - The README indicates **JWT-based auth** plus **Google OAuth**.
   - `authMiddleware` protects private routes, so authenticated requests are enforced at the API layer rather than only in the UI.
   - The presence of access/refresh secrets in `.env.example` suggests token-based session management with server-side verification and client-side token storage/usage.

10. **External services and infrastructure**
   - **MongoDB**: user and document persistence.
   - **Pinecone**: semantic index for retrieval.
   - **Google Gemini**: both generation and embeddings.
   - **Vercel** hosts the frontend; **Render** hosts the backend.
   - The frontend’s `vercel.json` and README note a proxy/rewrite setup so browser requests can reach the backend under the deployed domain structure.

11. **Request/data lifecycle**
   - A typical lifecycle is:
     1. User authenticates through the frontend.
     2. The frontend stores auth state and enables protected dashboard routes.
     3. User uploads documents through the file manager.
     4. Backend parses and stores document metadata.
     5. Text is chunked, embedded, and indexed in Pinecone.
     6. User asks questions or requests quizzes.
     7. Backend retrieves relevant chunks and calls Gemini to generate the result.
   - This is the key end-to-end flow to capture in an architecture diagram.

12. **Non-runtime artifacts**
   - `docs/` contains deployment notes, API docs, and interview/implementation docs; these are useful for understanding the design but are not runtime components.
   - `createIndex.js` is a setup/provisioning script, likely used to create or initialize the Pinecone index outside normal request handling.

13. **Main architectural boundary to show in a diagram**
   - The most important boundary is between:
     - **Client/UI**: React app, state, routing, theme
     - **API orchestration**: Express controllers and middleware
     - **Persistence/AI**: MongoDB, Pinecone, Gemini
   - The backend is the orchestrator that bridges user actions to document storage, semantic retrieval, and model inference.

Main entry points: [`frontend/src/App.jsx`](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/App.jsx) (App shell), [`frontend/src/pages/Dashboard.jsx`](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/pages/Dashboard.jsx) (Dashboard), [`backend/server.js`](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/backend/server.js) (Server), [`backend/controllers/fileController.js`](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/backend/controllers/fileController.js) (File controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_frontend_main["Main entry<br/>bootstrap<br/>[main.jsx]"]
  node_frontend_app["App shell<br/>SPA shell<br/>[App.jsx]"]
  node_auth_context(("Auth state<br/>context<br/>[AuthContext.jsx]"))
  node_theme_context(("Theme state<br/>context<br/>[ThemeContext.jsx]"))
  node_protected_route{{"Protected route<br/>route guard<br/>[ProtectedRoute.jsx]"}}
  node_dashboard_layout["Dashboard layout"]
  node_home_page["Home<br/>public page<br/>[Home.jsx]"]
  node_login_page["Login<br/>auth page<br/>[Login.jsx]"]
  node_register_page["Register<br/>auth page<br/>[Register.jsx]"]
  node_dashboard_page["Dashboard<br/>workspace page<br/>[Dashboard.jsx]"]
  node_overview_page["Overview<br/>dashboard page<br/>[Overview.jsx]"]
  node_aichat_page["AI chat<br/>dashboard page<br/>[AIChat.jsx]"]
  node_filemanager_page["Files<br/>dashboard page<br/>[FileManager.jsx]"]
  node_studyroom_page["Study room<br/>dashboard page<br/>[StudyRoom.jsx]"]
  node_calendar_page["Calendar<br/>dashboard page<br/>[CalendarView.jsx]"]
  node_billing_page["Billing<br/>dashboard page<br/>[Billing.jsx]"]
  node_settings_page["Settings<br/>dashboard page<br/>[Settings.jsx]"]
  node_payment_modal["Payment modal<br/>ui component<br/>[PaymentModal.jsx]"]
end

subgraph group_backend["Backend"]
  node_server_entry["Server<br/>Express entrypoint<br/>[server.js]"]
  node_auth_routes["Auth routes<br/>api routes<br/>[authRoutes.js]"]
  node_file_routes["File routes<br/>api routes<br/>[fileRoutes.js]"]
  node_ai_routes["AI routes<br/>api routes<br/>[aiRoutes.js]"]
  node_auth_controller["Auth controller<br/>[authController.js]"]
  node_file_controller["File controller<br/>[fileController.js]"]
  node_ai_controller["AI controller<br/>[aiController.js]"]
  node_auth_middleware{{"Auth middleware<br/>[authMiddleware.js]"}}
  node_rag_service["RAG service<br/>retrieval service<br/>[ragService.js]"]
end

subgraph group_data["Data & AI"]
  node_user_model[("User model<br/>mongoose model<br/>[User.js]")]
  node_document_model[("Document model<br/>mongoose model<br/>[Document.js]")]
  node_mongodb[("MongoDB<br/>persistent store")]
  node_pinecone[("Pinecone<br/>vector index")]
  node_gemini(("Gemini<br/>LLM/embeddings"))
  node_vercel["Vercel<br/>frontend host<br/>[vercel.json]"]
  node_render["Render<br/>backend host"]
end

subgraph group_docs["Docs"]
end

node_frontend_main -->|"mounts"| node_frontend_app
node_frontend_app -->|"uses"| node_auth_context
node_frontend_app -->|"uses"| node_theme_context
node_frontend_app -->|"guards"| node_protected_route
node_protected_route -->|"opens"| node_dashboard_layout
node_dashboard_layout -->|"wraps"| node_dashboard_page
node_dashboard_page -->|"navigates"| node_overview_page
node_dashboard_page -->|"navigates"| node_aichat_page
node_dashboard_page -->|"navigates"| node_filemanager_page
node_dashboard_page -->|"navigates"| node_studyroom_page
node_dashboard_page -->|"navigates"| node_calendar_page
node_dashboard_page -->|"navigates"| node_billing_page
node_dashboard_page -->|"navigates"| node_settings_page
node_billing_page -->|"opens"| node_payment_modal
node_frontend_app -->|"routes to"| node_home_page
node_frontend_app -->|"routes to"| node_login_page
node_frontend_app -->|"routes to"| node_register_page
node_server_entry -->|"mounts"| node_auth_routes
node_server_entry -->|"mounts"| node_file_routes
node_server_entry -->|"mounts"| node_ai_routes
node_auth_routes -->|"dispatches"| node_auth_controller
node_file_routes -->|"dispatches"| node_file_controller
node_ai_routes -->|"dispatches"| node_ai_controller
node_auth_routes -->|"protects"| node_auth_middleware
node_file_routes -->|"protects"| node_auth_middleware
node_ai_routes -->|"protects"| node_auth_middleware
node_auth_controller -->|"reads/writes"| node_user_model
node_file_controller -->|"reads/writes"| node_document_model
node_file_controller -->|"indexes"| node_rag_service
node_ai_controller -->|"queries"| node_rag_service
node_rag_service -->|"searches"| node_pinecone
node_rag_service -->|"embeds/generates"| node_gemini
node_user_model -->|"persists to"| node_mongodb
node_document_model -->|"persists to"| node_mongodb
node_frontend_app -->|"API calls"| node_server_entry
node_frontend_app -.->|"deployed on"| node_vercel
node_server_entry -.->|"deployed on"| node_render
node_file_controller -->|"metadata"| node_mongodb
node_file_controller -->|"chunks"| node_pinecone
node_ai_controller -->|"generates"| node_gemini
node_frontend_app -->|"auth API"| node_auth_routes
node_frontend_app -->|"file API"| node_file_routes
node_frontend_app -->|"ai API"| node_ai_routes
node_server_entry -->|"connects"| node_mongodb
node_server_entry -->|"connects"| node_pinecone
node_server_entry -->|"connects"| node_gemini

click node_frontend_main "https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/main.jsx"
click node_frontend_app "https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/App.jsx"
click node_auth_context "https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/context/AuthContext.jsx"
click node_theme_context "https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/context/ThemeContext.jsx"
click node_protected_route "https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/components/ProtectedRoute.jsx"
click node_dashboard_layout "https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/layouts/DashboardLayout.jsx"
click node_home_page "https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/pages/Home.jsx"
click node_login_page "https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/pages/Login.jsx"
click node_register_page "https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/pages/Register.jsx"
click node_dashboard_page "https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/pages/Dashboard.jsx"
click node_overview_page "https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/pages/dashboard/Overview.jsx"
click node_aichat_page "https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/pages/dashboard/AIChat.jsx"
click node_filemanager_page "https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/pages/dashboard/FileManager.jsx"
click node_studyroom_page "https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/pages/dashboard/StudyRoom.jsx"
click node_calendar_page "https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/pages/dashboard/CalendarView.jsx"
click node_billing_page "https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/pages/dashboard/Billing.jsx"
click node_settings_page "https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/pages/dashboard/Settings.jsx"
click node_payment_modal "https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/components/PaymentModal.jsx"
click node_server_entry "https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/backend/server.js"
click node_auth_routes "https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/backend/routes/authRoutes.js"
click node_file_routes "https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/backend/routes/fileRoutes.js"
click node_ai_routes "https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/backend/routes/aiRoutes.js"
click node_auth_controller "https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/backend/controllers/authController.js"
click node_file_controller "https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/backend/controllers/fileController.js"
click node_ai_controller "https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/backend/controllers/aiController.js"
click node_auth_middleware "https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/backend/middleware/authMiddleware.js"
click node_rag_service "https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/backend/services/ragService.js"
click node_user_model "https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/backend/models/User.js"
click node_document_model "https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/backend/models/Document.js"
click node_vercel "https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/vercel.json"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_frontend_main,node_frontend_app,node_auth_context,node_theme_context,node_protected_route,node_dashboard_layout,node_home_page,node_login_page,node_register_page,node_dashboard_page,node_overview_page,node_aichat_page,node_filemanager_page,node_studyroom_page,node_calendar_page,node_billing_page,node_settings_page,node_payment_modal toneBlue
class node_server_entry,node_auth_routes,node_file_routes,node_ai_routes,node_auth_controller,node_file_controller,node_ai_controller,node_auth_middleware,node_rag_service toneAmber
class node_user_model,node_document_model,node_mongodb,node_pinecone,node_gemini,node_vercel,node_render toneMint
```

## Components

### Frontend

React/Vite client application and UI state

- [Main entry](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/main.jsx): bootstrap · Mounts the React app and global providers · `frontend/src/main.jsx`
- [App shell](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/App.jsx): SPA shell · Top-level routing and provider composition · `frontend/src/App.jsx`
- [Auth state](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/context/AuthContext.jsx): context · Client-side authentication state and session handling · `frontend/src/context/AuthContext.jsx`
- [Theme state](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/context/ThemeContext.jsx): context · Shared UI theme state across the app · `frontend/src/context/ThemeContext.jsx`
- [Protected route](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/components/ProtectedRoute.jsx): route guard · Blocks unauthenticated access to private areas · `frontend/src/components/ProtectedRoute.jsx`
- [Dashboard layout](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/layouts/DashboardLayout.jsx): layout · Shell for authenticated workspace pages · `frontend/src/layouts/DashboardLayout.jsx`
- [Home](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/pages/Home.jsx): public page · Public landing page · `frontend/src/pages/Home.jsx`
- [Login](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/pages/Login.jsx): auth page · User sign-in screen · `frontend/src/pages/Login.jsx`
- [Register](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/pages/Register.jsx): auth page · User sign-up screen · `frontend/src/pages/Register.jsx`
- [Dashboard](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/pages/Dashboard.jsx): workspace page · Authenticated workspace entry page · `frontend/src/pages/Dashboard.jsx`
- [Overview](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/pages/dashboard/Overview.jsx): dashboard page · Workspace summary and status · `frontend/src/pages/dashboard/Overview.jsx`
- [AI chat](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/pages/dashboard/AIChat.jsx): dashboard page · Document-grounded conversational interface · `frontend/src/pages/dashboard/AIChat.jsx`
- [Files](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/pages/dashboard/FileManager.jsx): dashboard page · Upload and document management · `frontend/src/pages/dashboard/FileManager.jsx`
- [Study room](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/pages/dashboard/StudyRoom.jsx): dashboard page · Study and quiz workflow · `frontend/src/pages/dashboard/StudyRoom.jsx`
- [Calendar](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/pages/dashboard/CalendarView.jsx): dashboard page · Planning and schedule view · `frontend/src/pages/dashboard/CalendarView.jsx`
- [Billing](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/pages/dashboard/Billing.jsx): dashboard page · Subscription and payment area · `frontend/src/pages/dashboard/Billing.jsx`
- [Settings](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/pages/dashboard/Settings.jsx): dashboard page · Account and app preferences · `frontend/src/pages/dashboard/Settings.jsx`
- [Payment modal](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/src/components/PaymentModal.jsx): ui component · Billing purchase flow dialog · `frontend/src/components/PaymentModal.jsx`

### Backend

Express API, domain logic, and orchestration

- [Server](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/backend/server.js): Express entrypoint · Bootstraps the backend API server · `backend/server.js`
- [Auth routes](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/backend/routes/authRoutes.js): api routes · HTTP routes for authentication · `backend/routes/authRoutes.js`
- [File routes](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/backend/routes/fileRoutes.js): api routes · HTTP routes for document upload and file actions · `backend/routes/fileRoutes.js`
- [AI routes](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/backend/routes/aiRoutes.js): api routes · HTTP routes for chat and quiz generation · `backend/routes/aiRoutes.js`
- [Auth controller](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/backend/controllers/authController.js): controller · Login, registration, OAuth, and token handling · `backend/controllers/authController.js`
- [File controller](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/backend/controllers/fileController.js): controller · Upload intake and document workflow · `backend/controllers/fileController.js`
- [AI controller](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/backend/controllers/aiController.js): controller · Document-grounded AI request handling · `backend/controllers/aiController.js`
- [Auth middleware](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/backend/middleware/authMiddleware.js): middleware · Protects private API routes with JWT checks · `backend/middleware/authMiddleware.js`
- [RAG service](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/backend/services/ragService.js): retrieval service · Chunking, embeddings, retrieval, and answer assembly · `backend/services/ragService.js`

### Data & AI

Persistence and external AI services

- [User model](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/backend/models/User.js): mongoose model · User identity and auth persistence · `backend/models/User.js`
- [Document model](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/backend/models/Document.js): mongoose model · Uploaded document metadata and ownership · `backend/models/Document.js`
- **MongoDB**: persistent store · Primary database for users and documents
- **Pinecone**: vector index · Semantic retrieval index for document chunks
- **Gemini**: LLM/embeddings · Generates answers, quizzes, and embeddings
- [Vercel](https://github.com/priyanshudwivedi9068-eng/academicai/blob/main/frontend/vercel.json): frontend host · Hosts the client application · `frontend/vercel.json`
- **Render**: backend host · Hosts the API server

## Connections

- Main entry → App shell: mounts · Bootstraps the application shell
- App shell → Auth state: uses · Shares authentication state
- App shell → Theme state: uses · Shares theme state
- App shell → Protected route: guards · Restricts private routes
- Protected route → Dashboard layout: opens · Allows access to the dashboard shell
- Dashboard layout → Dashboard: wraps · Provides authenticated workspace chrome
- Dashboard → Overview: navigates · Workspace summary
- Dashboard → AI chat: navigates · Document-grounded chat
- Dashboard → Files: navigates · Uploads and file management
- Dashboard → Study room: navigates · Study and quiz flow
- Dashboard → Calendar: navigates · Scheduling view
- Dashboard → Billing: navigates · Subscription and payments
- Dashboard → Settings: navigates · Account preferences
- Billing → Payment modal: opens · Payment flow dialog
- App shell → Home: routes to · Public entry page
- App shell → Login: routes to · Sign-in page
- App shell → Register: routes to · Sign-up page
- Server → Auth routes: mounts · Registers auth endpoints
- Server → File routes: mounts · Registers file endpoints
- Server → AI routes: mounts · Registers AI endpoints
- Auth routes → Auth controller: dispatches · Forwards auth requests
- File routes → File controller: dispatches · Forwards file requests
- AI routes → AI controller: dispatches · Forwards AI requests
- Auth routes → Auth middleware: protects · Secures private auth-related endpoints
- File routes → Auth middleware: protects · Secures upload and document endpoints
- AI routes → Auth middleware: protects · Secures AI endpoints
- Auth controller → User model: reads/writes · Creates and authenticates users
- File controller → Document model: reads/writes · Stores document metadata
- File controller → RAG service: indexes · Sends uploaded content into retrieval processing
- AI controller → RAG service: queries · Retrieves relevant chunks for responses
- RAG service → Pinecone: searches · Retrieves semantically similar chunks
- RAG service → Gemini: embeds/generates · Creates embeddings and grounded outputs
- User model → MongoDB: persists to · User records stored in MongoDB
- Document model → MongoDB: persists to · Document records stored in MongoDB
- App shell → Server: API calls · Client talks to backend through the API boundary
- App shell → Vercel: deployed on · Frontend hosting target
- Server → Render: deployed on · Backend hosting target
- File controller → MongoDB: metadata · Document metadata is durable in the primary database
- File controller → Pinecone: chunks · Indexes document text for retrieval
- AI controller → Gemini: generates · Uses Gemini for answers and quizzes
- App shell → Auth routes: auth API · Client authentication requests
- App shell → File routes: file API · Client document requests
- App shell → AI routes: ai API · Client AI requests
- Server → MongoDB: connects · Backend database connection
- Server → Pinecone: connects · Backend vector store connection
- Server → Gemini: connects · Backend AI provider connection
