@rayltics is a high-performance, distributed e-commerce backend designed to handle ++users/month. It utilizes a hybrid micro-services architecture combining gRPC for low-latency internal communication and Kafka for asynchronous event-driven consistency.
The system is split into three distinct scaling clusters:
- Transactors (Stateless): CPU-bound services (Orders, Inventory) that scale horizontally.
- Streamers (Stateful): RAM-bound services (Chat, Notifications) handling long-lived WebSocket connections. They bridge users via Redis Pub/Sub.
- Workers (Background): Consumers that process Kafka events for eventual consistency (e.g., archiving chat logs, sending emails).
- External: REST/GraphQL (via API Gateway) & WebSockets.
- Internal Sync: gRPC (Protobuf) for critical dependency calls (e.g., Gateway -> Inventory).
- Internal Async: Kafka events for side effects (e.g., Order Created -> Send Email).
├── apps/
│ ├── api-gateway/ # Entry point (HTTP + WS Adapter)
│ ├── services/ # Stateless Cluster (gRPC)
│ │ ├── auth/ # JWT & Identity
│ │ ├── order/ # Order Processing & Sagas
│ │ ├── inventory/ # Stock management (Redis Locking)
│ │ └── catalog/ # Product Search (Mongo/Elastic)
│ ├── streamers/ # Stateful Cluster (WebSockets)
│ │ └── chat/ # Real-time Messaging
│ └── workers/ # Background Cluster
│ └── chat-persister/ # Saves Kafka stream to Mongo
│
├── packages/
│ ├── proto/ # Shared .proto files (Contracts)
│ ├── contracts/ # Shared DTOs & Event Definitions
│ └── common/ # Shared Utilities (Guards, Interceptors)
│
├── infra/
│ ├── docker/ # Local dev environment
│ ├── k8s/ # Kubernetes manifests (Helm)
│ └── terraform/ # Cloud infrastructure (IaC)- Node.js v18+
- Docker & Docker Compose
- pnpm (recommended) or npm
git clone https://github.com/itsferdiardiansa/rayltics.git
cd rayltics
pnpm installdocker-compose -f infra/docker/docker-compose.yml up -dNote: The postgres container will automatically execute infra/docker/postgres-init.sql on the first run to create the 5 required databases (order_db, inventory_db, etc.).
You can run all services in parallel using Nx:
npx nx run-many --target=serve --all --parallel=5npx nx serve api-gatewaynpx nx serve order-serviceThis project uses .proto files as the source of truth.
- Edit libs/proto/src/order.proto.
- The build system automatically copies these assets to the dist/ folder.
- Do not manually write TypeScript interfaces for these; let the NestJS gRPC compiler handle the mapping.
Use the Nx generator to scaffold a new service:
npx nx g @nx/nest:app services/paymentAdd it to docker-compose manually in infra/docker/docker-compose.yml
- DTOs: Put request/response shapes in libs/contracts.
- Events: Put Kafka event classes in libs/contracts/src/events.
- Utils: Put Auth Guards or Logging logic in libs/common.
We use Jest for Unit and E2E testing.
npx nx run-many --target=test --allnpx nx e2e order-service-e2eSince this is a monorepo, we build specific apps using the context of the root.
docker build -f apps/services/order/Dockerfile . -t rayltics/order-service:latestHelm charts are located in infra/k8s/charts.
helm install order-service ./infra/k8s/charts/nestjs-service --set image.repository=rayltics/order-service