A modern, event-driven microservices architecture built with Go, DAPR, Kafka, and Kubernetes. This project demonstrates a complete e-commerce platform with product management, payment processing, and shopping basket functionality.
sequenceDiagram
participant Client
participant Gateway
participant Basket
participant Payment
participant Product
participant Kafka
participant Redis
participant PostgreSQL
Note over Client,PostgreSQL: Shopping Flow
Client->>Gateway: GET /api/v1/products
Gateway->>Product: Forward request
Product->>PostgreSQL: Query products
Product-->>Gateway: Return products
Gateway-->>Client: Product list
Client->>Gateway: POST /api/v1/baskets/add
Gateway->>Basket: Add item to basket
Basket->>Redis: Store basket data
Basket-->>Gateway: Updated basket
Gateway-->>Client: Basket updated
Client->>Gateway: POST /api/v1/payments
Gateway->>Payment: Process payment
Payment->>PostgreSQL: Store payment
Payment->>Kafka: Publish payment-completed event
Note over Kafka: Event-Driven Flow
Kafka->>Product: Consume payment-completed
Product->>PostgreSQL: Update stock
Kafka->>Basket: Consume payment-completed
Basket->>Redis: Clear basket
- Docker & Docker Compose
- Go 1.21+
- Kubernetes (Minikube/Docker Desktop)
- kubectl
- protoc (Protocol Buffers compiler)
-
Clone the repository
git clone <repository-url> cd daprps
-
Start with Docker Compose
docker-compose up -d
-
Verify services
docker-compose ps
-
Start Minikube
minikube start
-
Deploy base resources
kubectl apply -k k8s/base
-
Deploy development environment
kubectl apply -k k8s/overlays/dev
-
Check deployment status
kubectl get all -n daprps-dev
daprps/
โโโ api/proto/ # Protocol Buffer definitions
โ โโโ basket/
โ โโโ payment/
โ โโโ product/
โ โโโ events/
โโโ cmd/ # Service entry points
โ โโโ basket-service/
โ โโโ payment-service/
โ โโโ product-service/
โโโ internal/ # Business logic
โ โโโ basket-service/
โ โโโ payment-service/
โ โโโ product-service/
โโโ kafka/ # Event streaming
โ โโโ consumer/
โ โโโ publisher/
โโโ gingateway/ # API Gateway
โโโ dapr/ # DAPR components
โโโ docker/ # Docker configurations
โโโ k8s/ # Kubernetes manifests
โ โโโ base/
โ โโโ overlays/
โโโ docker-compose.yml
- Ports: 8081 (HTTP), 50051 (gRPC)
- Database: PostgreSQL
- Features: Product CRUD, stock management
- Events: Consumes payment-completed events
- Ports: 8082 (HTTP), 50052 (gRPC)
- Database: PostgreSQL
- Features: Payment processing, refunds
- Events: Publishes payment-completed events
- Ports: 8083 (HTTP), 50053 (gRPC)
- Database: Redis (in-memory)
- Features: Shopping basket management
- Events: Consumes payment-completed events
- Port: 8080
- Features: Request routing, load balancing, CORS
GET /api/v1/products- List all productsGET /api/v1/products/{id}- Get product by ID
POST /api/v1/payments- Process paymentGET /api/v1/payments/{id}- Get payment status
GET /api/v1/baskets/{user_id}- Get user basketPOST /api/v1/baskets/add- Add item to basketPOST /api/v1/baskets/remove- Remove item from basket
graph LR
A[Payment Service] -->|Publishes| B[Kafka Topic: payment-completed]
B -->|Consumes| C[Product Service]
B -->|Consumes| D[Basket Service]
C -->|Updates| E[Product Stock]
D -->|Clears| F[User Basket]
# Build all services
make build
# Build specific service
make build-product
make build-payment
make build-basket# Run all tests
make test
# Run specific service tests
make test-product# Generate Protocol Buffer code
make proto- Tracing: Zipkin (Port 9411)
- Logging: Structured JSON logs
- Health Checks:
/healthendpoints - Metrics: Prometheus-ready endpoints
- Environment-based configuration
- Input validation
- SQL injection prevention (GORM)
- CORS configuration
- Request/Response logging
# Development
docker-compose up -d
# Production
docker-compose -f docker-compose.prod.yml up -d# Development
kubectl apply -k k8s/overlays/dev
# Production
kubectl apply -k k8s/overlays/prod- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Port conflicts: Ensure ports 8080-8083, 50051-50053 are available
- Database connection: Check PostgreSQL and Redis are running
- Kafka connectivity: Verify Zookeeper and Kafka are healthy
- DAPR issues: Check placement service and sidecar configurations
# View service logs
docker-compose logs -f [service-name]
# View Kubernetes logs
kubectl logs -f deployment/[deployment-name] -n daprps-devFor questions and support, please open an issue in the GitHub repository.
