# amitdev25/sih2024 architecture

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

- Interactive diagram: https://gitdiagram.com/amitdev25/sih2024
- Repository: https://github.com/amitdev25/sih2024

## Overview

##### Project type and purpose
- From the file tree and minimal README (“# SIH2024”), this is a server-side rendered full-stack web application built on Node.js and Express.
- It follows an MVC-style pattern:
- models/ holds data schemas (e.g., user.model.js)
- routes/ contains route handlers (controllers)
- views/ contains EJS templates (UI)
- There’s also a small Python script (webcam.py), suggesting integration with a webcam or image-processing component.

##### File structure
- app.js: Express app entry point
- package.json / nodemon.json: Node.js configuration and startup scripts
- models/: Data layer (user.model.js, likely MongoDB via Mongoose)
- routes/: Controller layer, partitioned by feature (admin, auth, guide, user, index)
- utils/: Helper modules (constants.js, passport.auth.js for authentication strategy)
- public/: Static assets (CSS, client-side JS if any)
- views/: EJS templates organized by page and layouts (header, footer, navbar, flash messages)
- webcam.py: A Python module—probably run separately or invoked by the Node app for webcam capture/processing

##### Key insights from the README
- No additional architecture doc, so infer tech stack from file names: Node.js, Express, EJS, Passport.js, possibly MongoDB.

##### Main components
a. Client (Browser)
b. Web Server (Node.js/Express)
c. Authentication layer (Passport.js strategies in utils/passport.auth.js)
d. Data Store (e.g., MongoDB)
e. Static Asset Server (serving public/)
f. Template Renderer (EJS views)
g. Webcam Module (Python script)

##### Relationships and interactions
- Browser ↔ Express HTTP routes (routes/*.route.js)
- Express → models (CRUD operations) → Database
- Express ↔ Passport.js for login/session management
- Express → EJS engine → rendered HTML pages
- Browser → public/style.css for styling
- Express ↔ Python script (webcam.py) via child_process or HTTP API (if applicable)

##### Architectural patterns and design principles
- MVC pattern: models, views, controllers (routes) are clearly separated
- Modularization: utils folder holds reusable components (constants, auth strategies)
- Template-based rendering for SEO and quick server-side pages
- Single codebase with one runtime (Node.js) plus an auxiliary Python module

##### Technologies, frameworks, and libraries
- Node.js, Express.js
- EJS templating
- Passport.js for authentication
- Mongoose or native MongoDB driver (inferred from models/)
- Nodemon for live reload
- Python 3 for webcam.py

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client
    Browser["Browser"]:::client
    Browser -->|"HTTP"| Express

    %% Server
    subgraph "Server"
        Express["Express App (app.js)"]:::server

        subgraph "Controllers (routes)"
            AdminRoutes["AdminRoutes Controller"]:::controller
            AuthRoutes["Authentication Routes Controller"]:::controller
            GuideRoutes["Guide Routes Controller"]:::controller
            IndexRoutes["Index Routes Controller"]:::controller
            UserRoutes["User Routes Controller"]:::controller
        end

        subgraph "Models"
            UserModel["User Data Model"]:::model
        end

        subgraph "Utils"
            Passport["Passport.js Strategies"]:::auth
            Constants["Application Constants"]:::config
        end

        subgraph "Views"
            subgraph "Layouts"
                Header["header.ejs"]:::view
                Navbar["navbar.ejs"]:::view
                FlashMsg["flash-message.ejs"]:::view
                Footer["footer.ejs"]:::view
            end
            subgraph "Pages"
                IndexView["index.ejs"]:::view
                LoginView["login.ejs"]:::view
                RegisterView["register.ejs"]:::view
                ProfileView["profile.ejs"]:::view
                ManageUsersView["manage-users.ejs"]:::view
                ErrorView["error_40x.ejs"]:::view
            end
        end

        subgraph "Static Assets"
            StyleCSS["style.css"]:::static
        end

        subgraph "Configuration"
            Env[".env"]:::config
            PackageJSON["package.json"]:::config
            NodemonJSON["nodemon.json"]:::config
            README["README.md"]:::config
            Lock["package-lock.json"]:::config
        end

        Express --> Controllers
        Controllers --> Models
        Models -->|"DB Query"| MongoDB

        Express --> Passport
        Express --> Constants

        Express --> Views
        Views -->|"HTML"| Browser

        Browser -->|"GET CSS"| StyleCSS
        Express --> StyleCSS

        Express -->|"spawn/process"| Webcam
        Webcam -->|"image data"| Express
    end

    %% Database
    MongoDB["MongoDB Database"]:::db

    %% Python Module
    Webcam["Webcam Module (webcam.py)"]:::python

    %% Class Definitions
    classDef client fill:#AED6F1,stroke:#3498DB,color:#1B4F72;
    classDef server fill:#ABEBC6,stroke:#229954,color:#1D8348;
    classDef controller fill:#F9E79F,stroke:#B7950B,color:#7D6608;
    classDef model fill:#F5CBA7,stroke:#BA4A00,color:#641E16;
    classDef db fill:#F5B7B1,stroke:#C0392B,color:#78281F;
    classDef auth fill:#D2B4DE,stroke:#76448A,color:#4A235A;
    classDef static fill:#D5D8DC,stroke:#7B7D7D,color:#2E4053;
    classDef view fill:#A9CCE3,stroke:#2E86C1,color:#1B2631;
    classDef config fill:#E5E7E9,stroke:#6E2C00,color:#17202A;
    classDef python fill:#F1948A,stroke:#922B21,color:#641E16;

    %% Click Events
    click Express "https://github.com/amitdev25/sih2024/blob/main/app.js"
    click UserModel "https://github.com/amitdev25/sih2024/blob/main/models/user.model.js"
    click AdminRoutes "https://github.com/amitdev25/sih2024/blob/main/routes/admin.route.js"
    click AuthRoutes "https://github.com/amitdev25/sih2024/blob/main/routes/auth.route.js"
    click GuideRoutes "https://github.com/amitdev25/sih2024/blob/main/routes/guide.route.js"
    click IndexRoutes "https://github.com/amitdev25/sih2024/blob/main/routes/index.route.js"
    click UserRoutes "https://github.com/amitdev25/sih2024/blob/main/routes/user.route.js"
    click Passport "https://github.com/amitdev25/sih2024/blob/main/utils/passport.auth.js"
    click Constants "https://github.com/amitdev25/sih2024/blob/main/utils/constants.js"
    click StyleCSS "https://github.com/amitdev25/sih2024/blob/main/public/style.css"
    click Header "https://github.com/amitdev25/sih2024/blob/main/views/layouts/header.ejs"
    click Navbar "https://github.com/amitdev25/sih2024/blob/main/views/layouts/navbar.ejs"
    click FlashMsg "https://github.com/amitdev25/sih2024/blob/main/views/layouts/flash-message.ejs"
    click Footer "https://github.com/amitdev25/sih2024/blob/main/views/layouts/footer.ejs"
    click IndexView "https://github.com/amitdev25/sih2024/blob/main/views/index.ejs"
    click LoginView "https://github.com/amitdev25/sih2024/blob/main/views/login.ejs"
    click RegisterView "https://github.com/amitdev25/sih2024/blob/main/views/register.ejs"
    click ProfileView "https://github.com/amitdev25/sih2024/blob/main/views/profile.ejs"
    click ManageUsersView "https://github.com/amitdev25/sih2024/blob/main/views/manage-users.ejs"
    click ErrorView "https://github.com/amitdev25/sih2024/blob/main/views/error_40x.ejs"
    click Webcam "https://github.com/amitdev25/sih2024/blob/main/webcam.py"
    click Env "https://github.com/amitdev25/sih2024/blob/main/.env"
    click PackageJSON "https://github.com/amitdev25/sih2024/blob/main/package.json"
    click NodemonJSON "https://github.com/amitdev25/sih2024/blob/main/nodemon.json"
    click README "https://github.com/amitdev25/sih2024/blob/main/README.md"
    click Lock "https://github.com/amitdev25/sih2024/blob/main/package-lock.json"
```
