# asitharamesh/lyft-clone architecture

> Architecture diagram of the GitHub repository asitharamesh/lyft-clone, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/asitharamesh/lyft-clone
- Repository: https://github.com/asitharamesh/lyft-clone

## Overview

This repository is a ride-sharing and food-delivery simulation, with rider and driver web apps backed by Flask REST and Socket.IO. The main journey is a rider request, route/fare calculation, nearby-driver matching and private offer, acceptance and persisted trip state, then room-scoped updates from the driver or selected simulator. Food ordering, authentication, admin operations, and health checks are separate product capabilities. The graph uses documented flows and visible imports/calls; some socket dispatch details and simulator wiring are described by the README rather than sampled implementation.

Main entry points: [`backend/sockets/handlers.py`](https://github.com/asitharamesh/lyft-clone/blob/main/backend/sockets/handlers.py) (Socket handlers), [`backend/app.py`](https://github.com/asitharamesh/lyft-clone/blob/main/backend/app.py) (Flask REST), [`backend/routes/admin_routes.py`](https://github.com/asitharamesh/lyft-clone/blob/main/backend/routes/admin_routes.py) (Admin API), [`backend/db.py`](https://github.com/asitharamesh/lyft-clone/blob/main/backend/db.py) (PostgreSQL)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web clients"]
  node_rider["Rider app<br/>[new_map.html]"]
  node_driver["Driver app"]
  node_adminui["Admin dashboard<br/>[admin.html]"]
end

subgraph group_api["Backend interfaces"]
  node_rest["Flask REST<br/>[app.py]"]
  node_authroutes["Authentication routes<br/>[auth_routes.py]"]
  node_menu["Menu and fare API<br/>[menu_routes.py]"]
  node_health["Health API<br/>[health_routes.py]"]
  node_admin["Admin API<br/>[admin_routes.py]"]
  node_sockets["Socket handlers<br/>[handlers.py]"]
end

subgraph group_domain["Ride services"]
  node_auth["Auth service<br/>[auth_service.py]"]
  node_matching["Driver matching"]
  node_rides["Ride lifecycle<br/>[ride_service.py]"]
  node_routing["Road routing<br/>[routing_service.py]"]
  node_pricing["Fare pricing<br/>[pricing_service.py]"]
  node_simulator["Ride simulator"]
end

subgraph group_state["Persistence and realtime state"]
  node_pg[("PostgreSQL<br/>[db.py]")]
  node_redis[("Redis state<br/>[db.py]")]
  node_socketio["Socket.IO<br/>[extensions.py]"]
  node_osrm["OSRM routing"]
end

subgraph group_ops["Operations"]
  node_stats["Operational statistics<br/>[ops_stats.py]"]
end

node_opsactor(("Admin user"))

node_rest -->|"registers routes"| node_authroutes
node_rest -->|"registers routes"| node_menu
node_rest -->|"registers routes"| node_health
node_rest -->|"registers routes"| node_admin
node_rest -->|"initializes"| node_socketio
node_rider -.->|"requests API"| node_rest
node_driver -.->|"sends events"| node_sockets
node_rider -.->|"requests rides"| node_sockets
node_authroutes -->|"hashes and issues tokens"| node_auth
node_authroutes -->|"reads and writes accounts"| node_pg
node_menu -->|"reads menus"| node_pg
node_menu -->|"calculates routes"| node_routing
node_menu -->|"builds fare"| node_pricing
node_sockets -->|"finds drivers"| node_matching
node_sockets -->|"manages ride state"| node_rides
node_sockets -->|"calculates trip routes"| node_routing
node_sockets -->|"calculates fares"| node_pricing
node_matching -->|"reads driver profiles"| node_pg
node_matching -->|"queries GEO index"| node_redis
node_rides -->|"persists lifecycle"| node_pg
node_routing -->|"requests road routes"| node_osrm
node_routing -->|"falls back to haversine"| node_routing
node_sockets -->|"emits room updates"| node_socketio
node_socketio -->|"publishes events"| node_redis
node_sockets -.->|"starts simulation"| node_simulator
node_simulator -.->|"reports trip updates"| node_sockets
node_health -->|"checks readiness"| node_pg
node_adminui -.->|"requests operations data"| node_admin
node_opsactor -.->|"views operations"| node_admin
node_admin -->|"reads operations data"| node_pg
node_admin -->|"reads driver state"| node_redis
node_admin -->|"reads counters"| node_stats
node_stats -->|"stores counters"| node_redis

click node_rider "https://github.com/asitharamesh/lyft-clone/blob/main/frontend/new_map.html"
click node_driver "https://github.com/asitharamesh/lyft-clone/tree/main/backend"
click node_adminui "https://github.com/asitharamesh/lyft-clone/blob/main/frontend/admin.html"
click node_rest "https://github.com/asitharamesh/lyft-clone/blob/main/backend/app.py"
click node_authroutes "https://github.com/asitharamesh/lyft-clone/blob/main/backend/routes/auth_routes.py"
click node_menu "https://github.com/asitharamesh/lyft-clone/blob/main/backend/routes/menu_routes.py"
click node_health "https://github.com/asitharamesh/lyft-clone/blob/main/backend/routes/health_routes.py"
click node_admin "https://github.com/asitharamesh/lyft-clone/blob/main/backend/routes/admin_routes.py"
click node_sockets "https://github.com/asitharamesh/lyft-clone/blob/main/backend/sockets/handlers.py"
click node_auth "https://github.com/asitharamesh/lyft-clone/blob/main/backend/services/auth_service.py"
click node_matching "https://github.com/asitharamesh/lyft-clone/blob/main/backend/services/matching_service.py"
click node_rides "https://github.com/asitharamesh/lyft-clone/blob/main/backend/services/ride_service.py"
click node_routing "https://github.com/asitharamesh/lyft-clone/blob/main/backend/services/routing_service.py"
click node_pricing "https://github.com/asitharamesh/lyft-clone/blob/main/backend/services/pricing_service.py"
click node_simulator "https://github.com/asitharamesh/lyft-clone/blob/main/backend/ride_simulation_engine.js"
click node_pg "https://github.com/asitharamesh/lyft-clone/blob/main/backend/db.py"
click node_redis "https://github.com/asitharamesh/lyft-clone/blob/main/backend/db.py"
click node_socketio "https://github.com/asitharamesh/lyft-clone/blob/main/backend/extensions.py"
click node_stats "https://github.com/asitharamesh/lyft-clone/blob/main/backend/services/ops_stats.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_rider,node_driver,node_adminui,node_opsactor toneBlue
class node_rest,node_authroutes,node_menu,node_health,node_admin,node_sockets toneAmber
class node_auth,node_matching,node_rides,node_routing,node_pricing,node_simulator toneMint
class node_pg,node_redis,node_socketio,node_osrm toneRose
class node_stats toneIndigo
```

## Components

### Web clients

- [Rider app](https://github.com/asitharamesh/lyft-clone/blob/main/frontend/new_map.html): `frontend/new_map.html`
- [Driver app](https://github.com/asitharamesh/lyft-clone/tree/main/backend): `backend`
- [Admin dashboard](https://github.com/asitharamesh/lyft-clone/blob/main/frontend/admin.html): `frontend/admin.html`

### Backend interfaces

- [Flask REST](https://github.com/asitharamesh/lyft-clone/blob/main/backend/app.py): `backend/app.py`
- [Authentication routes](https://github.com/asitharamesh/lyft-clone/blob/main/backend/routes/auth_routes.py): `backend/routes/auth_routes.py`
- [Menu and fare API](https://github.com/asitharamesh/lyft-clone/blob/main/backend/routes/menu_routes.py): `backend/routes/menu_routes.py`
- [Health API](https://github.com/asitharamesh/lyft-clone/blob/main/backend/routes/health_routes.py): `backend/routes/health_routes.py`
- [Admin API](https://github.com/asitharamesh/lyft-clone/blob/main/backend/routes/admin_routes.py): `backend/routes/admin_routes.py`
- [Socket handlers](https://github.com/asitharamesh/lyft-clone/blob/main/backend/sockets/handlers.py): `backend/sockets/handlers.py`

### Ride services

- [Auth service](https://github.com/asitharamesh/lyft-clone/blob/main/backend/services/auth_service.py): `backend/services/auth_service.py`
- [Driver matching](https://github.com/asitharamesh/lyft-clone/blob/main/backend/services/matching_service.py): `backend/services/matching_service.py`
- [Ride lifecycle](https://github.com/asitharamesh/lyft-clone/blob/main/backend/services/ride_service.py): `backend/services/ride_service.py`
- [Road routing](https://github.com/asitharamesh/lyft-clone/blob/main/backend/services/routing_service.py): `backend/services/routing_service.py`
- [Fare pricing](https://github.com/asitharamesh/lyft-clone/blob/main/backend/services/pricing_service.py): `backend/services/pricing_service.py`
- [Ride simulator](https://github.com/asitharamesh/lyft-clone/blob/main/backend/ride_simulation_engine.js): `backend/ride_simulation_engine.js`

### Persistence and realtime state

- [PostgreSQL](https://github.com/asitharamesh/lyft-clone/blob/main/backend/db.py): `backend/db.py`
- [Redis state](https://github.com/asitharamesh/lyft-clone/blob/main/backend/db.py): `backend/db.py`
- [Socket.IO](https://github.com/asitharamesh/lyft-clone/blob/main/backend/extensions.py): `backend/extensions.py`
- **OSRM routing**

### Operations

- [Operational statistics](https://github.com/asitharamesh/lyft-clone/blob/main/backend/services/ops_stats.py): `backend/services/ops_stats.py`

### Other components

- **Admin user**

## Connections

- Flask REST → Authentication routes: registers routes (evidence: `backend/app.py`)
- Flask REST → Menu and fare API: registers routes (evidence: `backend/app.py`)
- Flask REST → Health API: registers routes (evidence: `backend/app.py`)
- Flask REST → Admin API: registers routes (evidence: `backend/app.py`)
- Flask REST → Socket.IO: initializes (evidence: `backend/app.py`)
- Rider app → Flask REST: requests API (evidence: `README.md`)
- Driver app → Socket handlers: sends events (evidence: `README.md`)
- Rider app → Socket handlers: requests rides (evidence: `README.md`)
- Authentication routes → Auth service: hashes and issues tokens (evidence: `backend/routes/auth_routes.py`)
- Authentication routes → PostgreSQL: reads and writes accounts (evidence: `backend/routes/auth_routes.py`)
- Menu and fare API → PostgreSQL: reads menus (evidence: `backend/routes/menu_routes.py`)
- Menu and fare API → Road routing: calculates routes (evidence: `backend/routes/menu_routes.py`)
- Menu and fare API → Fare pricing: builds fare (evidence: `backend/routes/menu_routes.py`)
- Socket handlers → Driver matching: finds drivers (evidence: `backend/sockets/handlers.py`)
- Socket handlers → Ride lifecycle: manages ride state (evidence: `backend/sockets/handlers.py`)
- Socket handlers → Road routing: calculates trip routes (evidence: `backend/sockets/handlers.py`)
- Socket handlers → Fare pricing: calculates fares (evidence: `backend/sockets/handlers.py`)
- Driver matching → PostgreSQL: reads driver profiles (evidence: `backend/services/matching_service.py`)
- Driver matching → Redis state: queries GEO index (evidence: `backend/services/matching_service.py`)
- Ride lifecycle → PostgreSQL: persists lifecycle (evidence: `backend/services/ride_service.py`)
- Road routing → OSRM routing: requests road routes (evidence: `backend/services/routing_service.py`)
- Road routing → Road routing: falls back to haversine (evidence: `backend/services/routing_service.py`)
- Socket handlers → Socket.IO: emits room updates (evidence: `backend/sockets/handlers.py`)
- Socket.IO → Redis state: publishes events (evidence: `backend/extensions.py`)
- Socket handlers → Ride simulator: starts simulation (evidence: `README.md`)
- Ride simulator → Socket handlers: reports trip updates (evidence: `README.md`)
- Health API → PostgreSQL: checks readiness (evidence: `backend/db.py`)
- Admin dashboard → Admin API: requests operations data (evidence: `backend/routes/admin_routes.py`)
- Admin user → Admin API: views operations (evidence: `README.md`)
- Admin API → PostgreSQL: reads operations data (evidence: `backend/routes/admin_routes.py`)
- Admin API → Redis state: reads driver state (evidence: `backend/routes/admin_routes.py`)
- Admin API → Operational statistics: reads counters (evidence: `backend/routes/admin_routes.py`)
- Operational statistics → Redis state: stores counters (evidence: `backend/services/ops_stats.py`)
