π A modern, production-ready e-commerce platform built with microservices architecture. Features a Go backend with 12+ microservices and a Next.js frontend with advanced API client capabilities.
- Microservices Architecture - 12+ independent, scalable services
- Modern Frontend - Next.js with TypeScript and shadcn/ui
- Advanced API Client - Retry logic, caching, token refresh
- Real-time Processing - Redis caching + RabbitMQ messaging
- Production Infrastructure - Nginx reverse proxy, health monitoring
- Automated CI/CD - GitHub Actions with security scanning
- Comprehensive Monitoring - Prometheus + Grafana dashboards
Backend:
- Go + Gin Framework
- PostgreSQL (12 databases)
- Redis (caching)
- RabbitMQ (messaging)
Frontend:
- Next.js 16 + React 19
- TypeScript
- TailwindCSS + shadcn/ui
- Advanced API client with retry/caching
Infrastructure:
- Docker + Docker Compose
- Nginx (reverse proxy)
- Prometheus + Grafana
- GitHub Actions CI/CD
- 1000+ orders/minute processing capacity
- Sub-100ms API response times
- 99.9% uptime SLA
- Automatic scaling and failover
- Request retry with exponential backoff
- Response caching (30-60s TTL)
- JWT authentication with auto-refresh
- Rate limiting (10 req/s API, 30 req/s app)
- Security headers (CSP, HSTS, X-Frame-Options)
- Container image scanning
- Automated dependency updates
Go-Microservices/
βββ client/ # Next.js Frontend
β βββ app/ # App router pages
β βββ components/ # React components (shadcn/ui)
β βββ lib/ # Utilities and API client
β β βββ api-client.ts # Advanced API client
β β βββ api-types.ts # TypeScript types
β β βββ api-loading-context.tsx
β βββ hooks/ # Custom React hooks
β β βββ use-api.ts # API hooks
β βββ Dockerfile # Client container
βββ microservices/ # Go Backend Services
β βββ api-gateway/ # API Gateway (Port 8000)
β βββ auth-service/ # Authentication (Port 8070)
β βββ product-service/ # Products (Port 8080)
β βββ order-service/ # Orders (Port 8081)
β βββ inventory-service/ # Inventory (Port 8082)
β βββ notification-service/ # Notifications (Port 8083)
β βββ payment-service/ # Payments (Port 8084)
β βββ customer-service/ # Customers (Port 8085)
β βββ admin-service/ # Admin (Port 8086)
β βββ cart-service/ # Shopping Cart (Port 8087)
β βββ review-rating-service/ # Reviews (Port 8088)
β βββ search-service/ # Search (Port 8089)
β βββ logistics-service/ # Logistics (Port 8090)
β βββ promotion-service/ # Promotions (Port 8091)
β βββ nginx/ # Reverse proxy config
β βββ docker-compose.yml # Service orchestration
β βββ healthcheck.sh # Health monitoring
βββ postman/ # API test collections
- Docker & Docker Compose
- Node.js 20+ (for local frontend development)
- Go 1.21+ (for local backend development)
# Clone repository
git clone <repository-url>
cd Go-Microservices
# Start all services (backend + frontend + nginx)
cd microservices
docker-compose up --build
# Services will be available at:
# - Frontend: http://localhost:3000 (via nginx: http://localhost)
# - API Gateway: http://localhost:8000 (via nginx: http://localhost/api)
# - Nginx Proxy: http://localhost:80
# - Prometheus: http://localhost:9090
# - Grafana: http://localhost:1707Backend Only:
cd microservices
docker-compose up api-gateway product-service order-serviceFrontend Only:
cd client
npm install
npm run dev
# Frontend at http://localhost:3000cd microservices
./healthcheck.sh
# Or check services manually
docker-compose ps| Service | Port | Description |
|---|---|---|
| nginx | 80/443 | Reverse proxy, load balancing |
| Next.js Client | 3000 | Frontend application |
| API Gateway | 8000 | Single entry point, routing |
| Auth Service | 8070 | Authentication, JWT tokens |
| Product Service | 8080 | Product management |
| Order Service | 8081 | Order processing, caching |
| Inventory Service | 8082 | Stock management |
| Notification Service | 8083 | Email/SMS notifications |
| Payment Service | 8084 | Payment processing |
| Customer Service | 8085 | Customer profiles |
| Admin Service | 8086 | Admin operations |
| Cart Service | 8087 | Shopping cart |
| Review Service | 8088 | Product reviews |
| Search Service | 8089 | Product search |
| Logistics Service | 8090 | Shipping, tracking |
| Promotion Service | 8091 | Discounts, coupons |
User β Nginx β Next.js Client
β
User β Nginx β API Gateway β Microservices
β
PostgreSQL / Redis / RabbitMQ
Located at: client/lib/api-client.ts
Features:
- Exponential Backoff Retry - 1s β 2s β 4s β 8s on failure
- Automatic Token Refresh - Seamless re-authentication on 401
- Response Caching - In-memory cache with configurable TTL
- Request Cancellation - AbortController support
- Loading States - React Context for global loading management
- TypeScript - Full type safety
Example usage:
import { apiClient } from '@/lib/api-client';
// Products (cached for 30s)
const products = await apiClient.products.list();
// Orders
const order = await apiClient.orders.create({ productId, quantity });
// Cart
await apiClient.cart.addItem(productId, 1);
// With React hooks
import { useApi } from '@/hooks/use-api';
const { data, loading, error } = useApi(
() => apiClient.products.list(),
{ immediate: true }
);User Types:
- Customers -
/login - Admins -
/admin/auth/login - Vendors -
/vendor/auth/login
Features:
- JWT token-based authentication
- HTTP-only cookies
- Automatic token refresh
- Role-based access control
Caching with Redis:
- 30-minute TTL for orders
- Automatic cache invalidation
- Cache-aside pattern
Message Queue:
- RabbitMQ for async processing
- Event publishing for new orders
- Topic exchange pattern
Batch Processing:
- Parallel order processing
- Configurable worker pool (10 workers)
- Timeout handling (30s)
- Performance: 1000+ orders/minute
- Fault tolerance for service calls
- Automatic retry mechanism
- Graceful degradation
- XSS protection
- CSRF prevention
- Rate limiting via nginx
- JWT authentication
- Database isolation
- Input validation
- Secure password hashing
- Security headers (nginx)
- Container scanning (Trivy)
- Code scanning (gosec)
- Dependency updates
- Request/response times
- Error rates
- Cache hit/miss ratios
- DB query performance
- Queue depth
- Service health
- Business KPIs
- Resource utilization
- Custom alerts
Access: http://localhost:1707 (admin/admin)
cd microservices/order-service
make test-unitmake test-integrationmake test-coverageImport Postman collections from postman/ directory
Each service provides interactive API documentation:
- API Gateway: http://localhost:8000/swagger/index.html
- Auth Service: http://localhost:8070/swagger/index.html
- Product Service: http://localhost:8080/swagger/index.html
- Order Service: http://localhost:8081/swagger/index.html
- Cart Service: http://localhost:8087/swagger/index.html
Generate docs:
cd <service-directory>
swag init -g main.go -o docsAll services include health checks:
healthcheck:
test: ["CMD", "wget", "--spider", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40sFeatures:
- Rate limiting
- Gzip compression
- Static asset caching (30 days)
- WebSocket support
- Security headers
SSL/TLS (Production):
Uncomment HTTPS configuration in nginx/nginx.conf and add certificates to nginx/certs/
Create .env file in microservices/:
JWT_SECRET=your-secret-key
STRIPE_SECRET_KEY=your-stripe-keyFrontend .env.local:
API_URL=http://localhost:8000
NEXT_PUBLIC_API_DEBUG=falseStages:
- Test - Unit + integration tests
- Security Scan - Trivy + gosec
- Build - Docker images
- Deploy - Kubernetes (on main branch)
Setup:
# Configure secrets in GitHub:
Settings β Secrets β Actions
- KUBE_CONFIG: Base64 kubeconfigTriggers:
- Push to
main - Pull requests to
main
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'feat: Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
Guidelines:
- Follow Conventional Commits
- Write tests for new features
- Update documentation
- Ensure CI passes
cd microservices/<service-name>
go mod download
go run main.gocd client
npm install
npm run dev# Run migrations
docker-compose exec <service> ./migrate up
# Rollback
docker-compose exec <service> ./migrate down# Check logs
docker-compose logs api-gateway
# Check health
docker-compose ps
./healthcheck.sh- Verify API Gateway is running
- Check
client/.env.localconfiguration - Ensure ports 3000 and 8000 are not in use
- Wait for health checks to pass (40s start period)
- Check database logs:
docker-compose logs product-db - Verify database credentials in docker-compose.yml
MIT License - see LICENSE file for details
- Go community
- Next.js team
- Docker
- All open source contributors
Built with β€οΈ using Go and Next.js