Pinstack is a production-ready microservice-based social network built with Go, featuring hexagonal architecture, comprehensive monitoring, event-driven design, and modern CI/CD practices.
| Service | Status | Description |
|---|---|---|
| User Service | β Production Ready | User management with CRUD operations, gRPC communication, and Prometheus metrics. |
| Auth Service | β Production Ready | JWT authentication/authorization with refresh tokens, session management, and Redis integration. |
| Post Service | β Production Ready | Post management with Redis caching, media handling, and optimized performance. |
| Relation Service | β Production Ready | Follow/unfollow relationships with Kafka event publishing and Redis caching. |
| Notification Service | β Production Ready | Event-driven notifications via Kafka consumer/producer with multiple notification types. |
| Component | Status | Description |
|---|---|---|
| API Gateway | β Production Ready | HTTPβgRPC routing, JWT validation, comprehensive Prometheus metrics. |
| Proto Definitions | β Ready | Centralized gRPC contracts with automated generation and version management. |
| Infra Deployments | β Ready | Docker Compose orchestration for PostgreSQL, Redis, Kafka infrastructure. |
| System Tests | β Production Ready | End-to-end integration testing with automated CI/CD integration. |
| Monitoring Service | β Production Ready | Complete observability stack: Prometheus, Grafana, Loki, ELK with custom dashboards. |
All services follow hexagonal architecture patterns with clear separation of concerns:
- Domain Layer: Core business logic and models
- Application Layer: Use cases and service orchestration
- Infrastructure Layer: External dependencies (databases, APIs, messaging)
- Ports & Adapters: Interface-driven design for easy testing and flexibility
- Kafka Integration: Asynchronous event processing for scalability
- Event Sourcing: State changes broadcast as events
- Loose Coupling: Services communicate via events and gRPC
- Prometheus Metrics: Request counts, latency, error rates, business metrics
- Structured Logging: JSON logs with correlation IDs via Loki
- Distributed Tracing: Request flow tracking across services
- Health Checks: Service availability and dependency monitoring
pinstack-post-servicepinstack-user-servicepinstack-auth-servicepinstack-proto-definitionspinstack-infra-deploymentspinstack-api-gatewaypinstack-relation-servicepinstack-notification-servicepinstack-monitoring-servicepinstack-system-tests
- Go β primary development language with clean architecture patterns
- gRPC / Protobuf β high-performance service-to-service communication
- PostgreSQL β ACID-compliant primary database with migrations
- Redis β caching, session storage, and high-performance data structures
- Kafka β event streaming and asynchronous message processing
- Docker / Compose β containerized deployment and development environments
- Prometheus β metrics collection and alerting
- Grafana β metrics visualization and dashboards
- Loki β centralized log aggregation and querying
- ELK Stack β alternative logging with Elasticsearch, Logstash, Kibana
- Structured Logging β JSON logs with correlation tracking
- GitHub Actions β automated testing and deployment pipelines
- Makefile β standardized development commands across services
- golangci-lint β comprehensive code quality and style checking
- Docker Multi-stage β optimized container builds
- Swagger/OpenAPI β API documentation and validation
- JWT Authentication β stateless token-based authentication
- Refresh Token Rotation β secure session management
- Input Validation β comprehensive request validation
- Redis Caching β intelligent caching strategies (cache-aside, write-through)
- Connection Pooling β optimized database connections
- gRPC Streaming β efficient real-time communication
- Prometheus Metrics β performance monitoring and alerting
- Health Checks β service availability monitoring
- Graceful Shutdown β proper resource cleanup
- Database Migrations β versioned schema management
- Retry Mechanisms β transient failure handling
- Microservice Architecture β independent scaling and deployment
- Event-Driven Design β asynchronous processing capabilities
- Horizontal Scaling β stateless service design
- Load Balancing Ready β multiple instance support
The entire Pinstack ecosystem uses modern GitHub Actions CI/CD with standardized Makefile commands for consistent development experience across all services.
Each microservice includes comprehensive CI pipeline:
-
Code Quality Checks
gofmtformatting validationgo vetstatic analysisgolangci-lintcomprehensive linting
-
Unit Testing
- Comprehensive test coverage reporting
- Mock-based testing with dependency injection
- Fast feedback loop for developers
-
Integration Testing
- Full Docker infrastructure setup
- Database migrations and seeding
- Real service-to-service communication testing
- Kafka event processing validation
-
Infrastructure Management
- Automatic Docker resource cleanup
- Network isolation for parallel testing
- Health check validation
Every service provides consistent Makefile interface:
# Code Quality & Testing
make fmt # Go formatting (gofmt)
make lint # Static analysis (go vet + golangci-lint)
make test-unit # Unit tests with coverage reporting
make test-integration # Integration tests with full infrastructure
make test-all # Complete test suite (fmt + lint + unit + integration)
make ci-local # Full CI process locally (GitHub Actions simulation)
# Infrastructure Management
make setup-system-tests # Clone/update test infrastructure repositories
make setup-monitoring # Clone/update monitoring stack
make start-infrastructure # Launch complete Docker test environment
make stop-infrastructure # Stop all containers
make clean-infrastructure # Complete cleanup (containers + volumes + images)
# Development Environments
make start-dev-full # Full development stack (services + monitoring + ELK)
make start-dev-light # Lightweight stack (services + Prometheus only)
make stop-dev-full # Stop development environment
make clean-dev-full # Complete development environment cleanup
# Monitoring & Observability
make start-monitoring # Prometheus + Grafana + Loki + ELK stack
make start-prometheus-stack # Prometheus + Grafana + Loki only
make start-elk-stack # Elasticsearch + Logstash + Kibana only
make check-monitoring-health # Validate all monitoring services
make logs-[service] # Service-specific log viewing
# Database & Cache Management
make migrate-up # Apply database migrations
make migrate-down # Rollback migrations
make redis-cli # Redis CLI access
make redis-flush # Clear Redis data (with confirmation)- Full System Integration Testing: End-to-end tests covering all service interactions
- Comprehensive Metrics: HTTP requests, gRPC calls, authentication, proxy metrics
- Isolated Testing: Each service tests only its required dependencies
- Event Testing: Kafka consumer/producer validation
- Cache Testing: Redis integration and invalidation testing
- Database Testing: Migration validation and data integrity
Production-ready observability available for all services:
- Prometheus: http://localhost:9090 - metrics and alerting
- Grafana: http://localhost:3000 (admin/admin) - dashboards and visualization
- Loki: http://localhost:3100 - centralized log aggregation
- Kibana: http://localhost:5601 - ELK stack log analysis
- PgAdmin: http://localhost:5050 (admin@admin.com/admin) - database management
- Kafka UI: http://localhost:9091 - event stream management
- Dependency Isolation: Services start only required infrastructure
- Parallel Testing: Network isolation enables concurrent test execution
- Automatic Cleanup: Zero manual intervention for resource management
- Fast Development Cycle: Local commands mirror CI/CD pipeline exactly
- Comprehensive Coverage: Unit, integration, and end-to-end testing
- Docker & Docker Compose β for containerized services
- Go 1.21+ β for local development
- Git β for repository management
# Clone any service repository (they all have similar structure)
git clone https://github.com/Soloda1/pinstack-api-gateway.git
cd pinstack-api-gateway
# Start complete development environment with monitoring
make start-dev-full
# Access services:
# - API Gateway: http://localhost:8080
# - User Service: http://localhost:8081
# - Auth Service: http://localhost:8082
# - Post Service: http://localhost:8083
# - Notification Service: http://localhost:8084
# - Relation Service: http://localhost:8085
#
# Monitoring:
# - Prometheus: http://localhost:9090
# - Grafana: http://localhost:3000 (admin/admin)
# - Kibana: http://localhost:5601
# - PgAdmin: http://localhost:5050 (admin@admin.com/admin)# Run complete test suite
make test-all
# Run only integration tests with full infrastructure
make test-integration
# Quick test without rebuilding containers
make quick-test# Format and lint code
make fmt lint
# Run unit tests
make test-unit
# Start monitoring only
make start-prometheus-stack
# View service logs
make logs-[service-name]
# Clean everything
make clean-dev-full
All services collect comprehensive metrics:
- HTTP Requests:
pinstack_http_requests_total,pinstack_http_request_duration_seconds - gRPC Calls:
pinstack_grpc_client_requests_total,pinstack_grpc_client_request_duration_seconds - Authentication:
pinstack_authentication_total,pinstack_authorization_total - Proxy Metrics:
pinstack_proxy_requests_total,pinstack_proxy_errors_total
- Database Operations: Connection pool usage, query duration, transaction metrics
- Cache Performance: Hit/miss ratios, operation latency (Redis)
- Event Processing: Kafka consumer lag, message processing rates
- Business Metrics: User registrations, post creation rates, relationship changes
- Resource Usage: CPU, memory, disk I/O per service
- Network: Inter-service communication latency
- Health Checks: Service availability and dependency status
The Pinstack API Gateway provides a comprehensive RESTful API with full Swagger/OpenAPI documentation available at:
- Swagger UI:
http://localhost:8080/swagger/index.html(when running locally) - OpenAPI JSON:
http://localhost:8080/swagger/doc.json
| Method | Endpoint | Description | Authentication |
|---|---|---|---|
POST |
/auth/register |
User registration | None |
POST |
/auth/login |
User authentication | None |
POST |
/auth/logout |
User logout | Refresh Token |
POST |
/auth/refresh |
Refresh access token | Refresh Token |
PUT |
/auth/update-password |
Update user password | JWT Required |
| Method | Endpoint | Description | Authentication |
|---|---|---|---|
POST |
/users |
Create new user | JWT Required |
GET |
/users/{id} |
Get user by ID | JWT Required |
PUT |
/users/{id} |
Update user profile | JWT Required |
DELETE |
/users/{id} |
Delete user account | JWT Required |
PUT |
/users/avatar |
Update user avatar | JWT Required |
| Method | Endpoint | Description | Authentication |
|---|---|---|---|
POST |
/posts |
Create new post | JWT Required |
GET |
/posts/{id} |
Get post by ID | JWT Required |
PUT |
/posts/{id} |
Update post | JWT Required |
DELETE |
/posts/{id} |
Delete post | JWT Required |
GET |
/posts/list |
Get posts with pagination | JWT Required |
| Method | Endpoint | Description | Authentication |
|---|---|---|---|
POST |
/relation/follow |
Follow user | JWT Required |
POST |
/relation/unfollow |
Unfollow user | JWT Required |
GET |
/relation/{user_id}/followers |
Get user followers | JWT Required |
GET |
/relation/{user_id}/followees |
Get user followees | JWT Required |
| Method | Endpoint | Description | Authentication |
|---|---|---|---|
GET |
/notification/feed |
Get notification feed | JWT Required |
GET |
/notification/unread-count |
Get unread count | JWT Required |
POST |
/notification/send |
Send notification | JWT Required |
PUT |
/notification/{id}/read |
Mark as read | JWT Required |
PUT |
/notification/read-all |
Mark all as read | JWT Required |
DELETE |
/notification/{id} |
Delete notification | JWT Required |
- OpenAPI 3.0 Specification: Complete API documentation
- Request Validation: Automatic input validation and error handling
- Pagination: Consistent pagination for list endpoints
- Media Support: File upload and media handling
- Real-time Events: WebSocket support for live notifications
- CORS Support: Cross-origin request handling
- Health Checks: Service health and readiness endpoints
- Testability: Easy unit testing with mocked dependencies
- Flexibility: Swap implementations without changing business logic
- Maintainability: Clear separation of concerns
- Scalability: Independent service evolution
- Loose Coupling: Services don't need direct knowledge of each other
- Scalability: Asynchronous processing handles load spikes
- Reliability: Event replay and processing guarantees
- Extensibility: New services can subscribe to existing events
- Performance: Binary protocol with HTTP/2 multiplexing
- Type Safety: Strongly typed contracts with Protobuf
- Language Agnostic: Easy polyglot service development
- Streaming: Bidirectional streaming for real-time features
π·πΊ ΡΠΈΡΠ°ΡΡ Π½Π° ΡΡΡΡΠΊΠΎΠΌ
π§ Production Ready: All core services are battle-tested with comprehensive monitoring, testing, and CI/CD pipelines. Ready for production deployment with Docker/Kubernetes.