# amithm7/dbms-parking architecture

> Architecture diagram of the GitHub repository amithm7/dbms-parking, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/amithm7/dbms-parking
- Repository: https://github.com/amithm7/dbms-parking

## Overview

##### Main Components

A. Client-Side (Frontend):
- Login Interface
- Main Application Interface
- Static Assets (CSS/JS)

B. Server-Side (Backend):
- Node.js Web Server
- API Endpoints
- Database Connection Layer

C. Database Layer:
- MySQL Database (parkingMS)
- Relations (Tables)
- Triggers (Bill Calculation)

**[Frontend Tier]**
- Show two main HTML pages (app.html, login.html)
- Include static asset bundles (CSS/JS)
- Indicate client-side JavaScript modules

**[Application Tier]**
- Node.js Server (server.js)
- API Routes
- Authentication Layer
- Business Logic Layer

**[Database Tier]**
- MySQL Database (parkingMS)
- Key Tables (from relations.sql)
- Billing Trigger

##### Important Flows to Highlight

a. Authentication Flow:
- Login request path
- Session management
- Security boundaries

b. Parking Management Flow:
- Employee management
- Parking space allocation
- Vehicle entry/exit
- Billing calculation

##### Specific Implementation Details

- Rectangles: Main components (Frontend, Backend, Database)
- Green: User interfaces
- Blue: Server components
- Yellow: Database components

##### Key Relationships

- Frontend to Backend:
- HTTP/API requests
- Static file serving
- Authentication requests

- Backend to Database:
- Database connection pool
- Query execution paths
- Trigger activation paths

##### Technical Specifications

- Node.js as the server runtime
- MySQL as the database
- REST API endpoints
- Static file middleware
- Billing trigger (20 + 5 per hour calculation)

**[User Interface Layer]**
- ↓
**[Static Assets] → [Node.js Server] → [API Routes]**
- ↓
**[Database Connection]**
- ↓
**[MySQL Database]**
- ↓
**[Tables and Triggers]**

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "User Interface Layer"
        Login["Login Interface"]
        MainApp["Main Application Interface"]
        StaticAssets["Static Assets"]
    end

    subgraph "Application Layer"
        NodeServer["Node.js Web Server"]
        API["API Endpoints"]
        Auth["Authentication Layer"]
        BusinessLogic["Business Logic"]
    end

    subgraph "Database Layer"
        DBConn["Database Connection Pool"]
        MySQL[(MySQL Database)]
        Tables["Database Tables"]
        Triggers["Billing Triggers"]
    end

    %% Relationships
    Login --> NodeServer
    MainApp --> NodeServer
    StaticAssets --> NodeServer
    NodeServer --> API
    API --> Auth
    API --> BusinessLogic
    BusinessLogic --> DBConn
    DBConn --> MySQL
    MySQL --> Tables
    MySQL --> Triggers

    %% Click Events
    click Login "https://github.com/amithm7/dbms-parking/blob/master/app/login.html"
    click MainApp "https://github.com/amithm7/dbms-parking/blob/master/app/app.html"
    click StaticAssets "https://github.com/amithm7/dbms-parking/tree/master/app/public/"
    click NodeServer "https://github.com/amithm7/dbms-parking/blob/master/server.js"
    click Tables "https://github.com/amithm7/dbms-parking/blob/master/db/relations.sql"
    click Triggers "https://github.com/amithm7/dbms-parking/blob/master/db/trigger.sql"

    %% Styling
    classDef frontend fill:#90EE90,stroke:#333,stroke-width:2px
    classDef backend fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef database fill:#FFE4B5,stroke:#333,stroke-width:2px

    class Login,MainApp,StaticAssets frontend
    class NodeServer,API,Auth,BusinessLogic backend
    class DBConn,MySQL,Tables,Triggers database

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        Backend["Backend Component"]:::backend
        DB["Database Component"]:::database
    end
```
