# nitansh11/redbus architecture

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

- Interactive diagram: https://gitdiagram.com/nitansh11/redbus
- Repository: https://github.com/nitansh11/redbus

## Overview

##### Main Components

a. Frontend Layer:
- React Application (Client-Side)
- Core Components:
- Landing Page
- Bus Booking System
- Bus Hire System
- Payment Integration
- Authentication
- State Management (Redux Store)
- Auth
- Bus Service
- Routes
- Booking
- Filters/Sort

b. Backend Layer:
- Express.js Server
- API Controllers:
- Booking
- Bus
- Customer
- Route
- Bus Service
- Database Models (MongoDB/Mongoose)

c. External Services:
- Google Authentication
- Stripe Payment Gateway
- MongoDB Database

##### Specific Elements

Frontend Layer:
**[React Client]**
- Components
- Landing Page
- Bus Booking
- Bus Hire
- Payment
- Redux Store
- Auth State
- Booking State
- Route State

Backend Layer:
**[Express Server]**
- API Routes
- Controllers
- Models
- Middleware

##### Data Flow Representation

- User interaction flow:
1. User Authentication → Google Auth
2. Bus Search → Routes API
3. Booking Flow → Booking API
4. Payment Processing → Stripe
5. Data Persistence → MongoDB

##### Important Architectural Patterns to Highlight

- MVC Pattern in Backend
- Redux State Management
- RESTful API Architecture
- Microservices-like separation of concerns

##### Integration Points

- Google Authentication flow
- Stripe Payment integration
- Database connections
- API endpoints

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef external fill:#f1c40f,stroke:#f39c12,color:white
    classDef auth fill:#e74c3c,stroke:#c0392b,color:white

    %% Frontend Layer
    subgraph Frontend
        Client["React Client"]
        
        subgraph Components
            Landing["Landing Page"]
            BusBook["Bus Booking"]
            BusHire["Bus Hire"]
            Payment["Payment"]
        end

        subgraph ReduxStore["Redux Store"]
            AuthState["Auth State"]
            BookingState["Booking State"]
            RouteState["Route State"]
            BusState["Bus Service State"]
            FilterState["Filters/Sort State"]
        end
    end

    %% Backend Layer
    subgraph Backend
        Express["Express Server"]
        
        subgraph Controllers
            BookingCtrl["Booking Controller"]
            BusCtrl["Bus Controller"]
            CustomerCtrl["Customer Controller"]
            RouteCtrl["Route Controller"]
            BusServiceCtrl["Bus Service Controller"]
        end

        subgraph Models
            BookingModel["Booking Model"]
            BusModel["Bus Model"]
            CustomerModel["Customer Model"]
            RouteModel["Route Model"]
            BusServiceModel["Bus Service Model"]
        end
    end

    %% External Services
    subgraph External
        Google["Google Auth"]
        Stripe["Stripe Payment"]
        MongoDB[(MongoDB Database)]
    end

    %% Relationships
    Client --> Express
    Landing --> AuthState
    BusBook --> BookingState
    BusHire --> BusState
    Payment --> Stripe

    Express --> Controllers
    Controllers --> Models
    Models --> MongoDB

    AuthState --> Google
    BookingState --> BookingCtrl
    RouteState --> RouteCtrl
    BusState --> BusServiceCtrl

    %% Click Events
    click Landing "https://github.com/nitansh11/redbus/blob/master/front-end-redbus/src/Components/LandingPage/LandingPage.jsx"
    click BusBook "https://github.com/nitansh11/redbus/blob/master/front-end-redbus/src/Components/Bus Booking Form/BusBookingForm.jsx"
    click BusHire "https://github.com/nitansh11/redbus/blob/master/front-end-redbus/src/Components/Bus hire Main Page/BusHire.jsx"
    click Payment "https://github.com/nitansh11/redbus/blob/master/front-end-redbus/src/Components/Payment Page/Payment.jsx"
    click AuthState "https://github.com/nitansh11/redbus/tree/master/front-end-redbus/src/Redux/auth"
    click BusState "https://github.com/nitansh11/redbus/tree/master/front-end-redbus/src/Redux/busService"
    click RouteState "https://github.com/nitansh11/redbus/tree/master/front-end-redbus/src/Redux/routes"
    click BookingState "https://github.com/nitansh11/redbus/tree/master/front-end-redbus/src/Redux/BookBus"
    click FilterState "https://github.com/nitansh11/redbus/tree/master/front-end-redbus/src/Redux/FilterAndSort"
    click Express "https://github.com/nitansh11/redbus/blob/master/back-end-redbus/app.js"
    click BookingCtrl "https://github.com/nitansh11/redbus/blob/master/back-end-redbus/controllers/booking.js"
    click BusCtrl "https://github.com/nitansh11/redbus/blob/master/back-end-redbus/controllers/bus.js"
    click CustomerCtrl "https://github.com/nitansh11/redbus/blob/master/back-end-redbus/controllers/customer.js"
    click RouteCtrl "https://github.com/nitansh11/redbus/blob/master/back-end-redbus/controllers/route.js"
    click BusServiceCtrl "https://github.com/nitansh11/redbus/blob/master/back-end-redbus/controllers/busservice.js"
    click BookingModel "https://github.com/nitansh11/redbus/blob/master/back-end-redbus/models/boooking.js"
    click BusModel "https://github.com/nitansh11/redbus/blob/master/back-end-redbus/models/bus.js"
    click CustomerModel "https://github.com/nitansh11/redbus/blob/master/back-end-redbus/models/customer.js"
    click RouteModel "https://github.com/nitansh11/redbus/blob/master/back-end-redbus/models/route.js"
    click BusServiceModel "https://github.com/nitansh11/redbus/blob/master/back-end-redbus/models/busService.js"

    %% Style Applications
    class Client,Components,Landing,BusBook,BusHire,Payment frontend
    class Express,Controllers,BookingCtrl,BusCtrl,CustomerCtrl,RouteCtrl,BusServiceCtrl backend
    class MongoDB database
    class Google,Stripe external
    class AuthState auth
```
