# nguyenhongsac/college-appointment-system architecture

> Architecture diagram of the GitHub repository nguyenhongsac/college-appointment-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nguyenhongsac/college-appointment-system
- Repository: https://github.com/nguyenhongsac/college-appointment-system

## Overview

##### Project type and purpose
- This is a backend-only REST API (“college-appointment-system”) built with Node.js and Express.
- Its primary purpose is to manage user authentication (students and faculty), appointment booking, and availability slots.

##### File structure
- Top-level:
- server.js – application entry point
- package.json / .env – dependency and configuration management
- src/ – main source folder
- Under src/:
- app.js – Express application setup (middleware, routes hooking)
- config/db.js – database connection logic
- controllers/ – business logic for each resource (auth, appointments, availability)
- models/ – data models (User, Appointment, AvailabilitySlot) likely implemented with an ORM/ODM
- routes/ – HTTP route definitions mapping URL paths to controller methods
- middleware/authMiddleware.js – JWT validation and route protection
- tests/ – automated tests for application behavior

##### README for additional insights
- Dependencies: express, bcryptjs (password hashing), jsonwebtoken (JWT auth), dotenv (environment variables).
- No front-end or microservices present—architecture is a single API service.

##### Detail
- How server.js invokes app.js and config/db.js.
- Middleware insertion points.
- Don’t over-abstract: include all three controllers, their routes, and the data flow to/from the DB.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Client["Client (Web/Mobile)"]:::external
    server["server.js"]:::logic
    app["app.js"]:::logic
    dbConfig["config/db.js"]:::logic
    authRoutes["Auth Routes"]:::logic
    appointmentRoutes["Appointment Routes"]:::logic
    availabilityRoutes["Availability Slot Routes"]:::logic
    authMiddleware["authMiddleware"]:::logic
    authController["Auth Controller"]:::logic
    appointmentController["Appointment Controller"]:::logic
    availabilityController["Availability Slot Controller"]:::logic
    UserModel["User Model"]:::data
    AppointmentModel["Appointment Model"]:::data
    AvailabilityModel["Availability Slot Model"]:::data
    DB["Database"]:::data
    appTest["app.test.js"]:::logic
    testConfig["test.config.js"]:::logic

    Client -->|HTTP| server
    server -->|start| app
    app -->|loads| dbConfig
    app -->|use| authRoutes
    app -->|use| appointmentRoutes
    app -->|use| availabilityRoutes

    authRoutes -->|protected by| authMiddleware
    authRoutes -->|invoke| authController

    appointmentRoutes -->|protected by| authMiddleware
    appointmentRoutes -->|invoke| appointmentController

    availabilityRoutes -->|protected by| authMiddleware
    availabilityRoutes -->|invoke| availabilityController

    authController -->|uses| UserModel
    appointmentController -->|uses| AppointmentModel
    availabilityController -->|uses| AvailabilityModel

    UserModel -->|DB query| DB
    AppointmentModel -->|DB query| DB
    AvailabilityModel -->|DB query| DB
    dbConfig -->|connect| DB

    app -->|run tests| appTest
    app -->|run tests| testConfig

    click server "https://github.com/nguyenhongsac/college-appointment-system/blob/main/server.js"
    click app "https://github.com/nguyenhongsac/college-appointment-system/blob/main/src/app.js"
    click dbConfig "https://github.com/nguyenhongsac/college-appointment-system/blob/main/src/config/db.js"
    click authMiddleware "https://github.com/nguyenhongsac/college-appointment-system/blob/main/src/middleware/authMiddleware.js"
    click authController "https://github.com/nguyenhongsac/college-appointment-system/blob/main/src/controllers/authController.js"
    click appointmentController "https://github.com/nguyenhongsac/college-appointment-system/blob/main/src/controllers/appointmentController.js"
    click availabilityController "https://github.com/nguyenhongsac/college-appointment-system/blob/main/src/controllers/availabilitySlotController.js"
    click UserModel "https://github.com/nguyenhongsac/college-appointment-system/blob/main/src/models/user.js"
    click AppointmentModel "https://github.com/nguyenhongsac/college-appointment-system/blob/main/src/models/appointment.js"
    click AvailabilityModel "https://github.com/nguyenhongsac/college-appointment-system/blob/main/src/models/availabilitySlot.js"
    click authRoutes "https://github.com/nguyenhongsac/college-appointment-system/blob/main/src/routes/authRoutes.js"
    click appointmentRoutes "https://github.com/nguyenhongsac/college-appointment-system/blob/main/src/routes/appointmentRoutes.js"
    click availabilityRoutes "https://github.com/nguyenhongsac/college-appointment-system/blob/main/src/routes/availabilitySlotRoutes.js"
    click appTest "https://github.com/nguyenhongsac/college-appointment-system/blob/main/tests/app.test.js"
    click testConfig "https://github.com/nguyenhongsac/college-appointment-system/blob/main/tests/test.config.js"

    classDef external fill:#b3d9ff,stroke:#0066cc
    classDef logic fill:#ccffcc,stroke:#339933
    classDef data fill:#ffdb99,stroke:#cc6600
```
