# rifatbond007/ecommerce-microservices-platform architecture

> Architecture diagram of the GitHub repository rifatbond007/ecommerce-microservices-platform, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rifatbond007/ecommerce-microservices-platform
- Repository: https://github.com/rifatbond007/ecommerce-microservices-platform

## Overview

1. This repo is a microservices e-commerce platform, not a single backend. The main request path is: React/Vite frontend → API Gateway → one of the domain services → that service’s own database/schema. Supporting infrastructure is PostgreSQL, Redis, and RabbitMQ.

2. The frontend is a client-side SPA under `frontend/`. It is organized by route-level pages for public browsing, auth, user account flows, seller/admin consoles, checkout, search, notifications, and static content. Shared UI lives in `components/ui`, page chrome in `components/layout`, and state is kept in small client stores for auth and cart. The frontend talks to the backend through `src/lib/api.ts`.

3. The API Gateway (`services/gateway`) is the primary entry point on port 3000. Its role is request routing plus cross-cutting concerns: auth enforcement, rate limiting, and shared Redis usage. It is the boundary that keeps the frontend from calling individual services directly in normal operation.

4. The backend is split into ten Express + TypeScript services, each with its own Prisma schema and its own bounded domain:
   - `auth`: registration, login, refresh/logout, password reset, email verification, session/token handling
   - `user`: profiles, addresses, wishlists, reviews
   - `product`: catalog, brands, categories, inventory, variants, warehouses
   - `cart`: carts and saved carts
   - `order`: order lifecycle and history
   - `payment`: payment transactions, refunds, webhook handling
   - `notification`: user preferences and notifications delivery
   - `search`: search index and search queries
   - `admin`: dashboard, admin operations, settings, administrative user/order/product views

5. Each service follows the same internal layering: `app.ts` bootstraps the server, `routes/` assembles endpoints, `modules/` contains feature-specific controller/service/validator code, `repositories/` owns database access through Prisma, and `middleware/` handles auth/error/rate-limit concerns. This is a clear separation between HTTP, business logic, and persistence.

6. Data ownership is per service, not shared through one central application database. The README and Prisma layouts indicate a database-per-service strategy with separate schemas such as `auth`, `product_service`, `cart_service`, `order_service`, etc. That makes each domain independently deployable and reduces coupling at the storage layer.

7. RabbitMQ is the main asynchronous integration point. It is explicitly present in the notification, payment, and search services, and the infrastructure layer provisions RabbitMQ definitions. That suggests event-driven side effects such as payment notifications, search index updates, and other background workflows rather than direct synchronous coupling for every action.

8. Redis is used as shared fast-state infrastructure. In the gateway it supports edge concerns like rate limiting and possibly request/session coordination. It appears as a shared runtime dependency rather than a domain datastore.

9. The infrastructure folder is fully container-oriented. `infra/docker-compose.yml` orchestrates local development, with PostgreSQL initialization scripts, RabbitMQ definitions, and Redis configuration. This is the environment boundary for running the whole platform locally.

10. Security and access control are layered. JWT-based auth is centralized in the auth service, but auth middleware exists across services to protect their own endpoints. The gateway also applies auth and rate-limiting before requests reach downstream services.

11. The frontend mirrors the backend’s domain split in its UI structure. It has separate areas for customer, seller, and admin workflows, which is useful for an architecture diagram because it shows a single SPA serving multiple personas while still delegating all business operations to backend services.

12. CI/test automation exists but is secondary to runtime architecture. There is a GitHub Actions workflow, service-level Jest tests, and a shell script for API testing. The important architectural takeaway is that each service is independently testable and containerizable, matching the microservice boundaries.

Main entry points: [`services/gateway/src/modules/router/router.service.ts`](https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/services/gateway/src/modules/router/router.service.ts) (Router), [`infra/postgres/init-scripts/init-schemas.sql`](https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/infra/postgres/init-scripts/init-schemas.sql) (PostgreSQL), [`infra/docker-compose.yml`](https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/infra/docker-compose.yml) (Compose stack), [`services/gateway/src/app.ts`](https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/services/gateway/src/app.ts) (Gateway)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend SPA"]
  node_frontend_app["SPA<br/>react vite<br/>[App.tsx]"]
  node_frontend_pages["Route pages<br/>ui routes"]
  node_frontend_ui["Shared UI<br/>components"]
  node_frontend_state["Client state<br/>stores"]
  node_frontend_api["API client<br/>http client<br/>[api.ts]"]
end

subgraph group_edge["API Edge"]
  node_gateway["Gateway<br/>[app.ts]"]
  node_gateway_router["Router<br/>request routing<br/>[router.service.ts]"]
  node_gateway_middleware["Edge middleware<br/>auth rate-limit"]
  node_gateway_redis[("Redis cache<br/>shared state<br/>[redis.client.ts]")]
end

subgraph group_services["Domain Services"]
  node_auth_service["Auth<br/>identity service<br/>[app.ts]"]
  node_user_service["User<br/>profile service<br/>[app.ts]"]
  node_product_service["Product<br/>catalog service<br/>[app.ts]"]
  node_cart_service["Cart<br/>[app.ts]"]
  node_order_service["Order<br/>[app.ts]"]
  node_payment_service["Payment<br/>billing service<br/>[app.ts]"]
  node_notification_service["Notification<br/>message service<br/>[app.ts]"]
  node_search_service["Search<br/>[app.ts]"]
  node_admin_service["Admin<br/>[app.ts]"]
end

subgraph group_infra["Infrastructure"]
  node_postgres[("PostgreSQL<br/>database platform<br/>[init-schemas.sql]")]
  node_rabbitmq["RabbitMQ<br/>event bus<br/>[definitions.json]"]
  node_infra_compose["Compose stack<br/>local runtime<br/>[docker-compose.yml]"]
end

node_frontend_pages -->|"calls"| node_frontend_api
node_frontend_state -->|"syncs"| node_frontend_api
node_frontend_ui -->|"supports"| node_frontend_pages
node_frontend_app -->|"renders"| node_frontend_pages
node_frontend_api -->|"requests"| node_gateway
node_gateway_router -->|"routes"| node_auth_service
node_gateway_router -->|"routes"| node_user_service
node_gateway_router -->|"routes"| node_product_service
node_gateway_router -->|"routes"| node_cart_service
node_gateway_router -->|"routes"| node_order_service
node_gateway_router -->|"routes"| node_payment_service
node_gateway_router -->|"routes"| node_notification_service
node_gateway_router -->|"routes"| node_search_service
node_gateway_router -->|"routes"| node_admin_service
node_gateway_middleware -->|"guards"| node_gateway
node_gateway -->|"uses"| node_gateway_redis
node_auth_service -->|"owns schema"| node_postgres
node_user_service -->|"owns schema"| node_postgres
node_product_service -->|"owns schema"| node_postgres
node_cart_service -->|"owns schema"| node_postgres
node_order_service -->|"owns schema"| node_postgres
node_payment_service -->|"owns schema"| node_postgres
node_notification_service -->|"owns schema"| node_postgres
node_search_service -->|"owns schema"| node_postgres
node_admin_service -->|"owns schema"| node_postgres
node_payment_service -->|"publishes"| node_rabbitmq
node_notification_service -->|"consumes"| node_rabbitmq
node_search_service -->|"consumes"| node_rabbitmq
node_infra_compose -->|"orchestrates"| node_gateway
node_infra_compose -->|"orchestrates"| node_postgres
node_infra_compose -->|"orchestrates"| node_rabbitmq
node_infra_compose -->|"orchestrates"| node_gateway_redis

click node_frontend_app "https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/frontend/src/app/App.tsx"
click node_frontend_pages "https://github.com/rifatbond007/ecommerce-microservices-platform/tree/main/frontend/src/app/pages"
click node_frontend_ui "https://github.com/rifatbond007/ecommerce-microservices-platform/tree/main/frontend/src/components"
click node_frontend_state "https://github.com/rifatbond007/ecommerce-microservices-platform/tree/main/frontend/src/store"
click node_frontend_api "https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/frontend/src/lib/api.ts"
click node_gateway "https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/services/gateway/src/app.ts"
click node_gateway_router "https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/services/gateway/src/modules/router/router.service.ts"
click node_gateway_middleware "https://github.com/rifatbond007/ecommerce-microservices-platform/tree/main/services/gateway/src/middleware"
click node_gateway_redis "https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/services/gateway/src/shared/redis/redis.client.ts"
click node_auth_service "https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/services/auth/src/app.ts"
click node_user_service "https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/services/user/src/app.ts"
click node_product_service "https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/services/product/src/app.ts"
click node_cart_service "https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/services/cart/src/app.ts"
click node_order_service "https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/services/order/src/app.ts"
click node_payment_service "https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/services/payment/src/app.ts"
click node_notification_service "https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/services/notification/src/app.ts"
click node_search_service "https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/services/search/src/app.ts"
click node_admin_service "https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/services/admin/src/app.ts"
click node_postgres "https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/infra/postgres/init-scripts/init-schemas.sql"
click node_rabbitmq "https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/infra/rabbitmq/definitions.json"
click node_infra_compose "https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/infra/docker-compose.yml"

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_frontend_app,node_frontend_pages,node_frontend_ui,node_frontend_state,node_frontend_api toneBlue
class node_gateway,node_gateway_router,node_gateway_middleware,node_gateway_redis toneAmber
class node_auth_service,node_user_service,node_product_service,node_cart_service,node_order_service,node_payment_service,node_notification_service,node_search_service,node_admin_service toneMint
class node_postgres,node_rabbitmq,node_infra_compose toneRose
```

## Components

### Frontend SPA

Client-side React/Vite interface for customer, seller, and admin workflows.

- [SPA](https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/frontend/src/app/App.tsx): react vite · Single-page frontend entry and routing shell. · `frontend/src/app/App.tsx`
- [Route pages](https://github.com/rifatbond007/ecommerce-microservices-platform/tree/main/frontend/src/app/pages): ui routes · Public browsing, auth, account, checkout, search, seller, and admin pages. · `frontend/src/app/pages`
- [Shared UI](https://github.com/rifatbond007/ecommerce-microservices-platform/tree/main/frontend/src/components): components · Reusable chrome and UI primitives used across the SPA. · `frontend/src/components`
- [Client state](https://github.com/rifatbond007/ecommerce-microservices-platform/tree/main/frontend/src/store): stores · Small client stores for auth and cart state. · `frontend/src/store`
- [API client](https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/frontend/src/lib/api.ts): http client · Frontend backend adapter used by the SPA to reach the platform. · `frontend/src/lib/api.ts`

### API Edge

Primary request boundary and cross-cutting gateway concerns.

- [Gateway](https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/services/gateway/src/app.ts): api gateway · Primary entry point for routing, auth enforcement, rate limiting, and shared Redis access. · `services/gateway/src/app.ts`
- [Router](https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/services/gateway/src/modules/router/router.service.ts): request routing · Dispatches incoming requests toward downstream services. · `services/gateway/src/modules/router/router.service.ts`
- [Edge middleware](https://github.com/rifatbond007/ecommerce-microservices-platform/tree/main/services/gateway/src/middleware): auth rate-limit · Cross-cutting gateway controls for authentication and throttling. · `services/gateway/src/middleware`
- [Redis cache](https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/services/gateway/src/shared/redis/redis.client.ts): shared state · Gateway-side fast state used for shared edge concerns. · `services/gateway/src/shared/redis/redis.client.ts`

### Domain Services

Independently deployable Express + TypeScript services with their own Prisma-backed data ownership.

- [Auth](https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/services/auth/src/app.ts): identity service · Registration, login, sessions, password reset, and email verification. · `services/auth/src/app.ts`
- [User](https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/services/user/src/app.ts): profile service · Profiles, addresses, wishlists, reviews, and seller-facing user data. · `services/user/src/app.ts`
- [Product](https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/services/product/src/app.ts): catalog service · Catalog, brands, categories, inventory, variants, and warehouses. · `services/product/src/app.ts`
- [Cart](https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/services/cart/src/app.ts): cart service · Active carts and saved carts. · `services/cart/src/app.ts`
- [Order](https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/services/order/src/app.ts): order service · Order lifecycle and order history. · `services/order/src/app.ts`
- [Payment](https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/services/payment/src/app.ts): billing service · Transactions, refunds, and webhook handling. · `services/payment/src/app.ts`
- [Notification](https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/services/notification/src/app.ts): message service · User preferences and notification delivery. · `services/notification/src/app.ts`
- [Search](https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/services/search/src/app.ts): search service · Search queries and search index operations. · `services/search/src/app.ts`
- [Admin](https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/services/admin/src/app.ts): admin service · Administrative dashboards, operations, and management views. · `services/admin/src/app.ts`

### Infrastructure

Shared platform dependencies and local container orchestration.

- [PostgreSQL](https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/infra/postgres/init-scripts/init-schemas.sql): database platform · Database-per-service persistence with separate schemas owned by each service. · `infra/postgres/init-scripts/init-schemas.sql`
- [RabbitMQ](https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/infra/rabbitmq/definitions.json): event bus · Asynchronous integration backbone for payments, notifications, and search workflows. · `infra/rabbitmq/definitions.json`
- [Compose stack](https://github.com/rifatbond007/ecommerce-microservices-platform/blob/main/infra/docker-compose.yml): local runtime · Container-oriented local environment for the full platform. · `infra/docker-compose.yml`

## Connections

- Route pages → API client: calls · UI flows use the shared API adapter for backend access.
- Client state → API client: syncs · Auth and cart state coordinate with backend requests.
- Shared UI → Route pages: supports · Shared layout and primitives support route-level screens.
- SPA → Route pages: renders · SPA routes the user into domain-specific pages.
- API client → Gateway: requests · Normal frontend traffic goes through the gateway instead of directly to services.
- Router → Auth: routes · Authentication flows are one of the primary downstream paths.
- Router → User: routes · User/account flows are routed to the user service.
- Router → Product: routes · Catalog and browsing requests flow to product.
- Router → Cart: routes · Cart operations route to the cart service.
- Router → Order: routes · Order lifecycle requests route to order.
- Router → Payment: routes · Payment requests route to payment.
- Router → Notification: routes · Notification endpoints route to notification.
- Router → Search: routes · Search requests route to search.
- Router → Admin: routes · Admin console requests route to admin.
- Edge middleware → Gateway: guards · Gateway applies shared auth and rate limiting before downstream access.
- Gateway → Redis cache: uses · Shared edge state is stored in Redis.
- Auth → PostgreSQL: owns schema · Auth persists sessions and identity data in its own schema.
- User → PostgreSQL: owns schema · User domain persists profiles and related data in its own schema.
- Product → PostgreSQL: owns schema · Product catalog data is stored in a dedicated schema.
- Cart → PostgreSQL: owns schema · Cart state is persisted separately from other domains.
- Order → PostgreSQL: owns schema · Order history and lifecycle data are isolated in their own schema.
- Payment → PostgreSQL: owns schema · Payment transactions and refunds are stored in a dedicated schema.
- Notification → PostgreSQL: owns schema · Notification preferences and delivery records use their own schema.
- Search → PostgreSQL: owns schema · Search metadata and logs are persisted separately.
- Admin → PostgreSQL: owns schema · Admin data and operational records use a service-specific schema.
- Payment → RabbitMQ: publishes · Payment events feed asynchronous workflows.
- Notification → RabbitMQ: consumes · Notification delivery is event-driven.
- Search → RabbitMQ: consumes · Search indexing reacts to upstream events.
- Compose stack → Gateway: orchestrates · Local compose stack brings up the platform services.
- Compose stack → PostgreSQL: orchestrates · Compose provisions the shared database platform.
- Compose stack → RabbitMQ: orchestrates · Compose provisions the event bus.
- Compose stack → Redis cache: orchestrates · Compose provisions Redis for shared fast state.
