# meghasajup/car_rental-frontend architecture

> Architecture diagram of the GitHub repository meghasajup/car_rental-frontend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/meghasajup/car_rental-frontend
- Repository: https://github.com/meghasajup/car_rental-frontend

## Overview

##### Main System Components

a) Frontend Architecture (Client-Side):
- Divide it into these sub-components:
- Layout Layer (RootLayout, AdminLayout, UserLayout)
- Components Layer (UI, Admin, User components)
- Pages Layer (Admin and User pages)
- Services Layer (API integration)
- Routes Layer (Protected and Public routes)

##### Component Relationships

Create these sections with appropriate connections:

a) User Interface Layer:
- To protected user interfaces (ProfilePage, Wishlist, etc.)
- Admin interfaces separately (AdminCarManagement, AdminBookingManagement, etc.)

b) Authentication Flow:
- Auth flow through UserAuth and AdminAuth components
- How protected routes interact with auth components

##### Data Flow Architecture

Data flow with these elements:

a) API Integration:
- AxiosInstance configuration
- UserApi and adminApi services to respective components
- External service connections (payment processing for PaymentSuccess/Cancel)

##### Specific Implementation Details

- 🟦 Blue rectangles for layout components
- 🟩 Green rectangles for page components
- 🟨 Yellow rectangles for shared UI components
- 🟥 Red rectangles for protected routes
- ⬡ Hexagons for service layers

##### Key Features to Highlight

Create sections showing:

a) Admin Features:
- Car Management
- Booking Management
- User Management
- Report Management
- Review Management

b) User Features:
- Car Booking
- Payment Processing
- Profile Management
- Wishlist
- Reviews/Testimonials

##### Technical Stack Indicators

- React + Vite
- Tailwind CSS
- Axios for API calls
- Protected Route Implementation
- Dark Mode Implementation

**┌─ User Interface Layer ─┐**
- ┌─ Components Layer ─┐ │
- ┌─ Services Layer┐ │ │
- Core Logic  │ │ │
- ┘ │ │
- ┘ │
- ┘

##### Dark mode toggle functionality across the application

Remember to:
- Related components together
- Clear boundaries between admin and user sections
- State management and data flow clearly
- Error handling paths (ErrorPage component)
- How layouts wrap different sections of the application

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Frontend React + Vite"
        subgraph "Layout Layer"
            RootLayout["Root Layout"]:::layout
            AdminLayout["Admin Layout"]:::layout
            UserLayout["User Layout"]:::layout
        end

        subgraph "Components Layer"
            UI["UI Components"]:::component
            AdminComp["Admin Components"]:::component
            UserComp["User Components"]:::component
            DarkMode["Dark Mode Toggle"]:::component
        end

        subgraph "Authentication"
            UserAuth["User Authentication"]:::auth
            AdminAuth["Admin Authentication"]:::auth
        end

        subgraph "API Integration"
            AxiosConfig["Axios Configuration"]:::service
            AdminAPI["Admin API Service"]:::service
            UserAPI["User API Service"]:::service
        end

        subgraph "Admin Features"
            CarManagement["Car Management"]:::admin
            BookingManagement["Booking Management"]:::admin
            UserManagement["User Management"]:::admin
            ReportManagement["Report Management"]:::admin
            ReviewManagement["Review Management"]:::admin
        end

        subgraph "User Features"
            CarBooking["Car Booking"]:::user
            PaymentSuccess["Payment Success"]:::user
            PaymentCancel["Payment Cancel"]:::user
            Profile["Profile Management"]:::user
            Wishlist["Wishlist"]:::user
            Testimonials["Reviews/Testimonials"]:::user
        end

        subgraph "Core Pages"
            HomePage["Home Page"]:::page
            CarPage["Car Page"]:::page
            CarDetails["Car Details"]:::page
            CarDashboard["Car Dashboard"]:::page
            ErrorPage["Error Page"]:::page
        end

        subgraph "Routes"
            MainRoutes["Main Routes"]:::route
        end
    end

    %% Relationships
    RootLayout --> AdminLayout & UserLayout
    AdminLayout --> AdminComp
    UserLayout --> UserComp
    UserAuth --> UserFeatures
    AdminAuth --> AdminFeatures
    AxiosConfig --> AdminAPI & UserAPI
    MainRoutes --> UserAuth & AdminAuth
    UI --> DarkMode

    %% Click Events
    click RootLayout "https://github.com/meghasajup/car_rental-frontend/blob/main/src/layout/RootLayout.jsx"
    click AdminLayout "https://github.com/meghasajup/car_rental-frontend/blob/main/src/layout/AdminLayout.jsx"
    click UserLayout "https://github.com/meghasajup/car_rental-frontend/blob/main/src/layout/UserLayout.jsx"
    click UI "https://github.com/meghasajup/car_rental-frontend/tree/main/src/components/ui/"
    click AdminComp "https://github.com/meghasajup/car_rental-frontend/tree/main/src/components/admin/"
    click UserComp "https://github.com/meghasajup/car_rental-frontend/tree/main/src/components/user/"
    click DarkMode "https://github.com/meghasajup/car_rental-frontend/blob/main/src/components/ui/DarkMode.jsx"
    click UserAuth "https://github.com/meghasajup/car_rental-frontend/blob/main/src/routes/protectedRoutes/UserAuth.jsx"
    click AdminAuth "https://github.com/meghasajup/car_rental-frontend/blob/main/src/routes/protectedRoutes/AdminAuth.jsx"
    click AxiosConfig "https://github.com/meghasajup/car_rental-frontend/blob/main/src/config/axiosInstance.js"
    click AdminAPI "https://github.com/meghasajup/car_rental-frontend/blob/main/src/services/adminApi.js"
    click UserAPI "https://github.com/meghasajup/car_rental-frontend/blob/main/src/services/userApi.js"
    click CarManagement "https://github.com/meghasajup/car_rental-frontend/blob/main/src/pages/admin/AdminCarManagement.jsx"
    click BookingManagement "https://github.com/meghasajup/car_rental-frontend/blob/main/src/pages/admin/AdminBookingManagement.jsx"
    click UserManagement "https://github.com/meghasajup/car_rental-frontend/blob/main/src/pages/admin/AdminUserManagement.jsx"
    click ReportManagement "https://github.com/meghasajup/car_rental-frontend/blob/main/src/pages/admin/AdminReportManagement.jsx"
    click ReviewManagement "https://github.com/meghasajup/car_rental-frontend/blob/main/src/pages/admin/AdminReviewManagement.jsx"
    click CarBooking "https://github.com/meghasajup/car_rental-frontend/blob/main/src/pages/user/BookingPage.jsx"
    click PaymentSuccess "https://github.com/meghasajup/car_rental-frontend/blob/main/src/pages/user/PaymentSuccess.jsx"
    click PaymentCancel "https://github.com/meghasajup/car_rental-frontend/blob/main/src/pages/user/PaymentCancel.jsx"
    click Profile "https://github.com/meghasajup/car_rental-frontend/blob/main/src/pages/user/ProfilePage.jsx"
    click Wishlist "https://github.com/meghasajup/car_rental-frontend/blob/main/src/pages/user/Wishlist.jsx"
    click Testimonials "https://github.com/meghasajup/car_rental-frontend/blob/main/src/pages/user/TestimonialsPage.jsx"
    click HomePage "https://github.com/meghasajup/car_rental-frontend/blob/main/src/pages/user/HomePage.jsx"
    click CarPage "https://github.com/meghasajup/car_rental-frontend/blob/main/src/pages/user/CarPage.jsx"
    click CarDetails "https://github.com/meghasajup/car_rental-frontend/blob/main/src/pages/user/CarDetails.jsx"
    click CarDashboard "https://github.com/meghasajup/car_rental-frontend/blob/main/src/pages/user/CarDashboard.jsx"
    click ErrorPage "https://github.com/meghasajup/car_rental-frontend/blob/main/src/pages/user/ErrorPage.jsx"
    click MainRoutes "https://github.com/meghasajup/car_rental-frontend/blob/main/src/routes/Route.jsx"

    %% Styles
    classDef layout fill:#2196F3,stroke:#1565C0,color:white
    classDef component fill:#4CAF50,stroke:#2E7D32,color:white
    classDef auth fill:#F44336,stroke:#C62828,color:white
    classDef service fill:#FF9800,stroke:#EF6C00,color:white
    classDef admin fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef user fill:#00BCD4,stroke:#00838F,color:white
    classDef page fill:#8BC34A,stroke:#558B2F,color:white
    classDef route fill:#795548,stroke:#4E342E,color:white
```
