# s4tvik/attendance-management-system architecture

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

- Interactive diagram: https://gitdiagram.com/s4tvik/attendance-management-system
- Repository: https://github.com/s4tvik/attendance-management-system

## Overview

##### Project type and purpose
- This is a full-stack web application (“Attendance-Management-System”) for educational institutions to track student attendance.
- Frontend: static assets and EJS templates for login, teacher pages, student pages, error pages.
- Backend: Node.js/Express (app.js, server.js) serving routes, rendering views, handling form submissions.
- Database: MongoDB (or JSON files in `db/`) storing collections: attendance, login, student, teacher.

##### File structure
├─ server.js / app.js
│   • Express server setup, route definitions, middleware.
├─ *.ejs (calendar.ejs, student_home.ejs, teacher_home.ejs, teacher_class.ejs, teacher_form.ejs, etc.)
│   • View templates rendered on server side.
├─ public/
│   ├ css/ (Bootstrap5-based styles)
│   ├ js/ (app logic, Particle.js)
│   └ images/ (static assets)
├─ db/
│   └ *.json (mock data or seed files for MongoDB collections)
├─ login.html, login1.html, 404notfound.html, notloggedin.html
│   • Static fallback or initial pages
└─ node_modules, package.json, package-lock.json
- Dependencies: Express, MongoDB driver or ODM, Bootstrap5, Particle.js

##### Key insights from README
- Two user roles: Teacher and Student, each with dedicated views and workflows.
- Core pages: login, teacher-home, teacher-class (attendance marking), student-home (attendance viewing), error/404.
- Tech stack: Node.js/Express, EJS, Bootstrap5, Particle.js, MongoDB.

a. Client browser
- User interface: HTML/EJS pages + CSS (Bootstrap5 + custom) + JS (app_1.js + Particle.js).
- User roles: Teacher UI vs Student UI.
b. Web server
- Node.js/Express application (`server.js`, `app.js`).
- Route handlers/controllers for login, attendance operations, data retrieval.
c. Database
- MongoDB instance (or JSON files simulating collections).
- Collections: users (teacher/student), attendance records, login sessions.
d. External services
- Particle.js CDN (or local) for UI effects.
- (Optional) Authentication middleware or session store if any.

##### Relationships and data flow
- Browser → HTTP(S) → Express routes (POST /login, GET /teacher/home, POST /teacher/attendance, GET /student/home).
- Express → Database driver → MongoDB (CRUD operations on collections).
- Express ← Rendered EJS views + JSON data sent back to client.
- Static asset requests routed to `public/` folder.

##### Architectural patterns and design principles
- MVC-like separation:
- Model = MongoDB collections (`db/*.json` or actual DB).
- View = EJS templates + static HTML.
- Controller = Express route handlers in `server.js`/`app.js`.
- Single Express monolith (no microservices); simple layered architecture.
- Client-server separation: browser UI vs server logic.
- Secure routes (login gating teacher/student pages).

3. Inside Server, show modules: Routing, Controllers, Middleware.
4. Inside Database, list collections.
- Client → Server (HTTP)
- Server → Database (CRUD)
- Server → Client (Rendered HTML/JSON)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Layers
    subgraph "Client Layer" 
        direction TB
        subgraph "Views (EJS Templates)" 
            calendar["calendar.ejs"]:::frontend
            studentHome["student_home.ejs"]:::frontend
            teacherHome["teacher_home.ejs"]:::frontend
            teacherClass["teacher_class.ejs"]:::frontend
            teacherClass2["teacher_class2.ejs"]:::frontend
            teacherForm["teacher_form.ejs"]:::frontend
            teacherForm2["teacher_form2.ejs"]:::frontend
        end
        subgraph "Static HTML Pages"
            loginPage["login.html"]:::frontend
            loginPage1["login1.html"]:::frontend
            notFound["404notfound.html"]:::frontend
            notLoggedIn["notloggedin.html"]:::frontend
        end
        subgraph "Assets"
            subgraph "CSS" 
                css1["loginstyle.css"]:::frontend
                css2["loginstyle1.css"]:::frontend
            end
            subgraph "JS & Effects"
                appJs["app_1.js"]:::frontend
                particles["particles.js"]:::external
                particlesConfig["particlesjs-config_2.json"]:::external
            end
        end
    end

    subgraph "Server Layer" 
        direction TB
        serverJs["server.js"]:::backend
        appJsServer["app.js"]:::backend
        pkg["package.json"]:::backend
        pkgLock["package-lock.json"]:::backend
        subgraph "Express Components"
            Router["Routing Layer"]:::backend
            Controllers["Controller Logic"]:::backend
            Auth["Authentication Middleware"]:::backend
        end
    end

    subgraph "Data Layer"
        direction TB
        DB[(MongoDB / JSON files)]:::database
        attendance["attendance.json"]:::database
        loginDb["login.json"]:::database
        studentDb["student.json"]:::database
        teacherDb["teacher.json"]:::database
    end

    %% Connections Client to Server
    loginPage -->|"GET /login"| serverJs
    loginPage1 -->|"GET /login"| serverJs
    notLoggedIn -->|redirect| serverJs
    calendar -->|"GET /student/home"| appJsServer
    studentHome -->|"GET /student/home"| appJsServer
    teacherHome -->|"GET /teacher/home"| appJsServer
    teacherClass -->|"GET /teacher/class"| appJsServer
    teacherClass2 -->|"GET /teacher/class2"| appJsServer
    teacherForm -->|"POST /teacher/attendance"| appJsServer
    teacherForm2 -->|"POST /teacher/attendance2"| appJsServer
    css1 --> serverJs
    css2 --> serverJs
    appJs --> serverJs
    particles --> serverJs
    particlesConfig --> serverJs

    %% Server internals
    serverJs --> appJsServer
    appJsServer --> Router
    Router --> Controllers
    Controllers --> Auth

    %% Server to DB
    Controllers -->|"find()"| DB
    Controllers -->|"insertOne(), updateOne()"| DB

    %% DB files
    DB --> attendance
    DB --> loginDb
    DB --> studentDb
    DB --> teacherDb

    %% Return responses
    Controllers -->|"render(view)"| Router
    Router -->|"HTML/EJS"| loginPage
    Router -->|"HTML/EJS"| studentHome
    Router -->|"HTML/EJS"| teacherHome

    %% Legend
    subgraph Legend
        direction TB
        F[Frontend Layer]:::frontend
        B[Backend Layer]:::backend
        D[Database Layer]:::database
        E[External Libraries]:::external
    end

    %% Click Events
    click serverJs "https://github.com/s4tvik/attendance-management-system/blob/main/server.js"
    click appJsServer "https://github.com/s4tvik/attendance-management-system/blob/main/app.js"
    click calendar "https://github.com/s4tvik/attendance-management-system/blob/main/calendar.ejs"
    click studentHome "https://github.com/s4tvik/attendance-management-system/blob/main/student_home.ejs"
    click teacherHome "https://github.com/s4tvik/attendance-management-system/blob/main/teacher_home.ejs"
    click teacherClass "https://github.com/s4tvik/attendance-management-system/blob/main/teacher_class.ejs"
    click teacherClass2 "https://github.com/s4tvik/attendance-management-system/blob/main/teacher_class2.ejs"
    click teacherForm "https://github.com/s4tvik/attendance-management-system/blob/main/teacher_form.ejs"
    click teacherForm2 "https://github.com/s4tvik/attendance-management-system/blob/main/teacher_form2.ejs"
    click loginPage "https://github.com/s4tvik/attendance-management-system/blob/main/login.html"
    click loginPage1 "https://github.com/s4tvik/attendance-management-system/blob/main/login1.html"
    click notFound "https://github.com/s4tvik/attendance-management-system/blob/main/404notfound.html"
    click notLoggedIn "https://github.com/s4tvik/attendance-management-system/blob/main/notloggedin.html"
    click css1 "https://github.com/s4tvik/attendance-management-system/blob/main/public/css/loginstyle.css"
    click css2 "https://github.com/s4tvik/attendance-management-system/blob/main/public/css/loginstyle1.css"
    click appJs "https://github.com/s4tvik/attendance-management-system/blob/main/public/js/app_1.js"
    click particles "https://github.com/s4tvik/attendance-management-system/blob/main/public/js/particles.js"
    click particlesConfig "https://github.com/s4tvik/attendance-management-system/blob/main/public/js/particlesjs-config_2.json"
    click attendance "https://github.com/s4tvik/attendance-management-system/blob/main/db/attendance.json"
    click loginDb "https://github.com/s4tvik/attendance-management-system/blob/main/db/login.json"
    click studentDb "https://github.com/s4tvik/attendance-management-system/blob/main/db/student.json"
    click teacherDb "https://github.com/s4tvik/attendance-management-system/blob/main/db/teacher.json"
    click pkg "https://github.com/s4tvik/attendance-management-system/blob/main/package.json"
    click pkgLock "https://github.com/s4tvik/attendance-management-system/blob/main/package-lock.json"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#005B96,stroke-width:1px;
    classDef backend fill:#DFFFE0,stroke:#2E7D32,stroke-width:1px;
    classDef database fill:#FFE8CC,stroke:#E65100,stroke-width:1px,shape:cylinder;
    classDef external fill:#F0F0F0,stroke:#888,stroke-dasharray: 5 5,stroke-width:1px;
```
