# codexuf/bindot architecture

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

- Interactive diagram: https://gitdiagram.com/codexuf/bindot
- Repository: https://github.com/codexuf/bindot

## Overview

1. **Overall shape**
   - This repo is a two-tier monorepo: a **React/TypeScript frontend SPA** and a **Node.js/Express backend API**, with **MongoDB** as the persistence layer.
   - The backend is the system of record; the frontend is a client that renders admin workflows and calls the REST API.

2. **Backend boundary**
   - `backend/server.js` is the API entrypoint.
   - The backend is organized by domain routes: `auth`, `customers`, `vehicles`, `bookings`, and `dashboard`.
   - `backend/middleware/auth.js` is the main security boundary, enforcing JWT-based access for protected admin operations.

3. **Data model layer**
   - MongoDB data is represented with Mongoose models in `backend/models/`.
   - The main entities are:
     - `Admin` for authentication
     - `Customer` for customer profiles
     - `Vehicle` for fleet inventory and availability
     - `Booking` for reservations and lifecycle state
   - These models define the backend’s core business objects and are the source for all CRUD and analytics flows.

4. **Authentication flow**
   - Admin signup and login are handled by `backend/routes/auth.js`.
   - Successful authentication issues a **JWT**, which the frontend uses to authorize subsequent requests.
   - The auth middleware protects sensitive routes so only authenticated admins can manage customers, vehicles, bookings, and dashboard data.

5. **Operational domain flows**
   - `customers.js`, `vehicles.js`, and `bookings.js` expose RESTful CRUD endpoints for the three main operational domains.
   - Bookings are the most business-sensitive domain: the README indicates the backend checks vehicle availability, updates booking status, and calculates total cost.
   - Vehicle status values such as available/booked/maintenance are part of the fleet management boundary and affect booking eligibility.

6. **Analytics / dashboard flow**
   - `backend/routes/dashboard.js` serves aggregated data for the admin overview.
   - The dashboard is not just a CRUD view; it depends on backend-side aggregation for metrics like revenue, booking counts, vehicle availability, recent activity, and monthly revenue trends.
   - This makes the dashboard a read-only analytics subsystem built on top of the same domain models.

7. **Frontend application shell**
   - The frontend is a Vite-built React app in `frontend/src/`.
   - `App.tsx` and `main.tsx` define the app bootstrap and route composition.
   - `Layout.tsx` provides the shared admin shell, while pages under `frontend/src/pages/` map directly to major workflows: Dashboard, Bookings, Customers, Vehicles, Login, and Signup.

8. **Frontend state and API boundary**
   - `frontend/src/context/AuthContext.tsx` centralizes authentication state and likely stores the current admin session/token.
   - `frontend/src/services/api.ts` is the client-side integration point for HTTP requests to the backend API, including authenticated calls.
   - This clean separation means UI components do not talk to the backend directly; they go through the API service and auth context.

9. **Reusable UI components**
   - `ConfirmDialog`, `Modal`, and `StatusBadge` are shared presentation components used across CRUD screens.
   - These components support the admin workflow around destructive actions, form entry/editing, and state visualization.
   - Their presence suggests the UI is designed around table-driven management screens rather than consumer-facing browsing.

10. **Technology stack implications**
   - The frontend uses **React, TypeScript, Tailwind CSS, React Router, Axios, and Recharts**.
   - The backend uses **Express, Mongoose, and JWT**.
   - Recharts matters architecturally because the dashboard consumes backend analytics data and renders charts client-side rather than via server-generated pages.

11. **End-to-end request path**
   - Typical flow: admin logs in → receives JWT → frontend stores auth state → authenticated UI loads dashboard or CRUD pages → pages call REST endpoints via `api.ts` → Express routes validate token → Mongoose reads/writes MongoDB → results return to the UI.
   - This is a standard client/API/database split with a protected admin boundary.

12. **Deployment/runtime boundaries**
   - The repo expects separate frontend and backend runtimes in development, with the frontend served on one port and the API on another.
   - The root scripts likely orchestrate installs and concurrent startup, but the architectural unit is still two independently running apps sharing a common MongoDB database.

13. **What to draw in an architecture diagram**
   - Draw four main boxes: **Admin Browser / React SPA**, **Express API**, **MongoDB**, and the **JWT auth boundary** around protected routes.
   - Inside the API, show five domain slices: **Auth**, **Customers**, **Vehicles**, **Bookings**, and **Dashboard Analytics**.
   - On the frontend, show the app shell plus route-based pages, with a shared **AuthContext** and **API service** as the main integration layer.

Main entry points: [`backend/server.js`](https://github.com/codexuf/bindot/blob/main/backend/server.js) (server.js), [`backend/routes/dashboard.js`](https://github.com/codexuf/bindot/blob/main/backend/routes/dashboard.js) (dashboard route), [`backend/middleware/auth.js`](https://github.com/codexuf/bindot/blob/main/backend/middleware/auth.js) (auth middleware), [`frontend/src/App.tsx`](https://github.com/codexuf/bindot/blob/main/frontend/src/App.tsx) (App)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend SPA"]
  node_frontend_main(("main.tsx<br/>bootstraps SPA<br/>[main.tsx]"))
  node_frontend_app["App<br/>routes shell<br/>[App.tsx]"]
  node_frontend_layout["Layout<br/>admin shell<br/>[Layout.tsx]"]
  node_frontend_auth["AuthContext<br/>session state<br/>[AuthContext.tsx]"]
  node_frontend_api["api.ts<br/>HTTP client<br/>[api.ts]"]
  node_frontend_pages["Pages<br/>workflow screens"]
  node_frontend_ui["Shared UI<br/>reusable components"]
end

subgraph group_backend["Backend API"]
  node_backend_server(("server.js<br/>API entrypoint<br/>[server.js]"))
  node_backend_auth_route["auth route<br/>JWT auth<br/>[auth.js]"]
  node_backend_customers_route["customers route<br/>CRUD API<br/>[customers.js]"]
  node_backend_vehicles_route["vehicles route<br/>CRUD API<br/>[vehicles.js]"]
  node_backend_bookings_route["bookings route<br/>booking API<br/>[bookings.js]"]
  node_backend_dashboard_route["dashboard route<br/>analytics API<br/>[dashboard.js]"]
  node_backend_auth_mw["auth middleware<br/>JWT guard<br/>[auth.js]"]
  node_model_admin["Admin<br/>Mongoose model<br/>[Admin.js]"]
  node_model_customer["Customer<br/>Mongoose model<br/>[Customer.js]"]
  node_model_vehicle["Vehicle<br/>Mongoose model<br/>[Vehicle.js]"]
  node_model_booking["Booking<br/>Mongoose model<br/>[Booking.js]"]
end

subgraph group_data["Data Store"]
  node_mongo[("MongoDB<br/>database")]
end

node_frontend_main -->|"mounts"| node_frontend_app
node_frontend_app -->|"uses shell"| node_frontend_layout
node_frontend_app -->|"routes to"| node_frontend_pages
node_frontend_layout -->|"reuses"| node_frontend_ui
node_frontend_auth -->|"authorizes"| node_frontend_api
node_frontend_pages -->|"calls"| node_frontend_api
node_frontend_pages -->|"reads auth"| node_frontend_auth
node_frontend_api -->|"REST calls"| node_backend_server
node_backend_server -->|"mounts"| node_backend_auth_route
node_backend_server -->|"mounts"| node_backend_customers_route
node_backend_server -->|"mounts"| node_backend_vehicles_route
node_backend_server -->|"mounts"| node_backend_bookings_route
node_backend_server -->|"mounts"| node_backend_dashboard_route
node_backend_customers_route -->|"protected by"| node_backend_auth_mw
node_backend_vehicles_route -->|"protected by"| node_backend_auth_mw
node_backend_bookings_route -->|"protected by"| node_backend_auth_mw
node_backend_dashboard_route -->|"protected by"| node_backend_auth_mw
node_backend_auth_route -->|"uses"| node_model_admin
node_backend_customers_route -->|"uses"| node_model_customer
node_backend_vehicles_route -->|"uses"| node_model_vehicle
node_backend_bookings_route -->|"uses"| node_model_booking
node_backend_dashboard_route -->|"aggregates"| node_model_booking
node_backend_dashboard_route -->|"aggregates"| node_model_vehicle
node_model_admin -->|"persists to"| node_mongo
node_model_customer -->|"persists to"| node_mongo
node_model_vehicle -->|"persists to"| node_mongo
node_model_booking -->|"persists to"| node_mongo
node_backend_auth_route -->|"issues JWT"| node_frontend_auth

click node_frontend_main "https://github.com/codexuf/bindot/blob/main/frontend/src/main.tsx"
click node_frontend_app "https://github.com/codexuf/bindot/blob/main/frontend/src/App.tsx"
click node_frontend_layout "https://github.com/codexuf/bindot/blob/main/frontend/src/components/Layout.tsx"
click node_frontend_auth "https://github.com/codexuf/bindot/blob/main/frontend/src/context/AuthContext.tsx"
click node_frontend_api "https://github.com/codexuf/bindot/blob/main/frontend/src/services/api.ts"
click node_frontend_pages "https://github.com/codexuf/bindot/tree/main/frontend/src/pages"
click node_frontend_ui "https://github.com/codexuf/bindot/tree/main/frontend/src/components"
click node_backend_server "https://github.com/codexuf/bindot/blob/main/backend/server.js"
click node_backend_auth_route "https://github.com/codexuf/bindot/blob/main/backend/routes/auth.js"
click node_backend_customers_route "https://github.com/codexuf/bindot/blob/main/backend/routes/customers.js"
click node_backend_vehicles_route "https://github.com/codexuf/bindot/blob/main/backend/routes/vehicles.js"
click node_backend_bookings_route "https://github.com/codexuf/bindot/blob/main/backend/routes/bookings.js"
click node_backend_dashboard_route "https://github.com/codexuf/bindot/blob/main/backend/routes/dashboard.js"
click node_backend_auth_mw "https://github.com/codexuf/bindot/blob/main/backend/middleware/auth.js"
click node_model_admin "https://github.com/codexuf/bindot/blob/main/backend/models/Admin.js"
click node_model_customer "https://github.com/codexuf/bindot/blob/main/backend/models/Customer.js"
click node_model_vehicle "https://github.com/codexuf/bindot/blob/main/backend/models/Vehicle.js"
click node_model_booking "https://github.com/codexuf/bindot/blob/main/backend/models/Booking.js"

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_frontend_main,node_frontend_app,node_frontend_layout,node_frontend_auth,node_frontend_api,node_frontend_pages,node_frontend_ui toneBlue
class node_backend_server,node_backend_auth_route,node_backend_customers_route,node_backend_vehicles_route,node_backend_bookings_route,node_backend_dashboard_route,node_backend_auth_mw,node_model_admin,node_model_customer,node_model_vehicle,node_model_booking toneAmber
class node_mongo toneMint
```

## Components

### Frontend SPA

React/TypeScript admin client and shared UI shell

- [main.tsx](https://github.com/codexuf/bindot/blob/main/frontend/src/main.tsx): bootstraps SPA · Frontend entrypoint that mounts the React app · `frontend/src/main.tsx`
- [App](https://github.com/codexuf/bindot/blob/main/frontend/src/App.tsx): routes shell · Top-level app composition and route wiring · `frontend/src/App.tsx`
- [Layout](https://github.com/codexuf/bindot/blob/main/frontend/src/components/Layout.tsx): admin shell · Shared authenticated frame for admin pages · `frontend/src/components/Layout.tsx`
- [AuthContext](https://github.com/codexuf/bindot/blob/main/frontend/src/context/AuthContext.tsx): session state · Central auth state and token/session coordination · `frontend/src/context/AuthContext.tsx`
- [api.ts](https://github.com/codexuf/bindot/blob/main/frontend/src/services/api.ts): HTTP client · Client-side API integration layer for backend calls · `frontend/src/services/api.ts`
- [Pages](https://github.com/codexuf/bindot/tree/main/frontend/src/pages): workflow screens · Route-level admin workflows for login, signup, dashboard, customers, vehicles, and bookings · `frontend/src/pages`
- [Shared UI](https://github.com/codexuf/bindot/tree/main/frontend/src/components): reusable components · Common dialogs, badges, and modal primitives · `frontend/src/components`

### Backend API

Express server, routes, middleware, and domain models

- [server.js](https://github.com/codexuf/bindot/blob/main/backend/server.js): API entrypoint · Express application bootstrap and server startup · `backend/server.js`
- [auth route](https://github.com/codexuf/bindot/blob/main/backend/routes/auth.js): JWT auth · Admin signup and login endpoints that issue JWTs · `backend/routes/auth.js`
- [customers route](https://github.com/codexuf/bindot/blob/main/backend/routes/customers.js): CRUD API · Customer management endpoints · `backend/routes/customers.js`
- [vehicles route](https://github.com/codexuf/bindot/blob/main/backend/routes/vehicles.js): CRUD API · Fleet inventory and availability endpoints · `backend/routes/vehicles.js`
- [bookings route](https://github.com/codexuf/bindot/blob/main/backend/routes/bookings.js): booking API · Reservation lifecycle, availability checks, and cost calculations · `backend/routes/bookings.js`
- [dashboard route](https://github.com/codexuf/bindot/blob/main/backend/routes/dashboard.js): analytics API · Aggregated admin metrics and recent activity data · `backend/routes/dashboard.js`
- [auth middleware](https://github.com/codexuf/bindot/blob/main/backend/middleware/auth.js): JWT guard · Protects sensitive admin routes with token validation · `backend/middleware/auth.js`
- [Admin](https://github.com/codexuf/bindot/blob/main/backend/models/Admin.js): Mongoose model · Admin authentication and identity records · `backend/models/Admin.js`
- [Customer](https://github.com/codexuf/bindot/blob/main/backend/models/Customer.js): Mongoose model · Customer profile records · `backend/models/Customer.js`
- [Vehicle](https://github.com/codexuf/bindot/blob/main/backend/models/Vehicle.js): Mongoose model · Vehicle inventory and status records · `backend/models/Vehicle.js`
- [Booking](https://github.com/codexuf/bindot/blob/main/backend/models/Booking.js): Mongoose model · Reservation and lifecycle state records · `backend/models/Booking.js`

### Data Store

MongoDB persistence layer

- **MongoDB**: database · System of record for admins, customers, vehicles, bookings, and aggregates

## Connections

- main.tsx → App: mounts · Bootstraps the React application
- App → Layout: uses shell · Composes the shared admin layout
- App → Pages: routes to · Maps URLs to admin workflow pages
- Layout → Shared UI: reuses · Uses shared UI primitives across screens
- AuthContext → api.ts: authorizes · Supplies session state and JWT for requests
- Pages → api.ts: calls · Sends CRUD and analytics requests through the API client
- Pages → AuthContext: reads auth · Login and protected views depend on auth state
- api.ts → server.js: REST calls · Frontend talks to the Express backend over HTTP
- server.js → auth route: mounts · Registers the authentication domain routes
- server.js → customers route: mounts · Registers customer management routes
- server.js → vehicles route: mounts · Registers fleet management routes
- server.js → bookings route: mounts · Registers booking management routes
- server.js → dashboard route: mounts · Registers dashboard analytics routes
- customers route → auth middleware: protected by · Customer operations require JWT validation
- vehicles route → auth middleware: protected by · Vehicle operations require JWT validation
- bookings route → auth middleware: protected by · Booking operations require JWT validation
- dashboard route → auth middleware: protected by · Dashboard access is restricted to authenticated admins
- auth route → Admin: uses · Creates and verifies admin identity records
- customers route → Customer: uses · Reads and writes customer documents
- vehicles route → Vehicle: uses · Reads and writes vehicle documents
- bookings route → Booking: uses · Reads and writes booking documents
- dashboard route → Booking: aggregates · Builds metrics from booking data
- dashboard route → Vehicle: aggregates · Builds metrics from vehicle availability data
- Admin → MongoDB: persists to · Admin data is stored in MongoDB
- Customer → MongoDB: persists to · Customer data is stored in MongoDB
- Vehicle → MongoDB: persists to · Vehicle data is stored in MongoDB
- Booking → MongoDB: persists to · Booking data is stored in MongoDB
- auth route → AuthContext: issues JWT · Successful login/signup returns a token consumed by the client
