# ankit6098/lectureshedulingbackend architecture

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

- Interactive diagram: https://gitdiagram.com/ankit6098/lectureshedulingbackend
- Repository: https://github.com/ankit6098/lectureshedulingbackend

## Overview

##### Project type and purpose
- This is a backend REST API built with Node.js and Express, using MongoDB (via Mongoose) for persistence.
- It provides administrative endpoints for managing “courses,” “lectures,” and “instructor assignments” in an educational scheduling context.

##### File structure
Top-level directories and files:
- config/
– environment.js (loads .env vars, e.g. mongoUrl)
– mongoose.js (connects to MongoDB)
- controllers/
– admin_Controller.js
– assignLecture_Controller.js
– course_Controller.js
– lecture_controller.js
– user_Controller.js
- models/
– AssignLecture.js
– Course.js
– Lecture.js
– User.js
- routes/
– admin.js
– index.js (root router)
- index.js (app entry point)
- package.json / .gitignore

Pattern:
– MVC-style separation:
Models → Mongoose schemas
Controllers → business logic and CRUD operations
Routes → HTTP endpoint definitions
– A single monolithic service exposing RESTful endpoints

##### README for additional insights
- Describes API endpoints for course/lecture management
- Requires a secure login feature (likely in user_Controller/admin_Controller)
- Hosted on Render at https://lectureshedulingbackend.onrender.com/

##### Detailed breakdown of components
- Config Layer:
– Load .env (mongoUrl)
– Initialize Mongoose connection
- Web Server: index.js
– Middleware (bodyParser, auth checks)
– Mount routers from routes/index.js
- Routing Layer: routes/index.js
– /api/admin → routes/admin.js
– /courses, /lectures, /users, /assignments → respective controllers
- Controller Layer:
– Methods: createCourse(), getAllLectures(), assignLectureToInstructor(), etc.
- Model Layer:
– Schemas: Course { title, description, … }, Lecture { date, topic, … }, AssignLecture { lectureId, userId }, User { name, role, passwordHash }
- Database: MongoDB cluster

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client
    Client["Client (Admin UI/Postman)"]:::client

    %% Configuration Layer
    subgraph "Configuration Layer"
        direction TB
        Env["environment.js"]:::config
        MongooseConfig["mongoose.js"]:::config
    end

    %% Server Entry Point
    Server["index.js"]:::server

    %% Router Layer
    subgraph "Router Layer"
        direction TB
        RouterRoot["routes/index.js"]:::router
        RouterAdmin["routes/admin.js"]:::router
    end

    %% Controller Layer
    subgraph "Controller Layer"
        direction TB
        AdminCtl["admin_Controller.js"]:::controller
        AssignCtl["assignLecture_Controller.js"]:::controller
        CourseCtl["course_Controller.js"]:::controller
        LectureCtl["lecture_controller.js"]:::controller
        UserCtl["user_Controller.js"]:::controller
    end

    %% Model Layer
    subgraph "Model Layer"
        direction TB
        AssignModel["AssignLecture.js"]:::model
        CourseModel["Course.js"]:::model
        LectureModel["Lecture.js"]:::model
        UserModel["User.js"]:::model
    end

    %% Database
    DB["MongoDB Database"]:::database

    %% Connections
    Client -->|"HTTP Request"| RouterRoot
    RouterRoot --> RouterAdmin
    RouterRoot --> AdminCtl
    RouterRoot --> AssignCtl
    RouterRoot --> CourseCtl
    RouterRoot --> LectureCtl
    RouterRoot --> UserCtl

    RouterAdmin --> AdminCtl

    AdminCtl --> UserModel
    AssignCtl --> AssignModel
    CourseCtl --> CourseModel
    LectureCtl --> LectureModel
    UserCtl --> UserModel

    AssignModel --> DB
    CourseModel --> DB
    LectureModel --> DB
    UserModel --> DB

    Env --> Server
    MongooseConfig --> Server
    MongooseConfig --> DB
    Server --> RouterRoot

    %% Click Events
    click Env "https://github.com/ankit6098/lectureshedulingbackend/blob/master/config/environment.js"
    click MongooseConfig "https://github.com/ankit6098/lectureshedulingbackend/blob/master/config/mongoose.js"
    click Server "https://github.com/ankit6098/lectureshedulingbackend/blob/master/index.js"
    click RouterRoot "https://github.com/ankit6098/lectureshedulingbackend/blob/master/routes/index.js"
    click RouterAdmin "https://github.com/ankit6098/lectureshedulingbackend/blob/master/routes/admin.js"
    click AdminCtl "https://github.com/ankit6098/lectureshedulingbackend/blob/master/controllers/admin_Controller.js"
    click AssignCtl "https://github.com/ankit6098/lectureshedulingbackend/blob/master/controllers/assignLecture_Controller.js"
    click CourseCtl "https://github.com/ankit6098/lectureshedulingbackend/blob/master/controllers/course_Controller.js"
    click LectureCtl "https://github.com/ankit6098/lectureshedulingbackend/blob/master/controllers/lecture_controller.js"
    click UserCtl "https://github.com/ankit6098/lectureshedulingbackend/blob/master/controllers/user_Controller.js"
    click AssignModel "https://github.com/ankit6098/lectureshedulingbackend/blob/master/models/AssignLecture.js"
    click CourseModel "https://github.com/ankit6098/lectureshedulingbackend/blob/master/models/Course.js"
    click LectureModel "https://github.com/ankit6098/lectureshedulingbackend/blob/master/models/Lecture.js"
    click UserModel "https://github.com/ankit6098/lectureshedulingbackend/blob/master/models/User.js"

    %% Styles
    classDef config fill:#cccccc,stroke:#333333,color:#000000
    classDef server fill:#cce5ff,stroke:#2a7fdb,color:#000000
    classDef router fill:#99d6ff,stroke:#1a8cff,color:#000000
    classDef controller fill:#c3f0c3,stroke:#28a428,color:#000000
    classDef model fill:#ffe5b4,stroke:#d79b00,color:#000000
    classDef database fill:#ffcccb,stroke:#d21f3c,color:#000000
    classDef client fill:#f2d0a4,stroke:#c47d00,color:#000000
```
