Skip to content

Repository files navigation

🚀 microservices-ecommerce

A small example microservices-based e-commerce platform. This repository contains multiple independent services that collaborate via HTTP and message queues. Each service is a focused Node.js/TypeScript app with its own responsibilities, configurations, and Dockerfile.

🧩 Services Overview

  • authentication-server 🔐 — Handles user registration, login, OTP, JWT issuance and basic user management.
  • gateway-server 🛡️ — API gateway that exposes endpoints to clients and forwards requests to internal services.
  • product-server 📦 — Manages products, product data, reviews and search-related logic.
  • order-server 🧾 — Processes orders, validates payloads and communicates with payment/fulfillment (stubbed here).
  • notification-server ✉️ — Sends emails/notifications (consumes messages from RabbitMQ to send emails for other services).

Each service lives in its own folder and follows a similar project layout (src/, configs/, routes/, controllers/, services/, utils/, etc.).

🗂 Repo Structure (top-level)

  • authentication-server/
  • gateway-server/
  • notification-server/
  • order-server/
  • product-server/

Open each service folder to see the internal structure. Typical locations for important code:

  • src/configs — envs and connection setups (RabbitMQ, DBs, Redis, Firebase, etc.)
  • src/routes — route definitions
  • src/controllers — request handlers
  • src/services — business logic
  • src/middleware — auth, validation, error handlers

⚙️ Prerequisites

  • Node.js (>= 16 recommended)
  • npm or yarn
  • Docker & Docker Compose (optional — services include Dockerfiles)
  • Local/remote instances of MongoDB, Redis, RabbitMQ and (optional) Firebase, if you want to run everything end-to-end

▶️ Quick start (per service)

  1. Open a terminal and go to the service folder (e.g. authentication-server):

    cd authentication-server

  2. Install dependencies:

    npm install

  3. Configure environment variables. See src/configs/envs.ts in each service for required variables.

  4. Run in development mode (most services expose dev or start scripts):

    npm run dev

Repeat for each service you want to run locally. Alternatively, build and run the Dockerfile in each service or use your own Docker Compose setup.

🐳 Docker

Each service includes a Dockerfile. You can build an image for a service and run it with Docker. Example:

docker build -t authentication-server ./authentication-server docker run -e NODE_ENV=production -p 4000:4000 authentication-server

There is no central docker-compose.yml in this repo — you can create one to orchestrate services, MongoDB, RabbitMQ, and Redis for local integration testing.

🔗 Message Queue & Integrations

The services use RabbitMQ for async communication (see src/configs/rabbitmq.ts in services that need it). Notification-server listens to messages from other services to send emails. Product and Order services may publish events like order.created, product.updated, etc.

🧪 Testing

Run tests inside each service directory. Many services use Jest for unit testing (see authentication-server/tests).

npm test

🧭 Environment variables

Each service holds an envs file under src/configs/envs.ts. Inspect those files to find the environment variables required for local runs (ports, DB URLs, RabbitMQ URL, JWT secrets, mail credentials, Firebase creds, etc.).

🏗 Architecture (high level)

  1. Client → Gateway Server (auth, routing, basic validation)
  2. Gateway forwards requests to Product/Order/Auth services (HTTP)
  3. Services communicate async via RabbitMQ for decoupled notifications and background processing
  4. Notification service consumes messages and sends emails

This pattern allows services to scale independently and keeps responsibilities separated.

✅ Contributing

  • Open issues or PRs against the service folder relevant to your change.
  • Keep changes scoped to a single service when possible.
  • Follow existing code style and patterns (TypeScript + Node + minimal controller-service separation).

🧾 License

This project includes LICENSE files in individual services. Check each service for license specifics.

📬 Questions

If you need help running a specific service locally or want a docker-compose example, tell me which services you want to run together and I can provide a configuration or step-by-step guidance.

Happy hacking! ✨

About

A small example microservices-based e-commerce platform

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages