# hungnguyen3205/car_rental_website architecture

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

- Interactive diagram: https://gitdiagram.com/hungnguyen3205/car_rental_website
- Repository: https://github.com/hungnguyen3205/car_rental_website

## Overview

#### Purpose and topology
Midnight Luxury is a decoupled car-rental platform: a Vue client/admin SPA, Laravel JSON API and MySQL persistence, plus a separate Python chatbot service. Docker assets and a top-level load-balancer configuration support multi-service deployment: `docker-compose.yml`, `nginx_lb/nginx.conf`, `BE/Dockerfile`.

#### Frontend application
The Vue/Vite SPA is the user-facing entry point, bootstrapped at `FE/src/main.js` and composed through `FE/src/App.vue`. Route selection separates public/client flows from administration in `FE/src/router/index.js`; layouts establish the role-specific shells in `FE/src/layout/wrapper/Client/index.vue` and `FE/src/layout/wrapper/Admin/index.vue`.

#### Rental and customer journey
Client pages present fleet discovery, booking/trip history, authentication, and profile flows. Fleet and booking views consume API data through the shared request layer at `FE/src/core/baseRequest.js`. The principal user path is browse vehicles → submit booking → inspect trip/detail, represented by `FE/src/pages/Fleet/index.vue`, `FE/src/pages/Client/MyTrips/index.vue`, and `FE/src/pages/Client/MyTrips/BookingDetail.vue`.

#### Laravel API and domain boundary
Laravel is the authoritative business/API layer, entered through `BE/public/index.php` and API route definitions in `BE/routes/api.php`. Controllers partition client, admin, and authentication responsibilities: `BE/app/Http/Controllers/Client/BookingController.php`, `BE/app/Http/Controllers/Admin/BookingController.php`, and `BE/app/Http/Controllers/Auth/AuthController.php`. Social login is isolated in `BE/app/Http/Controllers/Auth/SocialAuthController.php`.

#### Persistence and operational workflows
Eloquent domain models define the core rental records—cars, categories, bookings, users, and separate admins—at `BE/app/Models/Car.php`, `BE/app/Models/Booking.php`, and `BE/app/Models/Admin.php`. MySQL schema evolution establishes booking locations and uploaded bill images via `BE/database/migrations/2026_04_30_094849_add_locations_to_bookings_table.php` and `BE/database/migrations/2026_04_30_085549_add_bill_image_to_bookings_table.php`; bill artifacts are exposed under `BE/public/uploads/bills`.

#### Administration
Admin-only UI handles dashboard, fleet, and booking operations through the admin layout and corresponding Laravel controller boundary: `FE/src/pages/Admin/Dashboard/index.vue`, `FE/src/pages/Admin/Cars/index.vue`, `FE/src/pages/Admin/Bookings/index.vue`; `BE/app/Http/Controllers/Admin/DashboardController.php`, `BE/app/Http/Controllers/Admin/CarController.php`.

#### AI assistant service
The chatbot is an independently deployable FastAPI/Python service, started at `AI_Assistant/main.py`. It classifies customer intents defined in `AI_Assistant/intents.json` using custom model and NLP preprocessing modules: `AI_Assistant/model.py`, `AI_Assistant/nltk_utils.py`. Training produces/uses the model artifact `AI_Assistant/data.pth`; the client chat surface is `FE/src/components/Common/ChatWidget.vue`. This is a direct frontend-to-AI HTTP boundary, distinct from Laravel’s rental authority.

Main entry points: [`BE/routes/api.php`](https://github.com/hungnguyen3205/car_rental_website/blob/main/BE/routes/api.php) (API routes), [`docker-compose.yml`](https://github.com/hungnguyen3205/car_rental_website/blob/main/docker-compose.yml) (Service deployment), [`FE/src/router/index.js`](https://github.com/hungnguyen3205/car_rental_website/blob/main/FE/src/router/index.js) (Role router), [`BE/app/Http/Controllers/Client/BookingController.php`](https://github.com/hungnguyen3205/car_rental_website/blob/main/BE/app/Http/Controllers/Client/BookingController.php) (Client booking API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Vue SPA"]
  node_spa_bootstrap["SPA bootstrap<br/>Vue entry<br/>[main.js]"]
  node_app_shell["App shell<br/>Vue root<br/>[App.vue]"]
  node_router["Role router<br/>Vue router<br/>[index.js]"]
  node_client_layout["Client layout<br/>Vue layout<br/>[index.vue]"]
  node_admin_layout["Admin layout<br/>Vue layout<br/>[index.vue]"]
  node_fleet_booking["Fleet and trips<br/>Client views<br/>[index.vue]"]
  node_api_client["API request layer<br/>HTTP client<br/>[baseRequest.js]"]
  node_admin_views["Admin operations<br/>Admin views<br/>[index.vue]"]
  node_chat_widget["Chat widget<br/>Vue component<br/>[ChatWidget.vue]"]
end

subgraph group_backend["Laravel API"]
  node_laravel_entry["Laravel entry<br/>PHP entrypoint<br/>[index.php]"]
  node_api_routes["API routes<br/>Laravel routes<br/>[api.php]"]
  node_client_booking_api["Client booking API<br/>Laravel controller"]
  node_admin_api["Admin API<br/>Laravel controllers<br/>[CarController.php]"]
  node_auth_api["Auth and social login<br/>Laravel controllers<br/>[AuthController.php]"]
  node_rental_models["Rental domain models<br/>Eloquent models<br/>[Booking.php]"]
  node_mysql_schema[("MySQL rental schema<br/>Database schema")]
  node_bill_uploads["Bill uploads<br/>Public artifacts"]
end

subgraph group_ai["AI Assistant"]
  node_ai_service{{"FastAPI chatbot<br/>Python service<br/>[main.py]"}}
  node_intent_model["Intent model<br/>NLP classifier<br/>[model.py]"]
end

node_deployment{{"Service deployment<br/>Docker and load balancer<br/>[docker-compose.yml]"}}

node_spa_bootstrap -->|"mounts"| node_app_shell
node_app_shell -->|"uses"| node_router
node_router -->|"client routes"| node_client_layout
node_router -->|"admin routes"| node_admin_layout
node_client_layout -->|"renders"| node_fleet_booking
node_admin_layout -->|"renders"| node_admin_views
node_fleet_booking -->|"rental requests"| node_api_client
node_admin_views -->|"admin requests"| node_api_client
node_api_client -->|"JSON HTTP"| node_laravel_entry
node_laravel_entry -->|"dispatches"| node_api_routes
node_api_routes -->|"client booking"| node_client_booking_api
node_api_routes -->|"admin operations"| node_admin_api
node_api_routes -->|"authentication"| node_auth_api
node_client_booking_api -->|"reads and writes"| node_rental_models
node_admin_api -->|"manages"| node_rental_models
node_rental_models -->|"persists"| node_mysql_schema
node_client_booking_api -->|"stores bill images"| node_bill_uploads
node_chat_widget -->|"direct HTTP"| node_ai_service
node_ai_service -->|"classifies intents"| node_intent_model
node_deployment -.->|"deploys frontend"| node_spa_bootstrap
node_deployment -.->|"deploys API"| node_laravel_entry
node_deployment -.->|"deploys chatbot"| node_ai_service

click node_spa_bootstrap "https://github.com/hungnguyen3205/car_rental_website/blob/main/FE/src/main.js"
click node_app_shell "https://github.com/hungnguyen3205/car_rental_website/blob/main/FE/src/App.vue"
click node_router "https://github.com/hungnguyen3205/car_rental_website/blob/main/FE/src/router/index.js"
click node_client_layout "https://github.com/hungnguyen3205/car_rental_website/blob/main/FE/src/layout/wrapper/Client/index.vue"
click node_admin_layout "https://github.com/hungnguyen3205/car_rental_website/blob/main/FE/src/layout/wrapper/Admin/index.vue"
click node_fleet_booking "https://github.com/hungnguyen3205/car_rental_website/blob/main/FE/src/pages/Fleet/index.vue"
click node_api_client "https://github.com/hungnguyen3205/car_rental_website/blob/main/FE/src/core/baseRequest.js"
click node_admin_views "https://github.com/hungnguyen3205/car_rental_website/blob/main/FE/src/pages/Admin/Dashboard/index.vue"
click node_chat_widget "https://github.com/hungnguyen3205/car_rental_website/blob/main/FE/src/components/Common/ChatWidget.vue"
click node_laravel_entry "https://github.com/hungnguyen3205/car_rental_website/blob/main/BE/public/index.php"
click node_api_routes "https://github.com/hungnguyen3205/car_rental_website/blob/main/BE/routes/api.php"
click node_client_booking_api "https://github.com/hungnguyen3205/car_rental_website/blob/main/BE/app/Http/Controllers/Client/BookingController.php"
click node_admin_api "https://github.com/hungnguyen3205/car_rental_website/blob/main/BE/app/Http/Controllers/Admin/CarController.php"
click node_auth_api "https://github.com/hungnguyen3205/car_rental_website/blob/main/BE/app/Http/Controllers/Auth/AuthController.php"
click node_rental_models "https://github.com/hungnguyen3205/car_rental_website/blob/main/BE/app/Models/Booking.php"
click node_mysql_schema "https://github.com/hungnguyen3205/car_rental_website/blob/main/BE/database/migrations/2026_04_30_094849_add_locations_to_bookings_table.php"
click node_bill_uploads "https://github.com/hungnguyen3205/car_rental_website/tree/main/BE/public/uploads/bills"
click node_ai_service "https://github.com/hungnguyen3205/car_rental_website/blob/main/AI_Assistant/main.py"
click node_intent_model "https://github.com/hungnguyen3205/car_rental_website/blob/main/AI_Assistant/model.py"
click node_deployment "https://github.com/hungnguyen3205/car_rental_website/blob/main/docker-compose.yml"

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_spa_bootstrap,node_app_shell,node_router,node_client_layout,node_admin_layout,node_fleet_booking,node_api_client,node_admin_views,node_chat_widget toneBlue
class node_laravel_entry,node_api_routes,node_client_booking_api,node_admin_api,node_auth_api,node_rental_models,node_mysql_schema,node_bill_uploads toneAmber
class node_ai_service,node_intent_model toneMint
class node_deployment toneNeutral
```

## Components

### Vue SPA

Client and admin single-page application.

- [SPA bootstrap](https://github.com/hungnguyen3205/car_rental_website/blob/main/FE/src/main.js): Vue entry · `FE/src/main.js`
- [App shell](https://github.com/hungnguyen3205/car_rental_website/blob/main/FE/src/App.vue): Vue root · `FE/src/App.vue`
- [Role router](https://github.com/hungnguyen3205/car_rental_website/blob/main/FE/src/router/index.js): Vue router · Separates client and admin routes. · `FE/src/router/index.js`
- [Client layout](https://github.com/hungnguyen3205/car_rental_website/blob/main/FE/src/layout/wrapper/Client/index.vue): Vue layout · `FE/src/layout/wrapper/Client/index.vue`
- [Admin layout](https://github.com/hungnguyen3205/car_rental_website/blob/main/FE/src/layout/wrapper/Admin/index.vue): Vue layout · `FE/src/layout/wrapper/Admin/index.vue`
- [Fleet and trips](https://github.com/hungnguyen3205/car_rental_website/blob/main/FE/src/pages/Fleet/index.vue): Client views · Browse vehicles, submit bookings, and inspect trip details. · `FE/src/pages/Fleet/index.vue`
- [API request layer](https://github.com/hungnguyen3205/car_rental_website/blob/main/FE/src/core/baseRequest.js): HTTP client · `FE/src/core/baseRequest.js`
- [Admin operations](https://github.com/hungnguyen3205/car_rental_website/blob/main/FE/src/pages/Admin/Dashboard/index.vue): Admin views · Dashboard, car, and booking management. · `FE/src/pages/Admin/Dashboard/index.vue`
- [Chat widget](https://github.com/hungnguyen3205/car_rental_website/blob/main/FE/src/components/Common/ChatWidget.vue): Vue component · `FE/src/components/Common/ChatWidget.vue`

### Laravel API

Authoritative rental and administration API.

- [Laravel entry](https://github.com/hungnguyen3205/car_rental_website/blob/main/BE/public/index.php): PHP entrypoint · `BE/public/index.php`
- [API routes](https://github.com/hungnguyen3205/car_rental_website/blob/main/BE/routes/api.php): Laravel routes · `BE/routes/api.php`
- [Client booking API](https://github.com/hungnguyen3205/car_rental_website/blob/main/BE/app/Http/Controllers/Client/BookingController.php): Laravel controller · `BE/app/Http/Controllers/Client/BookingController.php`
- [Admin API](https://github.com/hungnguyen3205/car_rental_website/blob/main/BE/app/Http/Controllers/Admin/CarController.php): Laravel controllers · Dashboard, fleet, and booking administration. · `BE/app/Http/Controllers/Admin/CarController.php`
- [Auth and social login](https://github.com/hungnguyen3205/car_rental_website/blob/main/BE/app/Http/Controllers/Auth/AuthController.php): Laravel controllers · `BE/app/Http/Controllers/Auth/AuthController.php`
- [Rental domain models](https://github.com/hungnguyen3205/car_rental_website/blob/main/BE/app/Models/Booking.php): Eloquent models · Cars, bookings, users, admins, and categories. · `BE/app/Models/Booking.php`
- [MySQL rental schema](https://github.com/hungnguyen3205/car_rental_website/blob/main/BE/database/migrations/2026_04_30_094849_add_locations_to_bookings_table.php): Database schema · Booking locations and bill-image fields evolve through migrations. · `BE/database/migrations/2026_04_30_094849_add_locations_to_bookings_table.php`
- [Bill uploads](https://github.com/hungnguyen3205/car_rental_website/tree/main/BE/public/uploads/bills): Public artifacts · `BE/public/uploads/bills`

### AI Assistant

Independent intent-classification chatbot service.

- [FastAPI chatbot](https://github.com/hungnguyen3205/car_rental_website/blob/main/AI_Assistant/main.py): Python service · Serves customer intent responses independently of Laravel. · `AI_Assistant/main.py`
- [Intent model](https://github.com/hungnguyen3205/car_rental_website/blob/main/AI_Assistant/model.py): NLP classifier · Intent definitions, preprocessing, and trained model artifact. · `AI_Assistant/model.py`

### Other components

- [Service deployment](https://github.com/hungnguyen3205/car_rental_website/blob/main/docker-compose.yml): Docker and load balancer · Composes services behind the top-level load balancer. · `docker-compose.yml`

## Connections

- SPA bootstrap → App shell: mounts
- App shell → Role router: uses
- Role router → Client layout: client routes
- Role router → Admin layout: admin routes
- Client layout → Fleet and trips: renders
- Admin layout → Admin operations: renders
- Fleet and trips → API request layer: rental requests
- Admin operations → API request layer: admin requests
- API request layer → Laravel entry: JSON HTTP
- Laravel entry → API routes: dispatches
- API routes → Client booking API: client booking
- API routes → Admin API: admin operations
- API routes → Auth and social login: authentication
- Client booking API → Rental domain models: reads and writes
- Admin API → Rental domain models: manages
- Rental domain models → MySQL rental schema: persists
- Client booking API → Bill uploads: stores bill images
- Chat widget → FastAPI chatbot: direct HTTP · Bypasses Laravel rental authority.
- FastAPI chatbot → Intent model: classifies intents
- Service deployment → SPA bootstrap: deploys frontend
- Service deployment → Laravel entry: deploys API
- Service deployment → FastAPI chatbot: deploys chatbot
