# sauugat/semestar_library architecture

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

- Interactive diagram: https://gitdiagram.com/sauugat/semestar_library
- Repository: https://github.com/sauugat/semestar_library

## Overview

Semester Library is a student portal and mobile app for course materials, study assistance, collaboration, and campus activity. A student enters through the web or mobile client, uses authenticated portal features, and receives results through APIs backed by the database and external providers. The central study workflow is Kyana chat: a question is routed through chat handling and tools for note, syllabus, routine, or current-information answers. The graph also preserves documented feed, Code Lab, cohort chat, and notification capabilities. Some subsystems are represented from README or index evidence; their internal implementation was not sampled.

Main entry points: [`server.js`](https://github.com/sauugat/semestar_library/blob/main/server.js) (Express API), [`db.js`](https://github.com/sauugat/semestar_library/blob/main/db.js) (Portal database), [`mobile/app`](https://github.com/sauugat/semestar_library/tree/main/mobile/app) (Mobile app), [`public`](https://github.com/sauugat/semestar_library/tree/main/public) (Web portal)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Student clients"]
  node_web["Web portal"]
  node_mobile["Mobile app"]
  node_chat_ui["Chat interface<br/>[chatbot.js]"]
  node_library["Library UI<br/>[library.tsx]"]
  node_posts_ui["Feed interface<br/>[index.tsx]"]
end

subgraph group_study["Study services"]
  node_chat_handler["Chat orchestration<br/>[ai-assistant.js]"]
  node_chat_tools["Study tools<br/>[chat-tools.js]"]
  node_chat_provider["Model providers<br/>[chat-provider.js]"]
  node_note_search["Note search<br/>[note-search.js]"]
  node_academic_context["Academic context"]
  node_assignments["Code Lab assignments<br/>[assignments.js]"]
  node_code_explain["Code explanations<br/>[explain.js]"]
  node_routine["Routine service<br/>[routine.js]"]
end

subgraph group_community["Community features"]
  node_posts_route["Feed API<br/>[posts.js]"]
  node_posts_service["Post services<br/>[posts.js]"]
  node_cohort_chat["Cohort chat<br/>[cohort-chat.js]"]
  node_cohort_route["Cohort chat API<br/>[cohort-chat.js]"]
end

subgraph group_platform["Platform services"]
  node_server["Express API<br/>[server.js]"]
  node_notifications_route["Notifications API<br/>[notifications.js]"]
  node_notifications_service["Notification center"]
  node_push["Push delivery"]
end

subgraph group_storage["Persistence"]
  node_database[("Portal database<br/>[db.js]")]
end

node_student(("Student"))
node_provider{{"AI/search provider"}}
node_expo{{"Expo push"}}

node_student -->|"uses"| node_web
node_student -->|"uses"| node_mobile
node_web -->|"requests"| node_server
node_mobile -.->|"requests"| node_server
node_web -->|"opens chat"| node_chat_ui
node_chat_ui -->|"posts question"| node_server
node_server -->|"routes chat"| node_chat_handler
node_chat_handler -->|"invokes tools"| node_chat_tools
node_chat_handler -->|"requests answer"| node_chat_provider
node_chat_tools -.->|"searches notes"| node_note_search
node_chat_tools -.->|"uses context"| node_academic_context
node_chat_provider -->|"queries"| node_provider
node_mobile -->|"browses"| node_library
node_server -->|"routes requests"| node_assignments
node_server -->|"routes requests"| node_code_explain
node_mobile -->|"views feed"| node_posts_ui
node_posts_ui -->|"requests feed"| node_server
node_server -->|"mounts API"| node_posts_route
node_posts_route -->|"uses post logic"| node_posts_service
node_server -.->|"mounts feature"| node_cohort_route
node_cohort_route -->|"delegates"| node_cohort_chat
node_server -.->|"serves routine"| node_routine
node_server -->|"mounts API"| node_notifications_route
node_notifications_route -->|"calls service"| node_notifications_service
node_notifications_service -->|"reads/writes"| node_database
node_posts_route -->|"reads/writes"| node_database
node_assignments -->|"reads/writes"| node_database
node_note_search -->|"indexes and searches"| node_database
node_academic_context -->|"reads context"| node_database
node_push -->|"sends pushes"| node_expo

click node_web "https://github.com/sauugat/semestar_library/tree/main/public"
click node_mobile "https://github.com/sauugat/semestar_library/tree/main/mobile/app"
click node_server "https://github.com/sauugat/semestar_library/blob/main/server.js"
click node_database "https://github.com/sauugat/semestar_library/blob/main/db.js"
click node_chat_ui "https://github.com/sauugat/semestar_library/blob/main/public/chatbot.js"
click node_chat_handler "https://github.com/sauugat/semestar_library/blob/main/ai-assistant.js"
click node_chat_tools "https://github.com/sauugat/semestar_library/blob/main/lib/chat-tools.js"
click node_chat_provider "https://github.com/sauugat/semestar_library/blob/main/lib/chat-provider.js"
click node_note_search "https://github.com/sauugat/semestar_library/blob/main/lib/note-search.js"
click node_academic_context "https://github.com/sauugat/semestar_library/blob/main/lib/academic-context.js"
click node_library "https://github.com/sauugat/semestar_library/blob/main/mobile/app/(tabs)/library.tsx"
click node_assignments "https://github.com/sauugat/semestar_library/blob/main/routes/code-lab/assignments.js"
click node_code_explain "https://github.com/sauugat/semestar_library/blob/main/routes/code-lab/explain.js"
click node_posts_ui "https://github.com/sauugat/semestar_library/blob/main/mobile/app/(tabs)/index.tsx"
click node_posts_route "https://github.com/sauugat/semestar_library/blob/main/routes/posts.js"
click node_posts_service "https://github.com/sauugat/semestar_library/blob/main/lib/posts.js"
click node_cohort_chat "https://github.com/sauugat/semestar_library/blob/main/lib/cohort-chat.js"
click node_cohort_route "https://github.com/sauugat/semestar_library/blob/main/routes/cohort-chat.js"
click node_routine "https://github.com/sauugat/semestar_library/blob/main/lib/routine.js"
click node_notifications_route "https://github.com/sauugat/semestar_library/blob/main/routes/notifications.js"
click node_notifications_service "https://github.com/sauugat/semestar_library/blob/main/lib/notifications-service.js"
click node_push "https://github.com/sauugat/semestar_library/blob/main/lib/push-notifications.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_web,node_mobile,node_chat_ui,node_library,node_posts_ui toneBlue
class node_chat_handler,node_chat_tools,node_chat_provider,node_note_search,node_academic_context,node_assignments,node_code_explain,node_routine toneAmber
class node_posts_route,node_posts_service,node_cohort_chat,node_cohort_route toneMint
class node_server,node_notifications_route,node_notifications_service,node_push toneRose
class node_database,node_student,node_provider,node_expo toneIndigo
```

## Components

### Student clients

- [Web portal](https://github.com/sauugat/semestar_library/tree/main/public): `public`
- [Mobile app](https://github.com/sauugat/semestar_library/tree/main/mobile/app): `mobile/app`
- [Chat interface](https://github.com/sauugat/semestar_library/blob/main/public/chatbot.js): `public/chatbot.js`
- [Library UI](https://github.com/sauugat/semestar_library/blob/main/mobile/app/(tabs)/library.tsx): `mobile/app/(tabs)/library.tsx`
- [Feed interface](https://github.com/sauugat/semestar_library/blob/main/mobile/app/(tabs)/index.tsx): `mobile/app/(tabs)/index.tsx`

### Study services

- [Chat orchestration](https://github.com/sauugat/semestar_library/blob/main/ai-assistant.js): `ai-assistant.js`
- [Study tools](https://github.com/sauugat/semestar_library/blob/main/lib/chat-tools.js): `lib/chat-tools.js`
- [Model providers](https://github.com/sauugat/semestar_library/blob/main/lib/chat-provider.js): `lib/chat-provider.js`
- [Note search](https://github.com/sauugat/semestar_library/blob/main/lib/note-search.js): `lib/note-search.js`
- [Academic context](https://github.com/sauugat/semestar_library/blob/main/lib/academic-context.js): `lib/academic-context.js`
- [Code Lab assignments](https://github.com/sauugat/semestar_library/blob/main/routes/code-lab/assignments.js): `routes/code-lab/assignments.js`
- [Code explanations](https://github.com/sauugat/semestar_library/blob/main/routes/code-lab/explain.js): `routes/code-lab/explain.js`
- [Routine service](https://github.com/sauugat/semestar_library/blob/main/lib/routine.js): `lib/routine.js`

### Community features

- [Feed API](https://github.com/sauugat/semestar_library/blob/main/routes/posts.js): `routes/posts.js`
- [Post services](https://github.com/sauugat/semestar_library/blob/main/lib/posts.js): `lib/posts.js`
- [Cohort chat](https://github.com/sauugat/semestar_library/blob/main/lib/cohort-chat.js): `lib/cohort-chat.js`
- [Cohort chat API](https://github.com/sauugat/semestar_library/blob/main/routes/cohort-chat.js): `routes/cohort-chat.js`

### Platform services

- [Express API](https://github.com/sauugat/semestar_library/blob/main/server.js): `server.js`
- [Notifications API](https://github.com/sauugat/semestar_library/blob/main/routes/notifications.js): `routes/notifications.js`
- [Notification center](https://github.com/sauugat/semestar_library/blob/main/lib/notifications-service.js): `lib/notifications-service.js`
- [Push delivery](https://github.com/sauugat/semestar_library/blob/main/lib/push-notifications.js): `lib/push-notifications.js`

### Persistence

- [Portal database](https://github.com/sauugat/semestar_library/blob/main/db.js): `db.js`

### Other components

- **Student**
- **AI/search provider**
- **Expo push**

## Connections

- Student → Web portal: uses (evidence: `README.md`)
- Student → Mobile app: uses (evidence: `README.md`)
- Web portal → Express API: requests (evidence: `server.js`)
- Mobile app → Express API: requests
- Web portal → Chat interface: opens chat (evidence: `README.md`)
- Chat interface → Express API: posts question (evidence: `README.md`)
- Express API → Chat orchestration: routes chat (evidence: `server.js`)
- Chat orchestration → Study tools: invokes tools (evidence: `ai-assistant.js`)
- Chat orchestration → Model providers: requests answer (evidence: `ai-assistant.js`)
- Study tools → Note search: searches notes
- Study tools → Academic context: uses context
- Model providers → AI/search provider: queries (evidence: `README.md`)
- Mobile app → Library UI: browses (evidence: `README.md`)
- Express API → Code Lab assignments: routes requests (evidence: `server.js`)
- Express API → Code explanations: routes requests (evidence: `server.js`)
- Mobile app → Feed interface: views feed (evidence: `README.md`)
- Feed interface → Express API: requests feed (evidence: `README.md`)
- Express API → Feed API: mounts API (evidence: `server.js`)
- Feed API → Post services: uses post logic (evidence: `routes/posts.js`)
- Express API → Cohort chat API: mounts feature (evidence: `server.js`)
- Cohort chat API → Cohort chat: delegates (evidence: `routes/cohort-chat.js`)
- Express API → Routine service: serves routine
- Express API → Notifications API: mounts API (evidence: `server.js`)
- Notifications API → Notification center: calls service (evidence: `routes/notifications.js`)
- Notification center → Portal database: reads/writes (evidence: `lib/notifications-service.js`)
- Feed API → Portal database: reads/writes (evidence: `routes/posts.js`)
- Code Lab assignments → Portal database: reads/writes (evidence: `routes/code-lab/assignments.js`)
- Note search → Portal database: indexes and searches (evidence: `lib/note-search.js`)
- Academic context → Portal database: reads context (evidence: `lib/academic-context.js`)
- Push delivery → Expo push: sends pushes (evidence: `README.md`)
