Skip to content

amirkiarafiei/microservices-product-catalog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

106 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

TMF Product Catalog Microservices System

Tests: 120+ Code: 14.2K LOC Documentation View Code Wiki Ask DeepWiki


A cloud-native, event-driven microservices platform for managing telecommunications product catalogs. This project demonstrates high-scale architectural patterns including Distributed Sagas, CQRS, and Transactional Outbox.

GitHub: https://github.com/amirkiarafiei/microservices-product-catalog


Screenshots

Login Β Β Β  Builder
Viewer Β Β Β  Store

Table of Contents


πŸš€ Quick Start (Automated)

We use a Makefile to simplify monorepo orchestration.

1. Infrastructure

Spin up the databases and middleware:

make infra-up

2. First-Time Setup

Run these once to prepare security and databases:

make setup-keys  # Generate RSA keys
make migrate     # Apply DB schemas

Note: Follow script instructions to update services/identity-service/.env after generating keys.

3. Running the App

You can start everything with a single command:

make dev
  • Backend: Starts 7 microservices in the background (logs saved to logs/ directory).
  • Frontend: Starts the Next.js dev server on http://localhost:3000.

4. Management

make status  # Check which services are running
make stop    # Stop all background backend services
make clean   # Remove logs and temp files

5. Dependency Management & Testing

make install-all-deps  # Install all backend (uv) and frontend (npm) deps
make test-all          # Run all tests across the monorepo
make lint-all          # Run linters (ruff + next lint)

Default Credentials

Role Username Password
Admin admin admin
User user user

πŸ•΅οΈ Observability & Monitoring

The system is a "Glass Box" – you can see everything happening inside:


πŸ— Core Architecture Patterns

  • Hexagonal Architecture: Domain logic is strictly isolated from infrastructure.
  • Orchestrated Saga: Publication lifecycle managed by Camunda BPMN with automatic compensating transactions.
  • CQRS: Separate write models (PostgreSQL) and read models (MongoDB + Elasticsearch).
  • Transactional Outbox: Guaranteed event delivery using Postgres LISTEN/NOTIFY.
  • Zero-Trust Security: Every service boundary validates JWTs signed with RS256.
  • Full Observability: Distributed tracing with OpenTelemetry and centralized logging with ELK.

πŸ“Š System Visualizations

1. High-Level Architecture

The system is divided into a Command Side (Write) and a Query Side (Read), connected via asynchronous events.

flowchart TB
    subgraph ClientLayer [Frontend]
        UI[NextJS App]
    end

    subgraph EntryLayer [API Gateway]
        GW[API Gateway]
    end

    subgraph WriteSide [Command Side - PostgreSQL]
        ID[Identity]
        CH[Characteristic]
        SP[Specification]
        PR[Pricing]
        OF[Offering]
    end

    subgraph Orchestration [Orchestration]
        CAM[Camunda Engine]
    end

    subgraph Messaging [Event Bus]
        RMQ[RabbitMQ]
    end

    subgraph ReadSide [Query Side - NoSQL]
        ST[Store Query Service]
        MDB[(MongoDB)]
        ES[(Elasticsearch)]
    end

    UI --> GW
    GW --> WriteSide
    OF -->|"Start Saga"| CAM
    CAM -->|"Tasks"| WriteSide
    WriteSide -->|"Outbox Events"| RMQ
    RMQ --> ST
    ST --> MDB
    ST --> ES
    GW --> ST
Loading

2. Offering Publication Saga

A distributed transaction spanning four microservices, orchestrated by Camunda.

sequenceDiagram
    participant Admin
    participant OF as Offering Service
    participant CAM as Camunda Engine
    participant PR as Pricing Service
    participant SP as Spec Service
    participant ST as Store Service

    Admin->>OF: POST /publish
    OF->>CAM: Start Process
    CAM->>PR: Task: Lock Prices
    PR-->>CAM: Done
    CAM->>SP: Task: Validate Specs
    SP-->>CAM: Done
    CAM->>ST: Task: Pre-create View
    ST-->>CAM: Done
    CAM->>OF: Task: Mark Published
    OF-->>Admin: 200 OK (via Outbox/Event)
Loading

3. Transactional Outbox Pattern

Ensures that a database update and its corresponding event publication happen atomically.

flowchart LR
    subgraph Service [Microservice]
        Logic[Business Logic]
        Repo[Repository]
    end

    subgraph DB [PostgreSQL]
        Data[(Business Data)]
        Outbox[(Outbox Table)]
    end

    subgraph Broker [RabbitMQ]
        Queue[Event Exchange]
    end

    Logic --> Repo
    Repo -->|"Atomic Transaction"| Data
    Repo -->|"Atomic Transaction"| Outbox
    Outbox -->|"pg_notify"| Listener[Outbox Listener]
    Listener -->|"Publish"| Queue
Loading

πŸ“‚ Microservices Map

Service Responsibility Write DB Read/Search
API Gateway Entry point, Circuit Breakers, Correlation IDs - -
Identity Authentication & RSA Key Distribution PostgreSQL -
Characteristic Atomic attributes (Speed, Color, etc.) PostgreSQL -
Specification Technical groupings of characteristics PostgreSQL -
Pricing Monetary definitions & Saga Locking PostgreSQL -
Offering Product bundles & Saga Orchestrator PostgreSQL -
Store Query High-performance catalog & Full-text search - Mongo + ES
Web UI Modern Management & Shopping Portal - Next.js 16

Development Guide

Testing

We maintain a high-quality bar with 120+ tests across the suite:

# Run all tests (Unit + Integration + Component + E2E)
make test-all

# Run E2E tests (requires Docker)
make test-e2e

# Run tests for a specific service
cd services/pricing-service && uv run pytest tests -v

# Run shared library tests
cd libs/common-python && uv run pytest tests -v

Database Management

Migrate all services:

make migrate

Reset databases to clean state:

uv run python scripts/clean_databases.py

Seed sample data:

uv run python scripts/seed_data.py

Infrastructure

Start all containers:

make infra-up

Stop all containers:

make infra-down

View container status:

docker-compose ps

Key Technologies

Layer Technology Version
Frontend Next.js 16.1+
Frontend Styling Tailwind CSS 4.0+
Backend Python 3.13+
Framework FastAPI 0.104+
Package Manager uv Latest
Write DB PostgreSQL 15
Read DB MongoDB 7
Search Elasticsearch 8.11+
Message Broker RabbitMQ 3.12
Workflow Camunda 7.20
Tracing Zipkin Latest
Logging ELK Stack 8.11+
Containers Docker Compose Latest

πŸ“‚ Project Structure

microservices-product-catalog/
β”œβ”€β”€ docs/                      # Complete documentation
β”‚   β”œβ”€β”€ report/               # Final project report
β”‚   β”œβ”€β”€ api/                  # API reference & OpenAPI specs
β”‚   β”œβ”€β”€ sdd.md                # System Design Document
β”‚   └── phases/               # Development roadmap
β”‚
β”œβ”€β”€ services/                 # Microservices
β”‚   β”œβ”€β”€ api-gateway/          # Entry point :8000
β”‚   β”œβ”€β”€ identity-service/     # Auth :8001
β”‚   β”œβ”€β”€ characteristic-service/ # Characteristics :8002
β”‚   β”œβ”€β”€ specification-service/  # Specifications :8003
β”‚   β”œβ”€β”€ pricing-service/      # Pricing :8004
β”‚   β”œβ”€β”€ offering-service/     # Offerings :8005
β”‚   └── store-service/        # Store (CQRS Read) :8006
β”‚
β”œβ”€β”€ libs/common-python/       # Shared library
β”‚   └── src/common/
β”‚       β”œβ”€β”€ logging.py        # Structured logging
β”‚       β”œβ”€β”€ tracing.py        # OpenTelemetry
β”‚       β”œβ”€β”€ security.py       # JWT validation
β”‚       β”œβ”€β”€ messaging.py      # RabbitMQ
β”‚       └── exceptions.py     # Standard errors
β”‚
β”œβ”€β”€ web-ui/                   # Next.js frontend :3000
β”‚   └── src/
β”‚       β”œβ”€β”€ app/              # App Router pages
β”‚       β”œβ”€β”€ components/       # Reusable UI
β”‚       └── contexts/         # React contexts
β”‚
β”œβ”€β”€ scripts/                  # Development utilities
β”‚   β”œβ”€β”€ migrate.py            # DB migrations
β”‚   β”œβ”€β”€ seed_data.py          # Sample data
β”‚   β”œβ”€β”€ clean_databases.py    # Reset DBs
β”‚   └── generate_keys.sh      # RSA key generation
β”‚
β”œβ”€β”€ tests/                    # E2E tests
β”‚   └── e2e/
β”‚
β”œβ”€β”€ docker-compose.yml        # Infrastructure
β”œβ”€β”€ Makefile                  # Automation
β”œβ”€β”€ pyproject.toml            # Root workspace
└── README.md                 # This file

URLs & Ports

Service URL Port
Web UI http://localhost:3000 3000
API Gateway http://localhost:8000 8000
API Docs http://localhost:8000/docs -
Identity http://localhost:8001 8001
Characteristic http://localhost:8002 8002
Specification http://localhost:8003 8003
Pricing http://localhost:8004 8004
Offering http://localhost:8005 8005
Store http://localhost:8006 8006
Camunda http://localhost:8085 8085
RabbitMQ http://localhost:15672 15672
Zipkin http://localhost:9411 9411
Kibana http://localhost:5601 5601
Elasticsearch http://localhost:9200 9200
PostgreSQL localhost:5432 5432
MongoDB localhost:27017 27017

πŸ“š Project Documentation

Final Report

Complete project report with comprehensive technical analysis:

πŸ“– Read Full Report

Contents:

  • Problem definition and project scope
  • Requirements analysis (functional and non-functional)
  • Analysis models (Use Cases, Domain Model, Activity Diagrams)
  • Design models (Component, Sequence, State Machine Diagrams)
  • Detailed architectural design and patterns
  • Implementation details and decisions
  • Testing strategy and results (108 test functions)
  • Deployment instructions
  • Evaluation, challenges, and future improvements

API Reference

Complete API documentation with interactive endpoints:

πŸ“– API Reference Guide

Includes:

  • Authentication endpoints
  • Characteristics, Specifications, Pricing, Offerings CRUD operations
  • Store (public) catalog search
  • Health checks
  • Error responses with HTTP status codes
  • Request/response examples for all endpoints
  • Interactive Swagger documentation links

OpenAPI Specifications:

Design Documents


Contributing

Code Style

  • Python: Follow PEP 8 with ruff linter
  • TypeScript/React: Use prettier and eslint
  • Commits: Conventional commits format

PR Process

  1. Create feature branch: git checkout -b feat/description
  2. Make changes and write tests
  3. Run tests: make test-all
  4. Push and open PR
  5. Address review comments
  6. Merge after approval

License

This project is licensed under the MIT License - see the LICENSE file for details.


Contact

For questions or contributions, please open an issue on GitHub.


Last Updated: January 2026

About

TMForum product catalog microservices learning project. Demonstrates business decomposition, eventual consistency, saga transactions, and real-time processing with CQRS, event-driven architecture, and comprehensive observability.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors