How damarudhvarma/uber-microservices works
Project type and purpose
• This is a microservices-based ride-hailing application (“Uber Microservices Project”).
• Purpose: allow users to register/login and request rides; captains register/login and accept rides; rides are created and managed; a gateway routes client requests.
File structure
• Four top-level services:
• gateway/ – Reverse proxy (express-http-proxy) listening on port 3000
• user/ – User Service (port 3001)
• captain/ – Captain Service (port 3002)
• rides/ – Ride Service (port 3003)
• Each service has:
• DB/connect.js – MongoDB connection
• controllers/ – Request handlers
• models/ – Mongoose schemas (e.g., userModel, rideModel)
• middlewares/ – JWT auth & token blacklisting
• routes/ – Express routes
• service/rabbit.js – RabbitMQ publisher/subscriber
• app.js & server.js – Express setup and startup
• Shared config: .env for MONGO_URI, JWT_SECRET, RABBIT_URL, BASE_URL
Key architectural insights from README
• Communication:
• HTTP via gateway proxy for client→service
• Internal HTTP calls (axios) for service-to-service
• RabbitMQ for event-driven, async messaging
• Datastore: MongoDB per service
• Auth: JWT + token blacklisting (Mongo)
• Scalability: independent scaling of each service, load balancing at gateway
a. Main components
• Client (Web/Mobile)
• API Gateway (Express + express-http-proxy)
• User Service
• Captain Service
• Ride Service
• RabbitMQ Broker
• MongoDB Databases (one per service)
b. Relationships & interactions
1. Client → Gateway (HTTP)
2. Gateway → appropriate Service (HTTP proxy)
3. Service ↔ MongoDB (CRUD via Mongoose)
4. Service ↔ RabbitMQ (publish/subscribe events like “ride-created”, “ride-accepted”)
5. Services may communicate directly via HTTP (axios) for synchronous operations
c. Architectural patterns & design principles
• Microservices for domain separation
• Reverse proxy (API Gateway) for unified entry point
• Event-driven architecture with RabbitMQ for decoupling
• Token-based authentication (JWT) and token blacklisting
• Asynchronous, non-blocking operations in Node.js
d. Key technologies & frameworks
• Node.js + Express.js
• MongoDB + Mongoose
• RabbitMQ
• JWT, bcrypt
• express-http-proxy, axios
• dotenv, cookie-parser
Detail and separation
• Token-blacklist flow: show blacklistModel in Mongo used by authMiddleware.
• Environment config (.env) feeding into services.