# divyanshu2003singh/trip-tide architecture

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

- Interactive diagram: https://gitdiagram.com/divyanshu2003singh/trip-tide
- Repository: https://github.com/divyanshu2003singh/trip-tide

## Overview

##### Project type and purpose
- Triptide is a full-stack MERN (MongoDB, Express, React, Node) ride-sharing application.
- Purpose: allow customers to create ride requests, drivers to accept and manage rides, with real-time updates, geospatial filtering (5 km radius via Mapbox), and post-ride rating.

##### File structure
- Top-level directories:
- Backend/
– Controller: commonController.js, rideController.js, userController.js
– Router: commonRouter.js, rideRouter.js, userRouter.js
– Model: config.js, rideModel.js, userModel.js
– Middleware: userAuth.js
– util: rideUtil.js
- Frontend/
– public/: index.html, _redirects
– src/: index.js, pages/… (React component per page)
- Pattern:
- Backend follows MVC (Models, Controllers, Routers) plus a middleware layer and utilities.
- Frontend uses component-based React pages and static assets under public.

##### README for additional insights
- Key technologies: MongoDB, Express.js, React.js, Node.js, Socket.io, Mapbox API, JWT.
- Features: user auth, create/accept rides, real-time updates via Socket.io, rating system, ride status updates.
- External dependencies: Mapbox for geolocation/distance, JWT for auth tokens, real-time channel via WebSocket.

##### Detail without over-fragmenting
- Major page in the Frontend cluster if desired (Login, Signup, Map view, Ride list).
- Don’t omit the .env config (PORT, MONGODB_URI, JWT_SECRET) – indicate configuration as a note or side artifact.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (React Client)" 
        direction TB
        FEIndex["src/index.js"]:::frontend
        FEHTML["public/index.html"]:::frontend
        subgraph "Pages"
            direction TB
            Login["Login"]:::frontend
            Signup["Signup"]:::frontend
            CreateRidePage["CreateRidePage"]:::frontend
            ListRides["ListRides"]:::frontend
            FetchRideDetailsPage["FetchRideDetailsPage"]:::frontend
            DefineUser["DefineUser"]:::frontend
            AppBar["AppBar"]:::frontend
            ErrorPage["ErrorPage"]:::frontend
            GoogleAuth["google.jsx"]:::frontend
        end
    end

    %% Backend Layer
    subgraph "Backend (Express API Server)"
        direction TB
        subgraph "Routers"
            direction TB
            UserRouter["userRouter.js"]:::backend
            RideRouter["rideRouter.js"]:::backend
            CommonRouter["commonRouter.js"]:::backend
        end
        subgraph "Middleware"
            direction TB
            Middleware["userAuth.js"]:::backend
        end
        subgraph "Controllers"
            direction TB
            UserController["userController.js"]:::backend
            RideController["rideController.js"]:::backend
            CommonController["commonController.js"]:::backend
        end
        subgraph "Models"
            direction TB
            UserModel["userModel.js"]:::backend
            RideModel["rideModel.js"]:::backend
            Config["config.js"]:::backend
        end
        Util["rideUtil.js"]:::backend
    end

    %% Database and External Services
    DB[(MongoDB)]:::db
    MapboxAPI["Mapbox API"]:::external
    SocketIO["Socket.io Channel"]:::external

    %% Connections
    FEIndex -->|REST API| UserRouter
    FEIndex -->|REST API| RideRouter
    FEIndex -->|REST API| CommonRouter
    FEIndex -->|WebSocket| SocketIO

    Login --> FEIndex
    Signup --> FEIndex
    CreateRidePage --> FEIndex
    ListRides --> FEIndex
    FetchRideDetailsPage --> FEIndex
    DefineUser --> FEIndex
    AppBar --> FEIndex
    ErrorPage --> FEIndex
    GoogleAuth --> FEIndex

    UserRouter -->|uses| Middleware
    RideRouter -->|uses| Middleware
    CommonRouter -->|uses| Middleware

    Middleware --> UserController
    Middleware --> RideController
    Middleware --> CommonController

    UserController --> UserModel
    RideController --> RideModel
    CommonController --> Config

    UserController -->|CRUD| DB
    RideController -->|CRUD| DB
    CommonController -->|uses| DB

    RideController -->|uses| Util
    Util --> MapboxAPI

    RideController -->|emits events| SocketIO
    SocketIO -->|push updates| FEIndex

    %% Click Events
    click FEIndex "https://github.com/divyanshu2003singh/trip-tide/blob/main/Frontend/src/index.js"
    click FEHTML "https://github.com/divyanshu2003singh/trip-tide/blob/main/Frontend/public/index.html"
    click Login "https://github.com/divyanshu2003singh/trip-tide/blob/main/Frontend/src/pages/Login.jsx"
    click Signup "https://github.com/divyanshu2003singh/trip-tide/blob/main/Frontend/src/pages/Signup.jsx"
    click CreateRidePage "https://github.com/divyanshu2003singh/trip-tide/blob/main/Frontend/src/pages/CreateRidePage.jsx"
    click ListRides "https://github.com/divyanshu2003singh/trip-tide/blob/main/Frontend/src/pages/ListRides.jsx"
    click FetchRideDetailsPage "https://github.com/divyanshu2003singh/trip-tide/blob/main/Frontend/src/pages/FetchRideDetailsPage.jsx"
    click DefineUser "https://github.com/divyanshu2003singh/trip-tide/blob/main/Frontend/src/pages/DefineUser.jsx"
    click AppBar "https://github.com/divyanshu2003singh/trip-tide/blob/main/Frontend/src/pages/AppBar.jsx"
    click ErrorPage "https://github.com/divyanshu2003singh/trip-tide/blob/main/Frontend/src/pages/ErrorPage.jsx"
    click GoogleAuth "https://github.com/divyanshu2003singh/trip-tide/blob/main/Frontend/src/pages/google.jsx"

    click UserRouter "https://github.com/divyanshu2003singh/trip-tide/blob/main/Backend/Router/userRouter.js"
    click RideRouter "https://github.com/divyanshu2003singh/trip-tide/blob/main/Backend/Router/rideRouter.js"
    click CommonRouter "https://github.com/divyanshu2003singh/trip-tide/blob/main/Backend/Router/commonRouter.js"

    click UserController "https://github.com/divyanshu2003singh/trip-tide/blob/main/Backend/Controller/userController.js"
    click RideController "https://github.com/divyanshu2003singh/trip-tide/blob/main/Backend/Controller/rideController.js"
    click CommonController "https://github.com/divyanshu2003singh/trip-tide/blob/main/Backend/Controller/commonController.js"

    click UserModel "https://github.com/divyanshu2003singh/trip-tide/blob/main/Backend/Model/userModel.js"
    click RideModel "https://github.com/divyanshu2003singh/trip-tide/blob/main/Backend/Model/rideModel.js"
    click Config "https://github.com/divyanshu2003singh/trip-tide/blob/main/Backend/Model/config.js"

    click Middleware "https://github.com/divyanshu2003singh/trip-tide/blob/main/Backend/Middleware/userAuth.js"
    click Util "https://github.com/divyanshu2003singh/trip-tide/blob/main/Backend/util/rideUtil.js"

    %% Styles
    classDef frontend fill:#D0E6FF,stroke:#0366d6,color:#0366d6
    classDef backend fill:#E6F4EA,stroke:#28a745,color:#22863a
    classDef db fill:#FEE8E6,stroke:#cb2431,color:#cb2431
    classDef external fill:#FFF5B1,stroke:#d29922,color:#d29922
```
