# sahilbhoyaraiml23-prog/final-year-project architecture

> Architecture diagram of the GitHub repository sahilbhoyaraiml23-prog/final-year-project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sahilbhoyaraiml23-prog/final-year-project
- Repository: https://github.com/sahilbhoyaraiml23-prog/final-year-project

## Overview

Smart Campus Intelligence is a student- and faculty-facing campus portal. Users authenticate with institutional accounts, then use academic services (courses, announcements, resources, assignments and results), AI assistance, or the peer marketplace and chat. The React app calls the Express API; backend controllers coordinate persistence, uploads, audit events and realtime notifications. The README establishes the major capabilities, while sampled code and the SOURCE INDEX support only some individual connections; uncertain links are omitted.

Main entry points: [`backend/src/routes/index.ts`](https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/backend/src/routes/index.ts) (API routes), [`backend/src/services/prisma.ts`](https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/backend/src/services/prisma.ts) (Prisma access), [`frontend/src/App.tsx`](https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/frontend/src/App.tsx) (Application shell), [`backend/src/controllers/marketplaceController.ts`](https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/backend/src/controllers/marketplaceController.ts) (Marketplace lifecycle)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Campus Web App"]
  node_web_app["Application shell<br/>[App.tsx]"]
  node_auth_ui["Sign-in and registration<br/>[AuthPage.tsx]"]
  node_auth_state["Session state<br/>[AuthContext.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
  node_academic_ui["Academic pages"]
  node_market_ui["Marketplace pages"]
  node_chat_state["Chat state<br/>[ChatContext.tsx]"]
  node_chatbot["Campus chatbot<br/>[CampusChatbot.tsx]"]
end

subgraph group_backend["API and Identity"]
  node_backend_app["Express application<br/>[app.ts]"]
  node_api_routes["API routes<br/>[index.ts]"]
  node_auth_controller["Authentication<br/>[authController.ts]"]
  node_user_controller["User management<br/>[userController.ts]"]
  node_audit_service["Audit logging<br/>[audit.ts]"]
  node_prisma["Prisma access<br/>[prisma.ts]"]
end

subgraph group_academic["Academic Services"]
  node_academic_controllers["Academic controllers"]
  node_ai_controller["AI assistance<br/>[aiController.ts]"]
  node_rag["RAG knowledge service<br/>[ragService.ts]"]
  node_file_storage["Secure file storage<br/>[fileStorage.ts]"]
end

subgraph group_market["Marketplace and Realtime"]
  node_market_controller["Marketplace lifecycle"]
  node_chat_controller["Chat controller<br/>[chatController.ts]"]
  node_socket_service["Realtime service<br/>[socket.ts]"]
end

node_campus_user(("Campus user"))
node_database[("SQLite database")]

node_campus_user -->|"uses"| node_web_app
node_web_app -->|"shows when signed out"| node_auth_ui
node_web_app -->|"renders academic views"| node_academic_ui
node_web_app -.->|"provides marketplace views"| node_market_ui
node_web_app -->|"provides chat context"| node_chat_state
node_web_app -->|"renders"| node_chatbot
node_auth_ui -->|"submits credentials"| node_auth_state
node_auth_state -->|"calls API"| node_api_client
node_academic_ui -.->|"requests campus data"| node_api_client
node_market_ui -.->|"requests listings"| node_api_client
node_chat_state -->|"uses API client"| node_api_client
node_api_client -->|"REST requests"| node_backend_app
node_backend_app -->|"mounts routes"| node_api_routes
node_api_routes -->|"routes auth"| node_auth_controller
node_api_routes -->|"routes users"| node_user_controller
node_api_routes -->|"routes academic services"| node_academic_controllers
node_api_routes -->|"routes AI"| node_ai_controller
node_api_routes -->|"routes marketplace"| node_market_controller
node_api_routes -->|"routes chat"| node_chat_controller
node_auth_controller -->|"reads and writes"| node_prisma
node_user_controller -.->|"persists user data"| node_prisma
node_academic_controllers -.->|"persists academic data"| node_prisma
node_academic_controllers -.->|"stores uploads"| node_file_storage
node_academic_controllers -.->|"records actions"| node_audit_service
node_ai_controller -->|"retrieves knowledge"| node_rag
node_rag -->|"enriches from records"| node_prisma
node_market_controller -->|"persists listings"| node_prisma
node_market_controller -->|"stores listing images"| node_file_storage
node_market_controller -->|"records actions"| node_audit_service
node_market_controller -->|"emits updates"| node_socket_service
node_chat_controller -.->|"supports realtime chat"| node_socket_service
node_prisma -->|"database access"| node_database
node_socket_service -->|"persists chat data"| node_prisma

click node_web_app "https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/frontend/src/App.tsx"
click node_auth_ui "https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/frontend/src/pages/auth/AuthPage.tsx"
click node_auth_state "https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/frontend/src/context/AuthContext.tsx"
click node_api_client "https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/frontend/src/services/api.ts"
click node_academic_ui "https://github.com/sahilbhoyaraiml23-prog/final-year-project/tree/main/frontend/src/pages/academic"
click node_market_ui "https://github.com/sahilbhoyaraiml23-prog/final-year-project/tree/main/frontend/src/pages/marketplace"
click node_chat_state "https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/frontend/src/context/ChatContext.tsx"
click node_chatbot "https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/frontend/src/chatbot/CampusChatbot.tsx"
click node_backend_app "https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/backend/src/app.ts"
click node_api_routes "https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/backend/src/routes/index.ts"
click node_auth_controller "https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/backend/src/controllers/authController.ts"
click node_user_controller "https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/backend/src/controllers/userController.ts"
click node_academic_controllers "https://github.com/sahilbhoyaraiml23-prog/final-year-project/tree/main/backend/src/controllers"
click node_ai_controller "https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/backend/src/controllers/aiController.ts"
click node_rag "https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/backend/src/services/ragService.ts"
click node_market_controller "https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/backend/src/controllers/marketplaceController.ts"
click node_chat_controller "https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/backend/src/controllers/chatController.ts"
click node_socket_service "https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/backend/src/services/socket.ts"
click node_file_storage "https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/backend/src/services/fileStorage.ts"
click node_audit_service "https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/backend/src/services/audit.ts"
click node_prisma "https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/backend/src/services/prisma.ts"

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_app,node_auth_ui,node_auth_state,node_api_client,node_academic_ui,node_market_ui,node_chat_state,node_chatbot,node_campus_user toneBlue
class node_backend_app,node_api_routes,node_auth_controller,node_user_controller,node_audit_service,node_prisma,node_database toneAmber
class node_academic_controllers,node_ai_controller,node_rag,node_file_storage toneMint
class node_market_controller,node_chat_controller,node_socket_service toneRose
```

## Components

### Campus Web App

- [Application shell](https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Sign-in and registration](https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/frontend/src/pages/auth/AuthPage.tsx): `frontend/src/pages/auth/AuthPage.tsx`
- [Session state](https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/frontend/src/context/AuthContext.tsx): `frontend/src/context/AuthContext.tsx`
- [API client](https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/frontend/src/services/api.ts): `frontend/src/services/api.ts`
- [Academic pages](https://github.com/sahilbhoyaraiml23-prog/final-year-project/tree/main/frontend/src/pages/academic): `frontend/src/pages/academic`
- [Marketplace pages](https://github.com/sahilbhoyaraiml23-prog/final-year-project/tree/main/frontend/src/pages/marketplace): `frontend/src/pages/marketplace`
- [Chat state](https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/frontend/src/context/ChatContext.tsx): `frontend/src/context/ChatContext.tsx`
- [Campus chatbot](https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/frontend/src/chatbot/CampusChatbot.tsx): `frontend/src/chatbot/CampusChatbot.tsx`

### API and Identity

- [Express application](https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/backend/src/app.ts): `backend/src/app.ts`
- [API routes](https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/backend/src/routes/index.ts): `backend/src/routes/index.ts`
- [Authentication](https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/backend/src/controllers/authController.ts): `backend/src/controllers/authController.ts`
- [User management](https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/backend/src/controllers/userController.ts): `backend/src/controllers/userController.ts`
- [Audit logging](https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/backend/src/services/audit.ts): `backend/src/services/audit.ts`
- [Prisma access](https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/backend/src/services/prisma.ts): `backend/src/services/prisma.ts`

### Academic Services

- [Academic controllers](https://github.com/sahilbhoyaraiml23-prog/final-year-project/tree/main/backend/src/controllers): `backend/src/controllers`
- [AI assistance](https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/backend/src/controllers/aiController.ts): `backend/src/controllers/aiController.ts`
- [RAG knowledge service](https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/backend/src/services/ragService.ts): `backend/src/services/ragService.ts`
- [Secure file storage](https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/backend/src/services/fileStorage.ts): `backend/src/services/fileStorage.ts`

### Marketplace and Realtime

- [Marketplace lifecycle](https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/backend/src/controllers/marketplaceController.ts): `backend/src/controllers/marketplaceController.ts`
- [Chat controller](https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/backend/src/controllers/chatController.ts): `backend/src/controllers/chatController.ts`
- [Realtime service](https://github.com/sahilbhoyaraiml23-prog/final-year-project/blob/main/backend/src/services/socket.ts): `backend/src/services/socket.ts`

### Other components

- **Campus user**
- **SQLite database**

## Connections

- Campus user → Application shell: uses (evidence: `README.md`)
- Application shell → Sign-in and registration: shows when signed out (evidence: `frontend/src/App.tsx`)
- Application shell → Academic pages: renders academic views (evidence: `frontend/src/App.tsx`)
- Application shell → Marketplace pages: provides marketplace views (evidence: `README.md`)
- Application shell → Chat state: provides chat context (evidence: `frontend/src/App.tsx`)
- Application shell → Campus chatbot: renders (evidence: `frontend/src/App.tsx`)
- Sign-in and registration → Session state: submits credentials (evidence: `frontend/src/pages/auth/AuthPage.tsx`)
- Session state → API client: calls API (evidence: `frontend/src/context/AuthContext.tsx`)
- Academic pages → API client: requests campus data (evidence: `frontend/src/pages/academic/CoursesPage.tsx`)
- Marketplace pages → API client: requests listings (evidence: `README.md`)
- Chat state → API client: uses API client (evidence: `frontend/src/context/ChatContext.tsx`)
- API client → Express application: REST requests (evidence: `README.md`)
- Express application → API routes: mounts routes (evidence: `backend/src/app.ts`)
- API routes → Authentication: routes auth (evidence: `backend/src/routes/index.ts`)
- API routes → User management: routes users (evidence: `backend/src/routes/index.ts`)
- API routes → Academic controllers: routes academic services (evidence: `backend/src/routes/index.ts`)
- API routes → AI assistance: routes AI (evidence: `backend/src/routes/index.ts`)
- API routes → Marketplace lifecycle: routes marketplace (evidence: `backend/src/routes/index.ts`)
- API routes → Chat controller: routes chat (evidence: `backend/src/routes/index.ts`)
- Authentication → Prisma access: reads and writes (evidence: `backend/src/controllers/authController.ts`)
- User management → Prisma access: persists user data
- Academic controllers → Prisma access: persists academic data (evidence: `backend/src/controllers/authController.ts`)
- Academic controllers → Secure file storage: stores uploads (evidence: `backend/src/controllers/assignmentController.ts`)
- Academic controllers → Audit logging: records actions (evidence: `backend/src/controllers/authController.ts`)
- AI assistance → RAG knowledge service: retrieves knowledge (evidence: `backend/src/controllers/aiController.ts`)
- RAG knowledge service → Prisma access: enriches from records (evidence: `backend/src/services/ragService.ts`)
- Marketplace lifecycle → Prisma access: persists listings (evidence: `backend/src/controllers/marketplaceController.ts`)
- Marketplace lifecycle → Secure file storage: stores listing images (evidence: `backend/src/controllers/marketplaceController.ts`)
- Marketplace lifecycle → Audit logging: records actions (evidence: `backend/src/controllers/marketplaceController.ts`)
- Marketplace lifecycle → Realtime service: emits updates (evidence: `backend/src/controllers/marketplaceController.ts`)
- Chat controller → Realtime service: supports realtime chat
- Prisma access → SQLite database: database access (evidence: `README.md`)
- Realtime service → Prisma access: persists chat data (evidence: `backend/src/services/socket.ts`)
