How mohamedhabibfrigui/ecommerce-microservices works
Project Type & Purpose
• This is a Node.js-based, e-commerce microservices platform.
• It provides a GraphQL API Gateway for client interactions, three domain services (User, Product, Order) communicating internally over gRPC, event-driven messaging via Kafka, and data persistence in MongoDB.
File Structure Analysis
• Top-level directories:
• api-gateway/ – GraphQL server (Apollo, Express) with middleware (auth, rate-limit), routes, resolvers, schema, server entrypoint.
• user-service/, product-service/, order-service/ – Each contains a .proto file, a service entrypoint (e.g. userMicroservice.js), and a models/ folder with Mongoose schemas.
• Supplementary files:
• .gitignore, package.json at root.
• docs/ with images for Postman/Apollo.
Key README Insights
Client → (REST/GraphQL) → API Gateway → (gRPC) → Services → (MongoDB / Kafka)
• Stack highlights: Apollo Server, Express, gRPC, MongoDB, Kafka, JWT authentication, rate limiting.
• Emphasizes loose coupling, independent deployments, event-driven integration.
Main Components & Interactions
a. Components:
• Clients (web/mobile)
• API Gateway (Apollo GraphQL + Express)
• User Service, Product Service, Order Service (gRPC servers)
• MongoDB instances (one DB per service)
• Kafka cluster for events
b. Relationships:
• Clients send REST/GraphQL requests to API Gateway.
• Gateway authenticates (JWT), rate-limits, then dispatches gRPC calls to microservices.
• Services read/write to their MongoDB databases.
• Order Service publishes events to Kafka; User/Product Services subscribe for inventory updates, notifications, etc.
• Responses flow back along the same path to the client.
Architectural Patterns & Design Principles
• Microservices: each bounded context in its own process with its own datastore.
• API Gateway pattern: single entrypoint, hides service complexity, aggregates data.
• Event-driven via Kafka: loose coupling for cross-service workflows.
• gRPC for high-performance, strongly typed internal RPC.
• JWT for stateless auth, rate limiting for security.