# rohitchintalapudi/learnflowai-backend architecture

> Architecture diagram of the GitHub repository rohitchintalapudi/learnflowai-backend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rohitchintalapudi/learnflowai-backend
- Repository: https://github.com/rohitchintalapudi/learnflowai-backend

## Overview

This is an Express/TypeScript backend for an AI doubt-clarification and learning platform. The main user journey is authenticated API access to document ingestion or an AI learning workflow, followed by generated learning material, progress/analytics, and account-management results. The graph includes documented workflow capabilities even where their internal implementation was not sampled; those paths are directory-level and their internal call links are omitted. The document pipeline and authentication links have source-index or excerpt evidence; the README supplies the general service-to-database request-flow context.

Main entry points: [`src/app.ts`](https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/app.ts) (Express API), [`src/services/document.service.ts`](https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/services/document.service.ts) (Document processing), [`src/routes/document.routes.ts`](https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/routes/document.routes.ts) (Document API), [`src/auth/auth.ts`](https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/auth/auth.ts) (Authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and identity"]
  node_app["Express API<br/>[app.ts]"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_authmw["Session middleware<br/>[auth.middleware.ts]"]
  node_db[("PostgreSQL<br/>[prisma.ts]")]
end

subgraph group_learning["AI learning workflows"]
  node_workflow["AI workflows"]
  node_quiz["Quiz generation<br/>[quiz.service.ts]"]
  node_notes["Notes generation"]
  node_explanation["Explanations"]
  node_mindmap["Mind maps"]
  node_analogy["Analogies"]
  node_interview["Interview questions"]
  node_simulation["Simulations"]
end

subgraph group_knowledge["Document knowledge"]
  node_documents["Document API<br/>[document.routes.ts]"]
  node_documentctl["Document controller"]
  node_documentservice["Document processing"]
  node_parser["Document parser"]
  node_chunks["Text chunking<br/>[chunk.service.ts]"]
  node_vectors["Vector storage<br/>[vector.service.ts]"]
  node_rag["Relevant retrieval"]
  node_textsearch["Text search<br/>[textSearch.ts]"]
end

subgraph group_userdata["Progress and account"]
  node_profile["User profiles<br/>[profile.service.ts]"]
  node_history["Learning history"]
  node_quizdash["Quiz dashboard"]
  node_analytics["Analytics and insights"]
  node_dashboard["Dashboard"]
  node_settings["Account settings"]
  node_storage["Storage usage<br/>[storage.service.ts]"]
  node_alerts["Alerts and feedback"]
end

node_learner(("Learner"))

node_learner -->|"sends requests"| node_app
node_app -->|"routes auth"| node_auth
node_auth -->|"uses Prisma"| node_db
node_app -->|"mounts routes"| node_documents
node_documents -->|"protects routes"| node_authmw
node_documents -->|"dispatches requests"| node_documentctl
node_documentctl -->|"processes documents"| node_documentservice
node_documentservice -->|"parses files"| node_parser
node_documentservice -->|"creates chunks"| node_chunks
node_documentservice -->|"stores vectors"| node_vectors
node_rag -->|"searches text"| node_textsearch
node_app -->|"mounts workflow routes"| node_workflow
node_learner -.->|"requests quizzes"| node_quiz
node_learner -.->|"requests notes"| node_notes
node_learner -.->|"requests explanations"| node_explanation
node_learner -.->|"requests mind maps"| node_mindmap
node_learner -.->|"requests analogies"| node_analogy
node_learner -.->|"requests questions"| node_interview
node_learner -.->|"requests simulations"| node_simulation
node_app -->|"mounts profile routes"| node_profile
node_app -->|"mounts history routes"| node_history
node_app -->|"mounts quiz routes"| node_quizdash
node_app -->|"mounts analytics routes"| node_analytics
node_app -->|"mounts dashboard routes"| node_dashboard
node_app -->|"mounts settings routes"| node_settings
node_app -->|"mounts alerts routes"| node_alerts
node_settings -.->|"includes storage settings"| node_storage
node_storage -->|"reads usage records"| node_db

click node_app "https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/app.ts"
click node_auth "https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/auth/auth.ts"
click node_authmw "https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/middlewares/auth.middleware.ts"
click node_db "https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/database/prisma.ts"
click node_documents "https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/routes/document.routes.ts"
click node_documentctl "https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/controllers/document.controller.ts"
click node_documentservice "https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/services/document.service.ts"
click node_parser "https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/services/documentParser.service.ts"
click node_chunks "https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/services/chunk.service.ts"
click node_vectors "https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/services/vector.service.ts"
click node_rag "https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/lib/rag/retrieveRelevantChunks.ts"
click node_textsearch "https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/lib/rag/textSearch.ts"
click node_workflow "https://github.com/rohitchintalapudi/learnflowai-backend/tree/main/src/modules/workflow"
click node_quiz "https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/modules/workflow/quiz/quiz.service.ts"
click node_notes "https://github.com/rohitchintalapudi/learnflowai-backend/tree/main/src/modules/workflow/notes"
click node_explanation "https://github.com/rohitchintalapudi/learnflowai-backend/tree/main/src/modules/workflow/explanation"
click node_mindmap "https://github.com/rohitchintalapudi/learnflowai-backend/tree/main/src/modules/workflow/mindmap"
click node_analogy "https://github.com/rohitchintalapudi/learnflowai-backend/tree/main/src/modules/workflow/analogy"
click node_interview "https://github.com/rohitchintalapudi/learnflowai-backend/tree/main/src/modules/workflow/interview-questions"
click node_simulation "https://github.com/rohitchintalapudi/learnflowai-backend/tree/main/src/modules/workflow/simulation"
click node_profile "https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/modules/profile/profile.service.ts"
click node_history "https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/modules/learning-history/learningHistory.service.ts"
click node_quizdash "https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/modules/quiz-dashboard/quizDashboard.service.ts"
click node_analytics "https://github.com/rohitchintalapudi/learnflowai-backend/tree/main/src/modules/analytics"
click node_dashboard "https://github.com/rohitchintalapudi/learnflowai-backend/tree/main/src/modules/dashboard"
click node_settings "https://github.com/rohitchintalapudi/learnflowai-backend/tree/main/src/modules/settings"
click node_storage "https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/modules/settings/storage/storage.service.ts"
click node_alerts "https://github.com/rohitchintalapudi/learnflowai-backend/tree/main/src/modules/alerts"

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_app,node_auth,node_authmw,node_db toneBlue
class node_workflow,node_quiz,node_notes,node_explanation,node_mindmap,node_analogy,node_interview,node_simulation toneAmber
class node_documents,node_documentctl,node_documentservice,node_parser,node_chunks,node_vectors,node_rag,node_textsearch toneMint
class node_profile,node_history,node_quizdash,node_analytics,node_dashboard,node_settings,node_storage,node_alerts toneRose
class node_learner toneIndigo
```

## Components

### API and identity

- [Express API](https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/app.ts): `src/app.ts`
- [Authentication](https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/auth/auth.ts): `src/auth/auth.ts`
- [Session middleware](https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/middlewares/auth.middleware.ts): `src/middlewares/auth.middleware.ts`
- [PostgreSQL](https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/database/prisma.ts): `src/database/prisma.ts`

### AI learning workflows

- [AI workflows](https://github.com/rohitchintalapudi/learnflowai-backend/tree/main/src/modules/workflow): `src/modules/workflow`
- [Quiz generation](https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/modules/workflow/quiz/quiz.service.ts): `src/modules/workflow/quiz/quiz.service.ts`
- [Notes generation](https://github.com/rohitchintalapudi/learnflowai-backend/tree/main/src/modules/workflow/notes): `src/modules/workflow/notes`
- [Explanations](https://github.com/rohitchintalapudi/learnflowai-backend/tree/main/src/modules/workflow/explanation): `src/modules/workflow/explanation`
- [Mind maps](https://github.com/rohitchintalapudi/learnflowai-backend/tree/main/src/modules/workflow/mindmap): `src/modules/workflow/mindmap`
- [Analogies](https://github.com/rohitchintalapudi/learnflowai-backend/tree/main/src/modules/workflow/analogy): `src/modules/workflow/analogy`
- [Interview questions](https://github.com/rohitchintalapudi/learnflowai-backend/tree/main/src/modules/workflow/interview-questions): `src/modules/workflow/interview-questions`
- [Simulations](https://github.com/rohitchintalapudi/learnflowai-backend/tree/main/src/modules/workflow/simulation): `src/modules/workflow/simulation`

### Document knowledge

- [Document API](https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/routes/document.routes.ts): `src/routes/document.routes.ts`
- [Document controller](https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/controllers/document.controller.ts): `src/controllers/document.controller.ts`
- [Document processing](https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/services/document.service.ts): `src/services/document.service.ts`
- [Document parser](https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/services/documentParser.service.ts): `src/services/documentParser.service.ts`
- [Text chunking](https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/services/chunk.service.ts): `src/services/chunk.service.ts`
- [Vector storage](https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/services/vector.service.ts): `src/services/vector.service.ts`
- [Relevant retrieval](https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/lib/rag/retrieveRelevantChunks.ts): `src/lib/rag/retrieveRelevantChunks.ts`
- [Text search](https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/lib/rag/textSearch.ts): `src/lib/rag/textSearch.ts`

### Progress and account

- [User profiles](https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/modules/profile/profile.service.ts): `src/modules/profile/profile.service.ts`
- [Learning history](https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/modules/learning-history/learningHistory.service.ts): `src/modules/learning-history/learningHistory.service.ts`
- [Quiz dashboard](https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/modules/quiz-dashboard/quizDashboard.service.ts): `src/modules/quiz-dashboard/quizDashboard.service.ts`
- [Analytics and insights](https://github.com/rohitchintalapudi/learnflowai-backend/tree/main/src/modules/analytics): `src/modules/analytics`
- [Dashboard](https://github.com/rohitchintalapudi/learnflowai-backend/tree/main/src/modules/dashboard): `src/modules/dashboard`
- [Account settings](https://github.com/rohitchintalapudi/learnflowai-backend/tree/main/src/modules/settings): `src/modules/settings`
- [Storage usage](https://github.com/rohitchintalapudi/learnflowai-backend/blob/main/src/modules/settings/storage/storage.service.ts): `src/modules/settings/storage/storage.service.ts`
- [Alerts and feedback](https://github.com/rohitchintalapudi/learnflowai-backend/tree/main/src/modules/alerts): `src/modules/alerts`

### Other components

- **Learner**

## Connections

- Learner → Express API: sends requests
- Express API → Authentication: routes auth (evidence: `src/app.ts`)
- Authentication → PostgreSQL: uses Prisma (evidence: `src/auth/auth.ts`)
- Express API → Document API: mounts routes (evidence: `src/app.ts`)
- Document API → Session middleware: protects routes (evidence: `src/routes/document.routes.ts`)
- Document API → Document controller: dispatches requests (evidence: `src/routes/document.routes.ts`)
- Document controller → Document processing: processes documents (evidence: `src/controllers/document.controller.ts`)
- Document processing → Document parser: parses files (evidence: `src/services/document.service.ts`)
- Document processing → Text chunking: creates chunks (evidence: `src/services/document.service.ts`)
- Document processing → Vector storage: stores vectors (evidence: `src/services/document.service.ts`)
- Relevant retrieval → Text search: searches text (evidence: `src/lib/rag/retrieveRelevantChunks.ts`)
- Express API → AI workflows: mounts workflow routes (evidence: `src/app.ts`)
- Learner → Quiz generation: requests quizzes
- Learner → Notes generation: requests notes
- Learner → Explanations: requests explanations
- Learner → Mind maps: requests mind maps
- Learner → Analogies: requests analogies
- Learner → Interview questions: requests questions
- Learner → Simulations: requests simulations
- Express API → User profiles: mounts profile routes (evidence: `src/app.ts`)
- Express API → Learning history: mounts history routes (evidence: `src/app.ts`)
- Express API → Quiz dashboard: mounts quiz routes (evidence: `src/app.ts`)
- Express API → Analytics and insights: mounts analytics routes (evidence: `src/app.ts`)
- Express API → Dashboard: mounts dashboard routes (evidence: `src/app.ts`)
- Express API → Account settings: mounts settings routes (evidence: `src/app.ts`)
- Express API → Alerts and feedback: mounts alerts routes (evidence: `src/app.ts`)
- Account settings → Storage usage: includes storage settings (evidence: `src/modules/settings/storage/storage.controller.ts`)
- Storage usage → PostgreSQL: reads usage records (evidence: `src/modules/settings/storage/storage.service.ts`)
