# yxshee/mapmitra architecture

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

- Interactive diagram: https://gitdiagram.com/yxshee/mapmitra
- Repository: https://github.com/yxshee/mapmitra

## Overview

##### Main Components Identification

a. Frontend Layer:
- React.js application (in /frontend)
- User interface components (navigation, maps, authentication)
- Client-side routing and state management

b. Backend Services:
- Main Backend (Node.js/Express - in /backend)
- Routing Backend (Python - in /routing-backend)
- Quinjet Service (Go - in /quinjet)

c. Data Stores:
- MongoDB (primary database)
- Redis (caching layer)

d. External Services:
- OpenStreetMap integration
- Socket.io for real-time communication

**[Client Layer]**
- ↕
**[Load Balancer/API Gateway]**
- ↕
**[Application Services Layer]**
- ↕
**[Data Layer]**

##### Detailed Component Breakdown

Frontend (React.js):
- Main components:
- Navigation Interface
- Component
- Authentication Components
- Real-time Tracking Interface
- Admin Dashboard

Backend Services:
- Main Backend:
- Auth Controllers
- User Controllers
- Middleware Layer
- API Routes

- Routing Backend:
- GraphHopper Integration
- Landmark-based Navigation
- Route Optimization

- Quinjet Service:
- Ride Management
- Health Monitoring
- Worker Processes

##### Data Flow Representation

Following interactions:
- User authentication flow
- Real-time e-rickshaw tracking
- Navigation requests
- Admin management operations

##### Additional Elements

Include:
- System boundaries
- Security layers (authentication/authorization)
- Scaling components (load balancers, caches)

##### Technical Details

- Socket.io connections for real-time updates
- Redis caching layer implementation
- MongoDB database connections
- API endpoints and their relationships
- Authentication flow with Passport.js
- GraphHopper integration for routing

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        FE["Frontend App"]:::frontend
        MAP["Map Interface"]:::frontend
        AUTH["Auth Components"]:::frontend
        NAV["Navigation Components"]:::frontend
        ADMIN["Admin Interface"]:::frontend
        ROUTE["Route Control"]:::frontend
        AXIOS["API Config"]:::frontend
    end

    subgraph "API Gateway"
        LB[Load Balancer]:::gateway
    end

    subgraph "Backend Services"
        BE["Main Backend"]:::backend
        RB["Routing Backend"]:::backend
        QJ["Quinjet Service"]:::backend
        
        subgraph "Main Backend Components"
            AC["Auth Controllers"]:::backend
            UC["User Controllers"]:::backend
            AM["Auth Middleware"]:::backend
            RM["Role Middleware"]:::backend
            AR["Auth Routes"]:::backend
            UR["User Routes"]:::backend
        end
        
        subgraph "Routing Backend Components"
            LN["Landmark Navigation"]:::backend
            GH["GraphHopper Integration"]:::backend
        end
        
        subgraph "Quinjet Components"
            RMS["Ride Management"]:::backend
            HM["Health Monitoring"]:::backend
            WP["Worker Process"]:::backend
        end
    end

    subgraph "Data Stores"
        MONGO[(MongoDB)]:::database
        REDIS[(Redis Cache)]:::database
    end

    subgraph "External Services"
        OSM{"OpenStreetMap"}:::external
        SOCKET{"Socket.io"}:::external
    end

    %% Connections
    FE --> |API Requests| LB
    MAP --> |Map Data| OSM
    LB --> BE
    LB --> RB
    LB --> QJ
    BE --> MONGO
    BE --> REDIS
    RB --> GH
    QJ --> SOCKET
    SOCKET --> FE

    %% Styling
    classDef frontend fill:#3498db
    classDef backend fill:#2ecc71
    classDef database fill:#9b59b6
    classDef external fill:#f1c40f
    classDef gateway fill:#e74c3c

    %% Click Events
    click FE "https://github.com/yxshee/mapmitra/blob/main/frontend/src/App.jsx"
    click MAP "https://github.com/yxshee/mapmitra/blob/main/frontend/src/components/MapComponent.jsx"
    click AUTH "https://github.com/yxshee/mapmitra/blob/main/frontend/src/components/Login.jsx"
    click ADMIN "https://github.com/yxshee/mapmitra/blob/main/frontend/src/pages/Admin.jsx"
    click ROUTE "https://github.com/yxshee/mapmitra/blob/main/frontend/src/components/RoutingControl.jsx"
    click AXIOS "https://github.com/yxshee/mapmitra/blob/main/frontend/src/utils/axiosInstance.js"
    click BE "https://github.com/yxshee/mapmitra/blob/main/backend/src/app.js"
    click AC "https://github.com/yxshee/mapmitra/blob/main/backend/src/controllers/auth.controllers.js"
    click UC "https://github.com/yxshee/mapmitra/blob/main/backend/src/controllers/user.controllers.js"
    click AM "https://github.com/yxshee/mapmitra/blob/main/backend/src/middlewares/auth.middlewares.js"
    click RM "https://github.com/yxshee/mapmitra/blob/main/backend/src/middlewares/authorizeRoles.middlewares.js"
    click AR "https://github.com/yxshee/mapmitra/blob/main/backend/src/routes/auth.routes.js"
    click UR "https://github.com/yxshee/mapmitra/blob/main/backend/src/routes/user.routes.js"
    click RB "https://github.com/yxshee/mapmitra/blob/main/routing-backend/api/app.py"
    click LN "https://github.com/yxshee/mapmitra/blob/main/routing-backend/api/landmark.py"
    click GH "https://github.com/yxshee/mapmitra/blob/main/routing-backend/graphhopper/config.yml"
    click QJ "https://github.com/yxshee/mapmitra/blob/main/quinjet/cmd/main.go"
    click RMS "https://github.com/yxshee/mapmitra/blob/main/quinjet/internal/services/rides/rides.go"
    click HM "https://github.com/yxshee/mapmitra/blob/main/quinjet/internal/services/health/health.go"
    click WP "https://github.com/yxshee/mapmitra/blob/main/quinjet/cmd/worker/worker.go"
```
