CarFleet is a distributed backend system designed to simulate the core infrastructure of ride-sharing platforms. It handles high-throughput, real-time driver location streams and performs low-latency geospatial proximity searches.
The system follows a Microservices architecture:
- Communication: gRPC (Protocol Buffers) for low-latency, strict-contract messaging.
- Hot Storage (Redis): Uses Redis Geospatial Indexing for sub-millisecond driver tracking and proximity queries.
- Cold Storage (MongoDB): Handles persistent data like driver profiles and trip history.
- Routing Engine (OSRM): Self-hosted Open Source Routing Machine for calculating realistic driving paths on actual street maps.
- Infrastructure: Fully containerized using Docker and Docker Compose.
| Component | Technology |
|---|---|
| Frontend Framework | Next.js 15 (React 19) |
| Styling | TailwindCSS v4 |
| Maps & Visualization | Mapbox GL JS |
| State Management | React Reference State (Ref) for 60fps Perf |
| Backend Language | Python 3.10+ |
| API Protocol | gRPC & Protobuf |
| Real-Time Store | Redis (v7-alpine) |
| Persistent Store | MongoDB (v6.0) |
| Routing Engine | OSRM (Open Source Routing Machine) |
| DevOps | Docker, Docker Compose |
- Docker & Docker Compose
- Python 3.9+
- Node.js 18+ (for Frontend)
The system requires real-world map data for Los Angeles/California. Run the setup script to download and process the data:
cd backend
./setup_osrm.sh
cd ..Note: This downloads ~500MB of data and may take a few minutes to process.
Spin up the database and routing services:
docker compose up -dNavigate to the backend directory and start the services:
cd backend
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python server.py
# In another terminal:
python simulator.pyLaunch the Next.js web application:
cd frontend
npm install
npm run dev- High-Performance Rendering: Uses
requestAnimationFramefor buttery smooth 60fps car interpolation, bypassing React state for heavy animation loops. - 3D Visualization: Custom 3D SVG Car models that rotate and bank based on the vehicle's actual bearing.
- Smart Camera: "Cinematic Mode" automatically zooms and pans to frame the entire route (Pickup ➔ Dropoff) when a ride starts.
- Premium UI/UX:
- Radar Pulse: "Scanning" animation during driver search.
- Trail Clearing: Visual path "erasing" as the driver completes the route.
- Glassmorphism: Modern, translucent UI panels.
- Massive Scale: Capable of simulating 1000+ concurrent drivers in real-time.
- Real-World Routing: Drivers don't fly; they follow actual street geometry using OSRM (Open Source Routing Machine).
- Scattered Traffic: Algorithms distribute drivers realistically across local streets rather than clustering them on highways.
- Microservices: Fully decoupled Backend (Python) and Frontend (Node/Next.js).
- gRPC Contracts: Strict type safety between services using Protocol Buffers.
- Geospatial Sharding: Redis
GEOSEARCHfor O(log N) proximity lookups. - Atomic Locking: Lua scripts ensure a driver cannot be double-booked by concurrent riders.
- Dynamic Search Radius: Search logic expands radius (0.5mi ➔ 5.0mi) over time if no drivers are found immediately.