# chandruthangadurai2005/vehicle_service architecture

> Architecture diagram of the GitHub repository chandruthangadurai2005/vehicle_service, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chandruthangadurai2005/vehicle_service
- Repository: https://github.com/chandruthangadurai2005/vehicle_service

## Overview

#### Purpose and Entry Points
This is a Node.js/Express vehicle service center management system backed by PostgreSQL. It exposes REST CRUD APIs for operational entities—customers, vehicles, employees, services, billing, inventory, and branches—and serves a browser frontend.

Primary runtime entry point: `server.js`. Database connectivity is centralized in `db.js`. The deployed service is intended to run through the process definition in `Procfile`.

#### HTTP Server and Static Frontend Boundary
`server.js` initializes the Express application, mounts API routes, and serves browser-facing assets from `public/`. This separates the system into:
- Browser UI: `public/index.html`, `public/login.html`, `public/script.js`
- Backend API: `server.js`, `routes/api.js`
- Persistent data access: `db.js`

The frontend communicates with the backend over HTTP rather than accessing PostgreSQL directly.

#### REST API Layer
`routes/api.js` is the application’s primary business/API boundary. It implements REST-style endpoints used to create, read, update, and delete service-center records across the relational domain.

The API layer is responsible for translating client requests into database operations and returning HTTP responses. It is mounted by `server.js` and depends on the database connection exported by `db.js`.

#### Relational Data Layer
`db.js` encapsulates PostgreSQL connection/pool setup and is the sole infrastructure boundary for persistent data access. The domain described by the project includes related customer, vehicle, employee, service, billing, inventory, and branch records.

Control flow is generally:
1. Browser action in `public/script.js`
2. HTTP request to routes in `routes/api.js`
3. SQL/database request through `db.js`
4. PostgreSQL response mapped to JSON
5. UI refresh or update in `public/script.js`

#### Browser Application
The browser client is a static HTML/CSS/JavaScript application:
- `public/index.html` provides the main management interface.
- `public/login.html` provides a separate login-facing page.
- `public/script.js` contains client-side interaction and API request logic.
- `public/main.css` provides shared presentation styling.

This is a lightweight server-served frontend, not a separately built SPA runtime.

#### Runtime and Deployment
The material runtime is Node.js with Express, declared through `package.json`; dependencies are lockfile-pinned in `package-lock.json`. PostgreSQL is the external stateful service. `Procfile` defines the deployment process for a platform such as Render, matching the README’s hosted deployment reference.

#### Supporting Repository Artifacts
`ROLE_SYSTEM.md` and `session.txt` may support project-specific operational or authentication context, but the core application path remains `server.js` → `routes/api.js` → `db.js`. The included presentation, `public/vehicle service center (3).pptx`, is documentation rather than a runtime component.

Main entry points: [`server.js`](https://github.com/chandruthangadurai2005/vehicle_service/blob/main/server.js) (Express Server), [`public/index.html`](https://github.com/chandruthangadurai2005/vehicle_service/blob/main/public/index.html) (Management UI), [`public/login.html`](https://github.com/chandruthangadurai2005/vehicle_service/blob/main/public/login.html) (Login Page), [`public/script.js`](https://github.com/chandruthangadurai2005/vehicle_service/blob/main/public/script.js) (Client Interactions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser UI"]
  node_main_ui["Management UI<br/>static HTML<br/>[index.html]"]
  node_login_ui["Login Page<br/>static HTML<br/>[login.html]"]
  node_browser_client["Client Interactions<br/>browser JavaScript<br/>[script.js]"]
  node_styles["Shared Styles<br/>CSS<br/>[main.css]"]
end

subgraph group_backend["Node.js Service"]
  node_server["Express Server<br/>Node.js entry point<br/>[server.js]"]
  node_api["REST API<br/>Express routes<br/>[api.js]"]
  node_node_runtime["Node.js Dependencies<br/>runtime manifest<br/>[package.json]"]
  node_deployment["Deployment Process<br/>Procfile"]
end

subgraph group_data["Data Layer"]
  node_db_adapter["Database Pool<br/>PostgreSQL adapter<br/>[db.js]"]
  node_postgres[("PostgreSQL<br/>relational database")]
end

node_main_ui -->|"loads"| node_browser_client
node_login_ui -->|"loads"| node_browser_client
node_main_ui -->|"uses"| node_styles
node_login_ui -->|"uses"| node_styles
node_browser_client -->|"HTTP requests"| node_server
node_server -->|"serves"| node_main_ui
node_server -->|"serves"| node_login_ui
node_server -->|"mounts"| node_api
node_api -->|"queries"| node_db_adapter
node_db_adapter -->|"SQL connection"| node_postgres
node_node_runtime -.->|"declares runtime"| node_server
node_deployment -.->|"starts"| node_server

click node_main_ui "https://github.com/chandruthangadurai2005/vehicle_service/blob/main/public/index.html"
click node_login_ui "https://github.com/chandruthangadurai2005/vehicle_service/blob/main/public/login.html"
click node_browser_client "https://github.com/chandruthangadurai2005/vehicle_service/blob/main/public/script.js"
click node_styles "https://github.com/chandruthangadurai2005/vehicle_service/blob/main/public/main.css"
click node_server "https://github.com/chandruthangadurai2005/vehicle_service/blob/main/server.js"
click node_api "https://github.com/chandruthangadurai2005/vehicle_service/blob/main/routes/api.js"
click node_db_adapter "https://github.com/chandruthangadurai2005/vehicle_service/blob/main/db.js"
click node_node_runtime "https://github.com/chandruthangadurai2005/vehicle_service/blob/main/package.json"
click node_deployment "https://github.com/chandruthangadurai2005/vehicle_service/blob/main/Procfile"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main_ui,node_login_ui,node_browser_client,node_styles toneBlue
class node_server,node_api,node_node_runtime,node_deployment toneAmber
class node_db_adapter,node_postgres toneMint
```

## Components

### Browser UI

Server-served static management interface.

- [Management UI](https://github.com/chandruthangadurai2005/vehicle_service/blob/main/public/index.html): static HTML · `public/index.html`
- [Login Page](https://github.com/chandruthangadurai2005/vehicle_service/blob/main/public/login.html): static HTML · `public/login.html`
- [Client Interactions](https://github.com/chandruthangadurai2005/vehicle_service/blob/main/public/script.js): browser JavaScript · Issues API requests and refreshes the interface. · `public/script.js`
- [Shared Styles](https://github.com/chandruthangadurai2005/vehicle_service/blob/main/public/main.css): CSS · `public/main.css`

### Node.js Service

Express API and static asset host.

- [Express Server](https://github.com/chandruthangadurai2005/vehicle_service/blob/main/server.js): Node.js entry point · Hosts static assets and mounts the API. · `server.js`
- [REST API](https://github.com/chandruthangadurai2005/vehicle_service/blob/main/routes/api.js): Express routes · CRUD boundary for service-center operations. · `routes/api.js`
- [Node.js Dependencies](https://github.com/chandruthangadurai2005/vehicle_service/blob/main/package.json): runtime manifest · Declares the Express service runtime. · `package.json`
- [Deployment Process](https://github.com/chandruthangadurai2005/vehicle_service/blob/main/Procfile): Procfile · Defines the hosted service process. · `Procfile`

### Data Layer

Persistent relational storage boundary.

- [Database Pool](https://github.com/chandruthangadurai2005/vehicle_service/blob/main/db.js): PostgreSQL adapter · Centralized connection and SQL access boundary. · `db.js`
- **PostgreSQL**: relational database · Stores customers, vehicles, employees, services, billing, inventory, and branches.

## Connections

- Management UI → Client Interactions: loads
- Login Page → Client Interactions: loads
- Management UI → Shared Styles: uses
- Login Page → Shared Styles: uses
- Client Interactions → Express Server: HTTP requests
- Express Server → Management UI: serves
- Express Server → Login Page: serves
- Express Server → REST API: mounts
- REST API → Database Pool: queries
- Database Pool → PostgreSQL: SQL connection
- Node.js Dependencies → Express Server: declares runtime
- Deployment Process → Express Server: starts
