# hafiz-shahzaib/fyp architecture

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

- Interactive diagram: https://gitdiagram.com/hafiz-shahzaib/fyp
- Repository: https://github.com/hafiz-shahzaib/fyp

## Overview

This is a web learning platform for students, educators, and administrators: users discover courses, enroll, view lectures, complete assignments, and interact through reviews and chat; educators and admins manage course content and users. The frontend routes role-oriented experiences, while an Express API dispatches requests to controllers and MongoDB models. The graph includes documented payment, AI search, and image-chat capabilities, but several frontend-to-API and unsampled service relationships are not evidenced in the excerpts, so they are not asserted as direct calls.

Main entry points: [`backend/index.js`](https://github.com/hafiz-shahzaib/fyp/blob/main/backend/index.js) (Express API and route mounts), [`frontend/src/App.jsx`](https://github.com/hafiz-shahzaib/fyp/blob/main/frontend/src/App.jsx) (Role-based web app), [`backend/controller/courseController.js`](https://github.com/hafiz-shahzaib/fyp/blob/main/backend/controller/courseController.js) (Course and lecture management), [`backend/controller/messageController.js`](https://github.com/hafiz-shahzaib/fyp/blob/main/backend/controller/messageController.js) (Text and image responses)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web application"]
  node_webapp["Role-based web app<br/>[App.jsx]"]
  node_course_views["Course and lecture views<br/>[ViewCourse.jsx]"]
  node_assignment_views["Assignment views<br/>[ViewAssignment.jsx]"]
  node_admin_views["Admin course and user tools<br/>[AdminCourses.jsx]"]
  node_search_view["AI course search<br/>[SearchWithAi.jsx]"]
  node_chat_views["Chat and community views<br/>[Chat.jsx]"]
end

subgraph group_identity["Identity and accounts"]
  node_auth_routes["Authentication routes<br/>[authRoute.js]"]
  node_auth_controller["Sign-in and account recovery<br/>[authController.js]"]
  node_user_store[("User records<br/>[userModel.js]")]
end

subgraph group_learning["Learning content"]
  node_course_routes["Course routes<br/>[courseRoute.js]"]
  node_course_controller["Course and lecture management"]
  node_course_store[("Course records<br/>[courseModel.js]")]
  node_lecture_store[("Lecture records<br/>[lectureModel.js]")]
  node_enrollment_routes["Enrollment routes<br/>[enrollRoute.js]"]
  node_payment_routes["Payment routes<br/>[paymentRoute.js]"]
  node_search_controller["Course search"]
end

subgraph group_assessment["Assignments"]
  node_assessment_store[("Assignment and submission records<br/>[assignmentModel.js]")]
end

subgraph group_community["Community features"]
  node_review_routes["Review routes<br/>[reviewRoute.js]"]
  node_review_controller["Review handling"]
  node_review_store[("Review records<br/>[reviewModel.js]")]
  node_chat_routes["Chat routes<br/>[chatRoute.js]"]
  node_message_routes["Message routes<br/>[messageRoute.js]"]
  node_message_controller["Text and image responses"]
  node_chat_store[("Chat records<br/>[chatModel.js]")]
  node_ai_service["OpenAI-compatible service<br/>[openai.js]"]
  node_image_service["ImageKit service<br/>[imagekit.js]"]
end

subgraph group_api["Backend API"]
  node_api_server["Express API and route mounts<br/>[index.js]"]
end

node_learner(("Learner"))
node_educator(("Educator"))
node_administrator(("Administrator"))

node_learner -->|"uses"| node_webapp
node_educator -->|"uses"| node_webapp
node_administrator -->|"uses"| node_webapp
node_webapp -->|"routes to"| node_course_views
node_webapp -->|"routes to"| node_assignment_views
node_webapp -->|"routes to"| node_admin_views
node_webapp -->|"routes to"| node_search_view
node_webapp -->|"routes to"| node_chat_views
node_api_server -->|"mounts"| node_auth_routes
node_api_server -->|"mounts"| node_course_routes
node_api_server -->|"mounts"| node_enrollment_routes
node_api_server -.->|"mounts"| node_payment_routes
node_api_server -->|"mounts"| node_review_routes
node_api_server -->|"mounts"| node_chat_routes
node_api_server -->|"mounts"| node_message_routes
node_auth_routes -->|"dispatches"| node_auth_controller
node_auth_controller -->|"reads and writes"| node_user_store
node_course_routes -->|"dispatches"| node_course_controller
node_course_controller -->|"reads and writes"| node_course_store
node_course_controller -->|"creates and updates"| node_lecture_store
node_course_controller -->|"manages assignments"| node_assessment_store
node_course_controller -->|"checks educator"| node_user_store
node_review_routes -->|"dispatches"| node_review_controller
node_review_controller -->|"checks course"| node_course_store
node_review_controller -->|"reads and writes"| node_review_store
node_message_routes -->|"dispatches"| node_message_controller
node_message_controller -->|"reads and writes"| node_chat_store
node_message_controller -->|"requests text reply"| node_ai_service
node_message_controller -->|"uploads image"| node_image_service
node_course_routes -->|"dispatches search"| node_search_controller
node_chat_routes -.->|"mounted by"| node_api_server

click node_webapp "https://github.com/hafiz-shahzaib/fyp/blob/main/frontend/src/App.jsx"
click node_course_views "https://github.com/hafiz-shahzaib/fyp/blob/main/frontend/src/pages/ViewCourse.jsx"
click node_assignment_views "https://github.com/hafiz-shahzaib/fyp/blob/main/frontend/src/pages/Assignment/ViewAssignment.jsx"
click node_admin_views "https://github.com/hafiz-shahzaib/fyp/blob/main/frontend/src/pages/Admin/AdminCourses.jsx"
click node_search_view "https://github.com/hafiz-shahzaib/fyp/blob/main/frontend/src/pages/SearchWithAi.jsx"
click node_chat_views "https://github.com/hafiz-shahzaib/fyp/blob/main/frontend/src/pages/Chat/Chat.jsx"
click node_auth_routes "https://github.com/hafiz-shahzaib/fyp/blob/main/backend/route/authRoute.js"
click node_auth_controller "https://github.com/hafiz-shahzaib/fyp/blob/main/backend/controller/authController.js"
click node_user_store "https://github.com/hafiz-shahzaib/fyp/blob/main/backend/model/userModel.js"
click node_course_routes "https://github.com/hafiz-shahzaib/fyp/blob/main/backend/route/courseRoute.js"
click node_course_controller "https://github.com/hafiz-shahzaib/fyp/blob/main/backend/controller/courseController.js"
click node_course_store "https://github.com/hafiz-shahzaib/fyp/blob/main/backend/model/courseModel.js"
click node_lecture_store "https://github.com/hafiz-shahzaib/fyp/blob/main/backend/model/lectureModel.js"
click node_enrollment_routes "https://github.com/hafiz-shahzaib/fyp/blob/main/backend/route/enrollRoute.js"
click node_payment_routes "https://github.com/hafiz-shahzaib/fyp/blob/main/backend/route/paymentRoute.js"
click node_assessment_store "https://github.com/hafiz-shahzaib/fyp/blob/main/backend/model/assignmentModel.js"
click node_review_routes "https://github.com/hafiz-shahzaib/fyp/blob/main/backend/route/reviewRoute.js"
click node_review_controller "https://github.com/hafiz-shahzaib/fyp/blob/main/backend/controller/reviewController.js"
click node_review_store "https://github.com/hafiz-shahzaib/fyp/blob/main/backend/model/reviewModel.js"
click node_chat_routes "https://github.com/hafiz-shahzaib/fyp/blob/main/backend/route/chatRoute.js"
click node_message_routes "https://github.com/hafiz-shahzaib/fyp/blob/main/backend/route/messageRoute.js"
click node_message_controller "https://github.com/hafiz-shahzaib/fyp/blob/main/backend/controller/messageController.js"
click node_chat_store "https://github.com/hafiz-shahzaib/fyp/blob/main/backend/model/chatModel.js"
click node_api_server "https://github.com/hafiz-shahzaib/fyp/blob/main/backend/index.js"
click node_search_controller "https://github.com/hafiz-shahzaib/fyp/blob/main/backend/controller/searchController.js"
click node_ai_service "https://github.com/hafiz-shahzaib/fyp/blob/main/backend/config/openai.js"
click node_image_service "https://github.com/hafiz-shahzaib/fyp/blob/main/backend/config/imagekit.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_webapp,node_course_views,node_assignment_views,node_admin_views,node_search_view,node_chat_views toneBlue
class node_auth_routes,node_auth_controller,node_user_store toneAmber
class node_course_routes,node_course_controller,node_course_store,node_lecture_store,node_enrollment_routes,node_payment_routes,node_search_controller toneMint
class node_assessment_store toneRose
class node_review_routes,node_review_controller,node_review_store,node_chat_routes,node_message_routes,node_message_controller,node_chat_store,node_ai_service,node_image_service,node_learner,node_educator,node_administrator toneIndigo
class node_api_server toneTeal
```

## Components

### Web application

- [Role-based web app](https://github.com/hafiz-shahzaib/fyp/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Course and lecture views](https://github.com/hafiz-shahzaib/fyp/blob/main/frontend/src/pages/ViewCourse.jsx): `frontend/src/pages/ViewCourse.jsx`
- [Assignment views](https://github.com/hafiz-shahzaib/fyp/blob/main/frontend/src/pages/Assignment/ViewAssignment.jsx): `frontend/src/pages/Assignment/ViewAssignment.jsx`
- [Admin course and user tools](https://github.com/hafiz-shahzaib/fyp/blob/main/frontend/src/pages/Admin/AdminCourses.jsx): `frontend/src/pages/Admin/AdminCourses.jsx`
- [AI course search](https://github.com/hafiz-shahzaib/fyp/blob/main/frontend/src/pages/SearchWithAi.jsx): `frontend/src/pages/SearchWithAi.jsx`
- [Chat and community views](https://github.com/hafiz-shahzaib/fyp/blob/main/frontend/src/pages/Chat/Chat.jsx): `frontend/src/pages/Chat/Chat.jsx`

### Identity and accounts

- [Authentication routes](https://github.com/hafiz-shahzaib/fyp/blob/main/backend/route/authRoute.js): `backend/route/authRoute.js`
- [Sign-in and account recovery](https://github.com/hafiz-shahzaib/fyp/blob/main/backend/controller/authController.js): `backend/controller/authController.js`
- [User records](https://github.com/hafiz-shahzaib/fyp/blob/main/backend/model/userModel.js): `backend/model/userModel.js`

### Learning content

- [Course routes](https://github.com/hafiz-shahzaib/fyp/blob/main/backend/route/courseRoute.js): `backend/route/courseRoute.js`
- [Course and lecture management](https://github.com/hafiz-shahzaib/fyp/blob/main/backend/controller/courseController.js): `backend/controller/courseController.js`
- [Course records](https://github.com/hafiz-shahzaib/fyp/blob/main/backend/model/courseModel.js): `backend/model/courseModel.js`
- [Lecture records](https://github.com/hafiz-shahzaib/fyp/blob/main/backend/model/lectureModel.js): `backend/model/lectureModel.js`
- [Enrollment routes](https://github.com/hafiz-shahzaib/fyp/blob/main/backend/route/enrollRoute.js): `backend/route/enrollRoute.js`
- [Payment routes](https://github.com/hafiz-shahzaib/fyp/blob/main/backend/route/paymentRoute.js): `backend/route/paymentRoute.js`
- [Course search](https://github.com/hafiz-shahzaib/fyp/blob/main/backend/controller/searchController.js): `backend/controller/searchController.js`

### Assignments

- [Assignment and submission records](https://github.com/hafiz-shahzaib/fyp/blob/main/backend/model/assignmentModel.js): `backend/model/assignmentModel.js`

### Community features

- [Review routes](https://github.com/hafiz-shahzaib/fyp/blob/main/backend/route/reviewRoute.js): `backend/route/reviewRoute.js`
- [Review handling](https://github.com/hafiz-shahzaib/fyp/blob/main/backend/controller/reviewController.js): `backend/controller/reviewController.js`
- [Review records](https://github.com/hafiz-shahzaib/fyp/blob/main/backend/model/reviewModel.js): `backend/model/reviewModel.js`
- [Chat routes](https://github.com/hafiz-shahzaib/fyp/blob/main/backend/route/chatRoute.js): `backend/route/chatRoute.js`
- [Message routes](https://github.com/hafiz-shahzaib/fyp/blob/main/backend/route/messageRoute.js): `backend/route/messageRoute.js`
- [Text and image responses](https://github.com/hafiz-shahzaib/fyp/blob/main/backend/controller/messageController.js): `backend/controller/messageController.js`
- [Chat records](https://github.com/hafiz-shahzaib/fyp/blob/main/backend/model/chatModel.js): `backend/model/chatModel.js`
- [OpenAI-compatible service](https://github.com/hafiz-shahzaib/fyp/blob/main/backend/config/openai.js): `backend/config/openai.js`
- [ImageKit service](https://github.com/hafiz-shahzaib/fyp/blob/main/backend/config/imagekit.js): `backend/config/imagekit.js`

### Backend API

- [Express API and route mounts](https://github.com/hafiz-shahzaib/fyp/blob/main/backend/index.js): `backend/index.js`

### Other components

- **Learner**
- **Educator**
- **Administrator**

## Connections

- Learner → Role-based web app: uses (evidence: `frontend/src/App.jsx`)
- Educator → Role-based web app: uses (evidence: `frontend/src/App.jsx`)
- Administrator → Role-based web app: uses (evidence: `frontend/src/App.jsx`)
- Role-based web app → Course and lecture views: routes to (evidence: `frontend/src/App.jsx`)
- Role-based web app → Assignment views: routes to (evidence: `frontend/src/App.jsx`)
- Role-based web app → Admin course and user tools: routes to (evidence: `frontend/src/App.jsx`)
- Role-based web app → AI course search: routes to (evidence: `frontend/src/App.jsx`)
- Role-based web app → Chat and community views: routes to (evidence: `frontend/src/App.jsx`)
- Express API and route mounts → Authentication routes: mounts (evidence: `backend/index.js`)
- Express API and route mounts → Course routes: mounts (evidence: `backend/index.js`)
- Express API and route mounts → Enrollment routes: mounts (evidence: `backend/index.js`)
- Express API and route mounts → Payment routes: mounts (evidence: `backend/index.js`)
- Express API and route mounts → Review routes: mounts (evidence: `backend/index.js`)
- Express API and route mounts → Chat routes: mounts (evidence: `backend/index.js`)
- Express API and route mounts → Message routes: mounts (evidence: `backend/index.js`)
- Authentication routes → Sign-in and account recovery: dispatches (evidence: `backend/route/authRoute.js`)
- Sign-in and account recovery → User records: reads and writes (evidence: `backend/controller/authController.js`)
- Course routes → Course and lecture management: dispatches (evidence: `backend/route/courseRoute.js`)
- Course and lecture management → Course records: reads and writes (evidence: `backend/controller/courseController.js`)
- Course and lecture management → Lecture records: creates and updates (evidence: `backend/controller/courseController.js`)
- Course and lecture management → Assignment and submission records: manages assignments (evidence: `backend/controller/courseController.js`)
- Course and lecture management → User records: checks educator (evidence: `backend/controller/courseController.js`)
- Review routes → Review handling: dispatches (evidence: `backend/route/reviewRoute.js`)
- Review handling → Course records: checks course (evidence: `backend/controller/reviewController.js`)
- Review handling → Review records: reads and writes (evidence: `backend/controller/reviewController.js`)
- Message routes → Text and image responses: dispatches (evidence: `backend/route/messageRoute.js`)
- Text and image responses → Chat records: reads and writes (evidence: `backend/controller/messageController.js`)
- Text and image responses → OpenAI-compatible service: requests text reply (evidence: `backend/controller/messageController.js`)
- Text and image responses → ImageKit service: uploads image (evidence: `backend/controller/messageController.js`)
- Course routes → Course search: dispatches search (evidence: `backend/route/courseRoute.js`)
- Chat routes → Express API and route mounts: mounted by (evidence: `backend/index.js`)
