This project implements a modern microservices architecture designed to handle various aspects of a social networking application. Built with scalability, maintainability, and reliability in mind, the system follows industry best practices for microservices development.
-
API Gateway
- Primary entry point for all client requests
- Implements request routing and load balancing
- Handles API versioning and documentation
- Rate limiting and request validation
-
Auth Service
- Manages authentication and authorization
- JWT token generation and validation
- Role-based access control (RBAC)
- Session management with Redis
-
User Service
- User profile management
- Account settings and preferences
- User search and discovery
- Profile verification
-
Media Service
- Media file upload and processing
- Image resizing and optimization
- Content delivery network (CDN) integration
- File format validation
-
Post Service
- Content creation and management
- Post metadata handling
- Content moderation
- Feed generation
- Backend: Go 1.19+
- Database: PostgreSQL 14+
- Caching: Redis 6+
- Container Runtime: Docker
- Orchestration: Kubernetes
- Metrics: Prometheus
- Visualization: Grafana
- Logging: Zap (structured JSON logging)
- Tracing: OpenTelemetry
├── api-gateway/ # API Gateway service
├── auth-service/ # Authentication service
├── media-service/ # Media handling service
├── post-service/ # Post management service
├── user-service/ # User management service
├── shared/ # Shared libraries and utilities
└── docker-compose.yml # Local development setup
- Go 1.19 or later
- Docker and Docker Compose
- PostgreSQL 14+
- Redis 6+
- Make (optional)
- Clone the repository:
git clone <repository-url>
cd http_server
- Configure environment variables:
cp .env.example .env
# Edit .env with your configuration
- Start the services:
# Using Docker Compose
docker-compose up -d
# Verify services
docker-compose ps
Each service has a config.yaml
file with the following sections:
- Server configuration (ports, timeouts)
- Database settings
- Redis configuration
- Logging preferences
- Service dependencies
POST /api/v1/auth/login
- User authenticationPOST /api/v1/auth/register
- User registrationGET /api/v1/users/profile
- Get user profilePOST /api/v1/posts
- Create new postGET /api/v1/posts
- Get posts feed
All protected endpoints require a valid JWT token in the Authorization header:
Authorization: Bearer <token>
- Set up production environment:
make prod-env
- Build and push Docker images:
make docker-tag
make docker-push
- Deploy to Kubernetes:
make k8s-apply
- Access Grafana dashboard at
https://monitoring.yourdomain.com
- View service health status:
make health-check
- Monitor resources:
make monitor
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature
- Commit changes:
git commit -am 'Add new feature'
- Push to branch:
git push origin feature/your-feature
- Submit a Pull Request
- Follow Go best practices and project structure
- Write unit tests for new features
- Update documentation as needed
- Use conventional commits format
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions, please open an issue in the GitHub repository.
- Database connections
- JWT settings
- Logging configuration
- Metrics and monitoring
API documentation is available through Swagger UI at:
- Development:
http://localhost:8080/swagger/
- Production:
https://api.yourdomain.com/swagger/
- Prometheus endpoints:
/metrics
on each service - Grafana dashboards for visualization
- Custom metrics for business KPIs
- Structured JSON logging with Zap
- Log levels: DEBUG, INFO, WARN, ERROR
- Correlation IDs for request tracing
# Unit tests
go test ./...
# Integration tests
make integration-test
# Load tests
make load-test
- Build Docker images:
make build-images
- Deploy to Kubernetes:
kubectl apply -f k8s/
- Horizontal scaling through Kubernetes
- Vertical scaling for databases
- Cache layer scaling with Redis cluster
- Fork the repository
- Create a feature branch
- Write tests for new functionality
- Implement changes
- Ensure tests pass
- Submit pull request
- Follow Go standard formatting (gofmt)
- Use golangci-lint for static analysis
- Write meaningful commit messages
- Document public APIs
-
Service connectivity issues
- Check network configurations
- Verify service health endpoints
- Review logs for connection errors
-
Database connection issues
- Verify credentials in .env
- Check database logs
- Ensure migrations are up to date
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
- Create an issue in the repository
- Contact the development team
- Check the documentation wiki