Skip to content

ProgrammerZamanNow/opentelemetry-demo-microservices

Repository files navigation

Microservices Demo

Empat service yang saling terhubung untuk mendemonstrasikan alur order → product/payment → notification.

Client ──> Order Service ──> Payment Service ──> Notification Service
              │
              └────────────> Product Service

Stack

Service Tech Port Database
order-service Java 21 + Spring Boot 3 8080 orderdb
product-service Bun + TypeScript 3000 productdb
payment-service Go 1.22 (net/http + pgx) 8081 paymentdb
notification-service Node.js 20 + Express 3001 notificationdb
postgres PostgreSQL 16 5432 semua di atas

Jalankan

docker compose up --build

PostgreSQL akan otomatis membuat empat database lewat init-db.sh. Tiap service melakukan migrasi tabel saat startup.

Mencoba alur

  1. Lihat daftar product:

    curl http://localhost:3000/products
  2. Buat order — order-service akan memanggil product-service (ambil harga, kurangi stock) lalu payment-service (yang lalu memberi tahu notification-service):

    curl -X POST http://localhost:8080/orders \
      -H "Content-Type: application/json" \
      -d '{
        "customer": "yoel@example.com",
        "productId": 1,
        "quantity": 1,
        "paymentMethod": "CARD"
      }'
  3. Cek notifikasi yang sudah dikirim:

    curl http://localhost:3001/notifications

Menjalankan service secara individual (opsional)

Setiap service punya konfigurasi default yang menunjuk ke localhost:5432 (kredensial demo/demo). Pastikan PostgreSQL berjalan dan database sudah ada, lalu:

  • order-service: ./mvnw spring-boot:run (atau mvn spring-boot:run)
  • product-service: bun install && bun run dev
  • payment-service: go run .
  • notification-service: npm install && npm run dev

Struktur

.
├── docker-compose.yml
├── init-db.sh
├── order-service/         # Java Spring Boot 3
├── product-service/       # Bun + TypeScript
├── payment-service/       # Go
└── notification-service/  # Node.js

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors