# krishpatel09/car-rental architecture

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

- Interactive diagram: https://gitdiagram.com/krishpatel09/car-rental
- Repository: https://github.com/krishpatel09/car-rental

## Overview

##### Project Type & Purpose
- Full-stack web application for managing car rentals.
- Two main user roles: Customers (frontend) and Admin (backend).
- Built with PHP on Apache, MySQL database, and static assets (CSS/JS/images).

##### File Structure & Key Components
A. Presentation Layer
– carrental/index.php, car-listing.php, vehical-details.php, search.php, profile.php, etc. (public customer UI)
– carrental/admin/*.php (admin dashboard & management UI)
– carrental/assets/ (CSS, JS, images, fonts)
– carrental/includes/ (shared header, footer, login, registration, sidebar, config)

B. Application (Business Logic)
– PHP scripts that process form submissions (check_availability.php, post-testimonial.php)
– Admin scripts for CRUD operations on vehicles, bookings, brands, users.
– Shared configuration (includes/config.php) for database connection and global settings.

C. Data Layer
– MySQL database named “carrental” imported from carrental.sql
– Tables: vehicles, brands, bookings, users, testimonials, contacts, subscribers, etc.

D. Infrastructure
– Apache (or Nginx) web server running PHP
– Local environment: XAMPP/WAMP/LAMP stack
– Browser clients for public and admin interfaces

##### Extract Architectural Patterns
- Layered Architecture:
– Presentation (Views: PHP + HTML + CSS + JS)
– Business Logic (PHP controllers and includes)
– Data Access (SQL queries via PHP’s mysqli or PDO)
- Shared code through PHP includes for headers, footers, config
- No strict MVC framework but logical separation exists.

1. User’s Web Browser (Client)
– Sends HTTP requests for pages or AJAX calls.
2. Web Server (Apache + mod_php)
– Routes requests to appropriate PHP scripts in /carrental or /carrental/admin.
3. PHP Application Layer
– Presentation scripts (index.php, admin/*.php)
– Shared includes for authentication, layout, config
– Business logic modules for booking, user management
4. MySQL Database
– Stores all application data; accessed through config.php credentials
5. Static Asset Server
– Serves CSS/JS/images from /carrental/assets and /carrental/admin/css/js/img

- Browser → Web Server (HTTP GET/POST)
- Web Server → PHP Application → MySQL (queries/responses)
- PHP Application → Static Assets (on page load)
- Admin vs. Public user flows (separate entry points)

##### Detail Without Over-Splitting
- Logical component (frontend, backend scripts, includes, DB).
- Avoid drawing every single PHP file; instead group them by function (e.g., “Admin CRUD Scripts”).
- External dependencies (PHP, MySQL, Apache).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients
    BrowserCust(("Customer Browser")):::cloud
    BrowserAdmin(("Admin Browser")):::cloud

    %% Web Server
    WebServer["Web Server (Apache)"]:::component

    %% Public and Admin UI
    subgraph "Public Zone"
        PublicUI["Public Customer UI"]:::component
    end
    subgraph "Admin Zone"
        AdminUI["Admin Dashboard UI"]:::component
    end

    %% PHP Application Layer
    subgraph "PHP Application"
        PL["Includes & Config"]:::component
        BL1["Availability Checking"]:::component
        BL2["Testimonials Processing"]:::component
        BLAdminMgmt["Admin Management Modules"]:::component
    end

    %% Static Assets and Database
    StaticPublic["Public Static Assets"]:::static
    StaticAdmin["Admin Static Assets"]:::static
    DB[(MySQL Database)]:::database

    %% Data Flows
    BrowserCust -->|"HTTP GET/POST"| WebServer
    BrowserAdmin -->|"HTTP GET/POST"| WebServer
    WebServer -->|"routes to"| PublicUI
    WebServer -->|"routes to"| AdminUI
    PublicUI -->|"includes"| PL
    AdminUI -->|"includes"| PL
    PL -->|"invokes"| BL1
    PL -->|"invokes"| BL2
    PL -->|"invokes"| BLAdminMgmt
    BL1 -->|"SELECT/INSERT"| DB
    BL2 -->|"INSERT"| DB
    BLAdminMgmt -->|"CRUD SQL"| DB
    PublicUI -->|"loads assets"| StaticPublic
    AdminUI -->|"loads assets"| StaticAdmin
    DB -->|"SQL Responses"| PL

    %% Click Events
    click PublicUI "https://github.com/krishpatel09/car-rental/blob/main/carrental/index.php"
    click AdminUI "https://github.com/krishpatel09/car-rental/blob/main/carrental/admin/dashboard.php"
    click StaticPublic "https://github.com/krishpatel09/car-rental/tree/main/carrental/assets/"
    click StaticAdmin "https://github.com/krishpatel09/car-rental/tree/main/carrental/admin/css/"
    click PL "https://github.com/krishpatel09/car-rental/blob/main/carrental/includes/config.php"
    click BL1 "https://github.com/krishpatel09/car-rental/blob/main/carrental/check_availability.php"
    click BL2 "https://github.com/krishpatel09/car-rental/blob/main/carrental/post-testimonial.php"
    click BLAdminMgmt "https://github.com/krishpatel09/car-rental/blob/main/carrental/admin/manage-vehicles.php"

    %% Styles
    classDef cloud fill:#f39c12,stroke:#333,stroke-width:1px
    classDef component fill:#3498db,stroke:#333,stroke-width:1px
    classDef static fill:#95a5a6,stroke:#333,stroke-width:1px
    classDef database fill:#2ecc71,stroke:#333,stroke-width:1px
```
