# nomi-214/new_jeddah_motors architecture

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

- Interactive diagram: https://gitdiagram.com/nomi-214/new_jeddah_motors
- Repository: https://github.com/nomi-214/new_jeddah_motors

## Overview

New Jeddah Motors is a showroom-management application. Staff authenticate in the React app, then manage inventory, customers, sales, payments, and operating records through a FastAPI API; the API persists business data and supports dashboard reporting. The README documents the major product capabilities, while sampled source confirms API registration, OTP email delivery, and installment payment behavior. Several page-to-endpoint details are documented but not sampled, so those links reflect the documented contract rather than inspected call sites.

Main entry points: [`backend/main.py`](https://github.com/nomi-214/new_jeddah_motors/blob/main/backend/main.py) (FastAPI application), [`backend/database.py`](https://github.com/nomi-214/new_jeddah_motors/blob/main/backend/database.py) (Database access), [`frontend/src/App.jsx`](https://github.com/nomi-214/new_jeddah_motors/blob/main/frontend/src/App.jsx) (React routes), [`frontend/src/api/client.js`](https://github.com/nomi-214/new_jeddah_motors/blob/main/frontend/src/api/client.js) (HTTP client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["React routes<br/>[App.jsx]"]
  node_authui["Login and signup<br/>[Login.jsx]"]
  node_dashboardui["Dashboard<br/>[Dashboard.jsx]"]
  node_inventoryui["Cars<br/>[Cars.jsx]"]
  node_customersui["Customers<br/>[Customers.jsx]"]
  node_salesui["Sales<br/>[Sales.jsx]"]
  node_installmentsui["Installments<br/>[Installments.jsx]"]
  node_ledgerui["Transactions and expenses<br/>[Transactions.jsx]"]
  node_adminui["Staff and audit<br/>[Users.jsx]"]
  node_authstate["Auth state<br/>[AuthContext.jsx]"]
  node_client["HTTP client<br/>[client.js]"]
end

subgraph group_api["API workflows"]
  node_apiapp["FastAPI application<br/>[main.py]"]
  node_authapi["Authentication<br/>[auth_router.py]"]
  node_carsapi["Inventory API<br/>[cars.py]"]
  node_customersapi["Customer accounts"]
  node_salesapi["Sales API<br/>[sales.py]"]
  node_installmentsapi["Installment plans<br/>[installments.py]"]
  node_transactionsapi["Cash ledger<br/>[transactions.py]"]
  node_expensesapi["Expense tracking<br/>[expenses.py]"]
  node_reportsapi["Reports<br/>[reports.py]"]
  node_usersapi["User management<br/>[users.py]"]
  node_auditapi["Audit logs<br/>[audit_logs.py]"]
end

subgraph group_core["Shared backend"]
  node_database["Database access<br/>[database.py]"]
  node_models["Business models<br/>[models.py]"]
end

subgraph group_integrations["External services"]
  node_sqlstore[("SQL database")]
  node_email["SMTP email provider"]
end

node_staff(("Showroom staff"))

node_staff -->|"uses"| node_app
node_app -->|"routes"| node_authui
node_app -->|"routes"| node_dashboardui
node_app -->|"routes"| node_inventoryui
node_app -->|"routes"| node_customersui
node_app -->|"routes"| node_salesui
node_app -->|"routes"| node_installmentsui
node_app -->|"routes"| node_ledgerui
node_app -->|"routes"| node_adminui
node_authui -->|"authenticates"| node_authstate
node_authstate -->|"requests"| node_client
node_authui -->|"requests"| node_client
node_dashboardui -->|"requests"| node_client
node_inventoryui -->|"requests"| node_client
node_customersui -->|"requests"| node_client
node_salesui -->|"requests"| node_client
node_installmentsui -->|"requests"| node_client
node_ledgerui -->|"requests"| node_client
node_adminui -->|"requests"| node_client
node_client -->|"sends HTTP"| node_apiapp
node_apiapp -->|"mounts"| node_authapi
node_apiapp -->|"mounts"| node_carsapi
node_apiapp -->|"mounts"| node_customersapi
node_apiapp -->|"mounts"| node_salesapi
node_apiapp -->|"mounts"| node_installmentsapi
node_apiapp -->|"mounts"| node_transactionsapi
node_apiapp -->|"mounts"| node_expensesapi
node_apiapp -->|"mounts"| node_reportsapi
node_apiapp -->|"mounts"| node_usersapi
node_apiapp -->|"mounts"| node_auditapi
node_authapi -->|"queries"| node_database
node_carsapi -->|"queries"| node_database
node_customersapi -->|"queries"| node_database
node_salesapi -->|"queries"| node_database
node_installmentsapi -->|"reads and writes"| node_database
node_transactionsapi -->|"queries"| node_database
node_expensesapi -->|"queries"| node_database
node_reportsapi -->|"queries"| node_database
node_usersapi -->|"queries"| node_database
node_auditapi -->|"queries"| node_database
node_database -->|"maps entities"| node_models
node_database -->|"persists"| node_sqlstore
node_authapi -.->|"sends OTP"| node_email
node_salesapi -.->|"creates plans"| node_installmentsapi

click node_app "https://github.com/nomi-214/new_jeddah_motors/blob/main/frontend/src/App.jsx"
click node_authui "https://github.com/nomi-214/new_jeddah_motors/blob/main/frontend/src/pages/Login.jsx"
click node_dashboardui "https://github.com/nomi-214/new_jeddah_motors/blob/main/frontend/src/pages/Dashboard.jsx"
click node_inventoryui "https://github.com/nomi-214/new_jeddah_motors/blob/main/frontend/src/pages/Cars.jsx"
click node_customersui "https://github.com/nomi-214/new_jeddah_motors/blob/main/frontend/src/pages/Customers.jsx"
click node_salesui "https://github.com/nomi-214/new_jeddah_motors/blob/main/frontend/src/pages/Sales.jsx"
click node_installmentsui "https://github.com/nomi-214/new_jeddah_motors/blob/main/frontend/src/pages/Installments.jsx"
click node_ledgerui "https://github.com/nomi-214/new_jeddah_motors/blob/main/frontend/src/pages/Transactions.jsx"
click node_adminui "https://github.com/nomi-214/new_jeddah_motors/blob/main/frontend/src/pages/Users.jsx"
click node_authstate "https://github.com/nomi-214/new_jeddah_motors/blob/main/frontend/src/context/AuthContext.jsx"
click node_client "https://github.com/nomi-214/new_jeddah_motors/blob/main/frontend/src/api/client.js"
click node_apiapp "https://github.com/nomi-214/new_jeddah_motors/blob/main/backend/main.py"
click node_authapi "https://github.com/nomi-214/new_jeddah_motors/blob/main/backend/routers/auth_router.py"
click node_carsapi "https://github.com/nomi-214/new_jeddah_motors/blob/main/backend/routers/cars.py"
click node_customersapi "https://github.com/nomi-214/new_jeddah_motors/blob/main/backend/routers/customer_accounts.py"
click node_salesapi "https://github.com/nomi-214/new_jeddah_motors/blob/main/backend/routers/sales.py"
click node_installmentsapi "https://github.com/nomi-214/new_jeddah_motors/blob/main/backend/routers/installments.py"
click node_transactionsapi "https://github.com/nomi-214/new_jeddah_motors/blob/main/backend/routers/transactions.py"
click node_expensesapi "https://github.com/nomi-214/new_jeddah_motors/blob/main/backend/routers/expenses.py"
click node_reportsapi "https://github.com/nomi-214/new_jeddah_motors/blob/main/backend/routers/reports.py"
click node_usersapi "https://github.com/nomi-214/new_jeddah_motors/blob/main/backend/routers/users.py"
click node_auditapi "https://github.com/nomi-214/new_jeddah_motors/blob/main/backend/routers/audit_logs.py"
click node_database "https://github.com/nomi-214/new_jeddah_motors/blob/main/backend/database.py"
click node_models "https://github.com/nomi-214/new_jeddah_motors/blob/main/backend/models.py"

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_app,node_authui,node_dashboardui,node_inventoryui,node_customersui,node_salesui,node_installmentsui,node_ledgerui,node_adminui,node_authstate,node_client toneBlue
class node_apiapp,node_authapi,node_carsapi,node_customersapi,node_salesapi,node_installmentsapi,node_transactionsapi,node_expensesapi,node_reportsapi,node_usersapi,node_auditapi toneAmber
class node_database,node_models toneMint
class node_sqlstore,node_email toneRose
class node_staff toneIndigo
```

## Components

### Web application

- [React routes](https://github.com/nomi-214/new_jeddah_motors/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Login and signup](https://github.com/nomi-214/new_jeddah_motors/blob/main/frontend/src/pages/Login.jsx): `frontend/src/pages/Login.jsx`
- [Dashboard](https://github.com/nomi-214/new_jeddah_motors/blob/main/frontend/src/pages/Dashboard.jsx): `frontend/src/pages/Dashboard.jsx`
- [Cars](https://github.com/nomi-214/new_jeddah_motors/blob/main/frontend/src/pages/Cars.jsx): `frontend/src/pages/Cars.jsx`
- [Customers](https://github.com/nomi-214/new_jeddah_motors/blob/main/frontend/src/pages/Customers.jsx): `frontend/src/pages/Customers.jsx`
- [Sales](https://github.com/nomi-214/new_jeddah_motors/blob/main/frontend/src/pages/Sales.jsx): `frontend/src/pages/Sales.jsx`
- [Installments](https://github.com/nomi-214/new_jeddah_motors/blob/main/frontend/src/pages/Installments.jsx): `frontend/src/pages/Installments.jsx`
- [Transactions and expenses](https://github.com/nomi-214/new_jeddah_motors/blob/main/frontend/src/pages/Transactions.jsx): `frontend/src/pages/Transactions.jsx`
- [Staff and audit](https://github.com/nomi-214/new_jeddah_motors/blob/main/frontend/src/pages/Users.jsx): `frontend/src/pages/Users.jsx`
- [Auth state](https://github.com/nomi-214/new_jeddah_motors/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [HTTP client](https://github.com/nomi-214/new_jeddah_motors/blob/main/frontend/src/api/client.js): `frontend/src/api/client.js`

### API workflows

- [FastAPI application](https://github.com/nomi-214/new_jeddah_motors/blob/main/backend/main.py): `backend/main.py`
- [Authentication](https://github.com/nomi-214/new_jeddah_motors/blob/main/backend/routers/auth_router.py): `backend/routers/auth_router.py`
- [Inventory API](https://github.com/nomi-214/new_jeddah_motors/blob/main/backend/routers/cars.py): `backend/routers/cars.py`
- [Customer accounts](https://github.com/nomi-214/new_jeddah_motors/blob/main/backend/routers/customer_accounts.py): `backend/routers/customer_accounts.py`
- [Sales API](https://github.com/nomi-214/new_jeddah_motors/blob/main/backend/routers/sales.py): `backend/routers/sales.py`
- [Installment plans](https://github.com/nomi-214/new_jeddah_motors/blob/main/backend/routers/installments.py): `backend/routers/installments.py`
- [Cash ledger](https://github.com/nomi-214/new_jeddah_motors/blob/main/backend/routers/transactions.py): `backend/routers/transactions.py`
- [Expense tracking](https://github.com/nomi-214/new_jeddah_motors/blob/main/backend/routers/expenses.py): `backend/routers/expenses.py`
- [Reports](https://github.com/nomi-214/new_jeddah_motors/blob/main/backend/routers/reports.py): `backend/routers/reports.py`
- [User management](https://github.com/nomi-214/new_jeddah_motors/blob/main/backend/routers/users.py): `backend/routers/users.py`
- [Audit logs](https://github.com/nomi-214/new_jeddah_motors/blob/main/backend/routers/audit_logs.py): `backend/routers/audit_logs.py`

### Shared backend

- [Database access](https://github.com/nomi-214/new_jeddah_motors/blob/main/backend/database.py): `backend/database.py`
- [Business models](https://github.com/nomi-214/new_jeddah_motors/blob/main/backend/models.py): `backend/models.py`

### External services

- **SQL database**
- **SMTP email provider**

### Other components

- **Showroom staff**

## Connections

- Showroom staff → React routes: uses
- React routes → Login and signup: routes
- React routes → Dashboard: routes
- React routes → Cars: routes
- React routes → Customers: routes
- React routes → Sales: routes
- React routes → Installments: routes
- React routes → Transactions and expenses: routes
- React routes → Staff and audit: routes
- Login and signup → Auth state: authenticates
- Auth state → HTTP client: requests
- Login and signup → HTTP client: requests
- Dashboard → HTTP client: requests
- Cars → HTTP client: requests
- Customers → HTTP client: requests
- Sales → HTTP client: requests
- Installments → HTTP client: requests
- Transactions and expenses → HTTP client: requests
- Staff and audit → HTTP client: requests
- HTTP client → FastAPI application: sends HTTP
- FastAPI application → Authentication: mounts
- FastAPI application → Inventory API: mounts
- FastAPI application → Customer accounts: mounts
- FastAPI application → Sales API: mounts
- FastAPI application → Installment plans: mounts
- FastAPI application → Cash ledger: mounts
- FastAPI application → Expense tracking: mounts
- FastAPI application → Reports: mounts
- FastAPI application → User management: mounts
- FastAPI application → Audit logs: mounts
- Authentication → Database access: queries
- Inventory API → Database access: queries
- Customer accounts → Database access: queries
- Sales API → Database access: queries
- Installment plans → Database access: reads and writes
- Cash ledger → Database access: queries
- Expense tracking → Database access: queries
- Reports → Database access: queries
- User management → Database access: queries
- Audit logs → Database access: queries
- Database access → Business models: maps entities
- Database access → SQL database: persists
- Authentication → SMTP email provider: sends OTP
- Sales API → Installment plans: creates plans
