# hamsaraj875-del/learn-flow architecture

> Architecture diagram of the GitHub repository hamsaraj875-del/learn-flow, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hamsaraj875-del/learn-flow
- Repository: https://github.com/hamsaraj875-del/learn-flow

## Overview

LearnFlow is an Android study app backed by an Express/MongoDB server. The server workflow routes authentication, chat, document, test, and study-session requests to controllers; those controllers persist data and invoke AI services where shown. Android source paths indicate corresponding chat, session, test, focus, and account capabilities, but their wiring to one another or to the API is not established by the supplied excerpts. The graph therefore omits those speculative links; some server internals are also unsampled.

Main entry points: [`Server/controllers/controller.js`](https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/controllers/controller.js) (Chat and sessions), [`Server/routes/app.js`](https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/routes/app.js) (API routes), [`Server/controllers/aiResponseController.js`](https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/controllers/aiResponseController.js) (Chat and documents), [`Server/controllers/testController.js`](https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/controllers/testController.js) (Test controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_android["Android app"]
  node_android_app["Android app<br/>[LearnFlowApp.kt]"]
  node_chat_ui["Chat screens"]
  node_sessions_ui["Study sessions"]
  node_tests_ui["Tests and quizzes"]
  node_focus_ui["Focus blocking"]
  node_account_ui["Account screens<br/>[AccountDetails.kt]"]
end

subgraph group_routing["Server routing"]
  node_api_routes["API routes<br/>[app.js]"]
  node_login_routes["Login routes<br/>[login.js]"]
end

subgraph group_identity["Accounts"]
  node_login_controller["Account controller<br/>[loginController.js]"]
end

subgraph group_learning["Learning services"]
  node_chat_controller["Chat and sessions<br/>[controller.js]"]
  node_ai_controller["Chat and documents"]
  node_test_controller["Test controller<br/>[testController.js]"]
  node_rag_service["Document responses<br/>[ragAi.js]"]
  node_test_ai["Question generation<br/>[testAi.js]"]
  node_test_scoring["Answer evaluation<br/>[testResultAi.js]"]
end

subgraph group_persistence["Persistence"]
  node_user_store[("User records<br/>[database.js]")]
  node_message_store[("Messages<br/>[messages.js]")]
  node_mcq_store[("MCQ records<br/>[mcqTest.js]")]
  node_question_store[("Written-test records<br/>[questionTest.js]")]
  node_session_store[("Study sessions<br/>[studySession.js]")]
  node_conversation_store[("Conversations<br/>[conversation.js]")]
  node_document_store[("Documents<br/>[documents.js]")]
  node_chunk_store[("Document chunks<br/>[textChunk.js]")]
end

node_learner(("Learner"))
node_external_ai{{"AI providers"}}
node_supabase[("Supabase storage")]
node_email{{"Email service"}}

node_api_routes -->|"mounts"| node_login_routes
node_api_routes -->|"routes requests"| node_chat_controller
node_api_routes -->|"routes requests"| node_ai_controller
node_api_routes -->|"routes requests"| node_test_controller
node_login_routes -->|"dispatches"| node_login_controller
node_login_routes -->|"imports model"| node_user_store
node_login_controller -->|"reads and writes"| node_user_store
node_login_controller -->|"sends OTP"| node_email
node_chat_controller -->|"checks users"| node_user_store
node_chat_controller -->|"reads and writes"| node_message_store
node_chat_controller -->|"reads and writes"| node_conversation_store
node_chat_controller -->|"reads and writes"| node_session_store
node_chat_controller -->|"reads tests"| node_mcq_store
node_ai_controller -->|"stores messages"| node_message_store
node_ai_controller -->|"stores documents"| node_document_store
node_ai_controller -->|"stores and searches chunks"| node_chunk_store
node_ai_controller -->|"requests answers"| node_rag_service
node_api_routes -->|"uploads PDFs"| node_supabase
node_test_controller -->|"creates and updates"| node_mcq_store
node_test_controller -->|"creates and updates"| node_question_store
node_test_controller -->|"generates questions"| node_test_ai
node_test_controller -->|"evaluates answers"| node_test_scoring
node_rag_service -->|"generates responses"| node_external_ai
node_test_ai -->|"generates questions"| node_external_ai
node_learner -.-> node_android_app

click node_android_app "https://github.com/hamsaraj875-del/learn-flow/blob/main/App/app/src/main/java/com/example/learnflow/LearnFlowApp.kt"
click node_chat_ui "https://github.com/hamsaraj875-del/learn-flow/tree/main/App/app/src/main/java/com/example/learnflow/chat"
click node_sessions_ui "https://github.com/hamsaraj875-del/learn-flow/tree/main/App/app/src/main/java/com/example/learnflow/session"
click node_tests_ui "https://github.com/hamsaraj875-del/learn-flow/tree/main/App/app/src/main/java/com/example/learnflow/test"
click node_focus_ui "https://github.com/hamsaraj875-del/learn-flow/tree/main/App/app/src/main/java/com/example/learnflow/focus"
click node_account_ui "https://github.com/hamsaraj875-del/learn-flow/blob/main/App/app/src/main/java/com/example/learnflow/account/AccountDetails.kt"
click node_api_routes "https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/routes/app.js"
click node_login_routes "https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/routes/login.js"
click node_login_controller "https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/controllers/loginController.js"
click node_user_store "https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/models/database.js"
click node_chat_controller "https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/controllers/controller.js"
click node_ai_controller "https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/controllers/aiResponseController.js"
click node_test_controller "https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/controllers/testController.js"
click node_rag_service "https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/services/ragAi.js"
click node_test_ai "https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/services/testAi.js"
click node_test_scoring "https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/services/testResultAi.js"
click node_message_store "https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/models/messages.js"
click node_mcq_store "https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/models/mcqTest.js"
click node_question_store "https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/models/questionTest.js"
click node_session_store "https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/models/studySession.js"
click node_conversation_store "https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/models/conversation.js"
click node_document_store "https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/models/documents.js"
click node_chunk_store "https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/models/textChunk.js"

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_android_app,node_chat_ui,node_sessions_ui,node_tests_ui,node_focus_ui,node_account_ui toneBlue
class node_api_routes,node_login_routes,node_supabase toneAmber
class node_login_controller toneMint
class node_chat_controller,node_ai_controller,node_test_controller,node_rag_service,node_test_ai,node_test_scoring toneRose
class node_user_store,node_message_store,node_mcq_store,node_question_store,node_session_store,node_conversation_store,node_document_store,node_chunk_store,node_learner,node_external_ai,node_email toneIndigo
```

## Components

### Android app

- [Android app](https://github.com/hamsaraj875-del/learn-flow/blob/main/App/app/src/main/java/com/example/learnflow/LearnFlowApp.kt): `App/app/src/main/java/com/example/learnflow/LearnFlowApp.kt`
- [Chat screens](https://github.com/hamsaraj875-del/learn-flow/tree/main/App/app/src/main/java/com/example/learnflow/chat): `App/app/src/main/java/com/example/learnflow/chat`
- [Study sessions](https://github.com/hamsaraj875-del/learn-flow/tree/main/App/app/src/main/java/com/example/learnflow/session): `App/app/src/main/java/com/example/learnflow/session`
- [Tests and quizzes](https://github.com/hamsaraj875-del/learn-flow/tree/main/App/app/src/main/java/com/example/learnflow/test): `App/app/src/main/java/com/example/learnflow/test`
- [Focus blocking](https://github.com/hamsaraj875-del/learn-flow/tree/main/App/app/src/main/java/com/example/learnflow/focus): `App/app/src/main/java/com/example/learnflow/focus`
- [Account screens](https://github.com/hamsaraj875-del/learn-flow/blob/main/App/app/src/main/java/com/example/learnflow/account/AccountDetails.kt): `App/app/src/main/java/com/example/learnflow/account/AccountDetails.kt`

### Server routing

- [API routes](https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/routes/app.js): `Server/routes/app.js`
- [Login routes](https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/routes/login.js): `Server/routes/login.js`

### Accounts

- [Account controller](https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/controllers/loginController.js): `Server/controllers/loginController.js`

### Learning services

- [Chat and sessions](https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/controllers/controller.js): `Server/controllers/controller.js`
- [Chat and documents](https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/controllers/aiResponseController.js): `Server/controllers/aiResponseController.js`
- [Test controller](https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/controllers/testController.js): `Server/controllers/testController.js`
- [Document responses](https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/services/ragAi.js): `Server/services/ragAi.js`
- [Question generation](https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/services/testAi.js): `Server/services/testAi.js`
- [Answer evaluation](https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/services/testResultAi.js): `Server/services/testResultAi.js`

### Persistence

- [User records](https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/models/database.js): `Server/models/database.js`
- [Messages](https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/models/messages.js): `Server/models/messages.js`
- [MCQ records](https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/models/mcqTest.js): `Server/models/mcqTest.js`
- [Written-test records](https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/models/questionTest.js): `Server/models/questionTest.js`
- [Study sessions](https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/models/studySession.js): `Server/models/studySession.js`
- [Conversations](https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/models/conversation.js): `Server/models/conversation.js`
- [Documents](https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/models/documents.js): `Server/models/documents.js`
- [Document chunks](https://github.com/hamsaraj875-del/learn-flow/blob/main/Server/models/textChunk.js): `Server/models/textChunk.js`

### Other components

- **Learner**
- **AI providers**
- **Supabase storage**
- **Email service**

## Connections

- API routes → Login routes: mounts (evidence: `Server/routes/app.js`)
- API routes → Chat and sessions: routes requests (evidence: `Server/routes/app.js`)
- API routes → Chat and documents: routes requests (evidence: `Server/routes/app.js`)
- API routes → Test controller: routes requests (evidence: `Server/routes/app.js`)
- Login routes → Account controller: dispatches (evidence: `Server/routes/login.js`)
- Login routes → User records: imports model (evidence: `Server/routes/login.js`)
- Account controller → User records: reads and writes (evidence: `Server/controllers/loginController.js`)
- Account controller → Email service: sends OTP (evidence: `Server/controllers/loginController.js`)
- Chat and sessions → User records: checks users (evidence: `Server/controllers/controller.js`)
- Chat and sessions → Messages: reads and writes (evidence: `Server/controllers/controller.js`)
- Chat and sessions → Conversations: reads and writes (evidence: `Server/controllers/controller.js`)
- Chat and sessions → Study sessions: reads and writes (evidence: `Server/controllers/controller.js`)
- Chat and sessions → MCQ records: reads tests (evidence: `Server/controllers/controller.js`)
- Chat and documents → Messages: stores messages (evidence: `Server/controllers/aiResponseController.js`)
- Chat and documents → Documents: stores documents (evidence: `Server/controllers/aiResponseController.js`)
- Chat and documents → Document chunks: stores and searches chunks (evidence: `Server/controllers/aiResponseController.js`)
- Chat and documents → Document responses: requests answers (evidence: `Server/controllers/aiResponseController.js`)
- API routes → Supabase storage: uploads PDFs (evidence: `Server/routes/app.js`)
- Test controller → MCQ records: creates and updates (evidence: `Server/controllers/testController.js`)
- Test controller → Written-test records: creates and updates (evidence: `Server/controllers/testController.js`)
- Test controller → Question generation: generates questions (evidence: `Server/controllers/testController.js`)
- Test controller → Answer evaluation: evaluates answers (evidence: `Server/controllers/testController.js`)
- Document responses → AI providers: generates responses (evidence: `Server/services/ragAi.js`)
- Question generation → AI providers: generates questions (evidence: `Server/services/testAi.js`)
- Learner → Android app
