# haseebshahbaz/morent_carrental_marketplace architecture

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

- Interactive diagram: https://gitdiagram.com/haseebshahbaz/morent_carrental_marketplace
- Repository: https://github.com/haseebshahbaz/morent_carrental_marketplace

## Overview

##### Main System Components

a) Frontend Layer:
- Next.js Application (Client-side)
- Components Structure
- Landing Page Components
- Admin Dashboard
- Authentication Components
- Car Details Components
- Payment Components
- Profile Management
- UI Components Library

b) Backend Layer:
- Next.js API Routes (/api)
- Authentication System (NextAuth.js)
- Sanity CMS Integration

c) Database Layer:
- Sanity.io (Content Management)
- Schema Types:
- Cars
- Bookings
- Reviews
- Customers
- Locations
- Admin

##### Component Relationships

a) Client-Server Flow:
- API routes handling different functionalities:
- Car Management
- Bookings
- Reviews
- Profile Updates
- Image Upload
- Search Functionality

b) Authentication Flow:
- NextAuth integration
- Sign-in process
- Protected routes
- Session management

c) Data Flow:
- Sanity Client interactions
- Image handling
- Real-time updates

##### Specific Implementation Details

Technical aspects:

a) Frontend Architecture:
- App Router structure (/src/app)
- Component hierarchy
- State management
- Client-side routing

b) API Layer:
- RESTful endpoints
- Authentication middleware
- Image upload handling
- Search functionality

a) User Interface Layer:
- Public pages (Home, Car Details, Category)
- Protected pages (Profile, Payment, Admin)
- Authentication views

b) Application Layer:
- API Routes
- Middleware
- Server-side functions

c) Data Layer:
- Sanity schemas
- Content management
- File storage

d) External Services:
- Authentication providers
- Image hosting
- Payment processing

##### Additional Notes

Aspects:

- Error handling flow
- Security measures
- Caching strategy
- Performance optimizations
- Scalability considerations

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        UI[User Interface]
        LP["Landing Page"]:::frontend
        AD["Admin Dashboard"]:::frontend
        AUTH["Authentication UI"]:::frontend
        CD["Car Details"]:::frontend
        PAY["Payment Interface"]:::frontend
        PROF["Profile Management"]:::frontend
        UICOMP["UI Component Library"]:::frontend
    end

    subgraph "API Layer"
        AUTHAPI["Authentication API"]:::api
        BOOKAPI["Bookings API"]:::api
        CARAPI["Cars API"]:::api
        REVAPI["Reviews API"]:::api
        PROFAPI["Profile API"]:::api
        SEARCHAPI["Search API"]:::api
        IMGAPI["Image Upload API"]:::api
    end

    subgraph "Sanity CMS"
        SCLIENT["Sanity Client"]:::sanity
        subgraph "Schema Types"
            CARS["Cars Schema"]:::schema
            BOOK["Bookings Schema"]:::schema
            REV["Reviews Schema"]:::schema
            CUST["Customers Schema"]:::schema
            LOC["Locations Schema"]:::schema
            ADMIN["Admin Schema"]:::schema
        end
    end

    subgraph "Core Infrastructure"
        MIDDLEWARE["Authentication Middleware"]:::core
        SESSION["Session Management"]:::core
        UTILS["Utility Functions"]:::core
        HOOKS["Custom Hooks"]:::core
    end

    subgraph "Main Routes"
        HOME["Home Page"]:::route
        CARDET["Car Details Page"]:::route
        PAYPROC["Payment Processing"]:::route
        USERPROF["User Profile"]:::route
        ADMINDASH["Admin Dashboard Page"]:::route
        AUTHPAGE["Authentication Page"]:::route
    end

    UI --> LP
    UI --> AD
    UI --> AUTH
    UI --> CD
    UI --> PAY
    UI --> PROF
    UI --> UICOMP

    LP --> CARAPI
    AD --> CARAPI
    CD --> CARAPI
    PAY --> BOOKAPI
    PROF --> PROFAPI
    
    AUTHAPI --> SCLIENT
    BOOKAPI --> SCLIENT
    CARAPI --> SCLIENT
    REVAPI --> SCLIENT
    PROFAPI --> SCLIENT
    SEARCHAPI --> SCLIENT
    IMGAPI --> SCLIENT

    SCLIENT --> CARS
    SCLIENT --> BOOK
    SCLIENT --> REV
    SCLIENT --> CUST
    SCLIENT --> LOC
    SCLIENT --> ADMIN

    MIDDLEWARE --> SESSION
    SESSION --> AUTHAPI

    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef api fill:#2ecc71,stroke:#27ae60,color:white
    classDef sanity fill:#e74c3c,stroke:#c0392b,color:white
    classDef schema fill:#f1c40f,stroke:#f39c12,color:black
    classDef core fill:#9b59b6,stroke:#8e44ad,color:white
    classDef route fill:#1abc9c,stroke:#16a085,color:white

    click LP "https://github.com/haseebshahbaz/Morent_CarRental_Marketplace/tree/main/src/components/landingpage/"
    click AD "https://github.com/haseebshahbaz/Morent_CarRental_Marketplace/tree/main/src/components/admin/"
    click AUTH "https://github.com/haseebshahbaz/Morent_CarRental_Marketplace/tree/main/src/components/auth/"
    click CD "https://github.com/haseebshahbaz/Morent_CarRental_Marketplace/tree/main/src/components/car-detail/"
    click PAY "https://github.com/haseebshahbaz/Morent_CarRental_Marketplace/tree/main/src/components/payment/"
    click PROF "https://github.com/haseebshahbaz/Morent_CarRental_Marketplace/tree/main/src/components/profile/"
    click UICOMP "https://github.com/haseebshahbaz/Morent_CarRental_Marketplace/tree/main/src/components/ui/"
    
    click AUTHAPI "https://github.com/haseebshahbaz/Morent_CarRental_Marketplace/blob/main/src/app/api/auth/[...nextauth]/route.ts"
    click BOOKAPI "https://github.com/haseebshahbaz/Morent_CarRental_Marketplace/blob/main/src/app/api/bookings/route.ts"
    click CARAPI "https://github.com/haseebshahbaz/Morent_CarRental_Marketplace/blob/main/src/app/api/cars/route.ts"
    click REVAPI "https://github.com/haseebshahbaz/Morent_CarRental_Marketplace/blob/main/src/app/api/reviews/route.ts"
    click PROFAPI "https://github.com/haseebshahbaz/Morent_CarRental_Marketplace/blob/main/src/app/api/update-profile/route.ts"
    click SEARCHAPI "https://github.com/haseebshahbaz/Morent_CarRental_Marketplace/blob/main/src/app/api/search-cars/route.ts"
    click IMGAPI "https://github.com/haseebshahbaz/Morent_CarRental_Marketplace/blob/main/src/app/api/upload-image/route.ts"
    
    click SCLIENT "https://github.com/haseebshahbaz/Morent_CarRental_Marketplace/blob/main/src/sanity/lib/client.ts"
    click CARS "https://github.com/haseebshahbaz/Morent_CarRental_Marketplace/blob/main/src/sanity/schemaTypes/car.ts"
    click BOOK "https://github.com/haseebshahbaz/Morent_CarRental_Marketplace/blob/main/src/sanity/schemaTypes/booking.ts"
    click REV "https://github.com/haseebshahbaz/Morent_CarRental_Marketplace/blob/main/src/sanity/schemaTypes/review.ts"
    click CUST "https://github.com/haseebshahbaz/Morent_CarRental_Marketplace/blob/main/src/sanity/schemaTypes/customer.ts"
    click LOC "https://github.com/haseebshahbaz/Morent_CarRental_Marketplace/blob/main/src/sanity/schemaTypes/location.ts"
    click ADMIN "https://github.com/haseebshahbaz/Morent_CarRental_Marketplace/blob/main/src/sanity/schemaTypes/adminType.ts"
    
    click HOME "https://github.com/haseebshahbaz/Morent_CarRental_Marketplace/blob/main/src/app/page.tsx"
    click CARDET "https://github.com/haseebshahbaz/Morent_CarRental_Marketplace/blob/main/src/app/cars/[id]/page.tsx"
    click PAYPROC "https://github.com/haseebshahbaz/Morent_CarRental_Marketplace/blob/main/src/app/payment/[id]/page.tsx"
    click USERPROF "https://github.com/haseebshahbaz/Morent_CarRental_Marketplace/blob/main/src/app/profile/page.tsx"
    click ADMINDASH "https://github.com/haseebshahbaz/Morent_CarRental_Marketplace/blob/main/src/app/admin/page.tsx"
    click AUTHPAGE "https://github.com/haseebshahbaz/Morent_CarRental_Marketplace/blob/main/src/app/auth/signin/page.tsx"
    
    click MIDDLEWARE "https://github.com/haseebshahbaz/Morent_CarRental_Marketplace/blob/main/middleware.ts"
    click SESSION "https://github.com/haseebshahbaz/Morent_CarRental_Marketplace/blob/main/src/components/providers/session-providers.tsx"
    click UTILS "https://github.com/haseebshahbaz/Morent_CarRental_Marketplace/blob/main/src/lib/utils.ts"
    click HOOKS "https://github.com/haseebshahbaz/Morent_CarRental_Marketplace/tree/main/src/hooks/"
```
