Multi-channel notification service for email, SMS, push, and in-app notifications
notification-service is a Go microservice built with Fiber v3, providing a robust foundation for scalable applications with built-in monitoring, authentication, and cloud-native deployment capabilities.
- High Performance: Built with Fiber v3 for fast HTTP handling
- Database Integration: PostgreSQL with GORM ORM
- Caching: Redis for session management and caching
- Authentication: JWT-based authentication middleware
- Monitoring: Prometheus metrics and health checks
- Logging: Structured logging with configurable levels
- Container Ready: Docker multi-stage builds
- Kubernetes Native: Complete K8s manifests with HPA
- CI/CD Ready: GitHub Actions workflows
- Security: Built-in security middleware and best practices
- Go 1.21+
- Docker & Docker Compose
- PostgreSQL 15+
- Redis 7+
-
Clone and setup:
git clone <repository-url> cd notificationservice cp .env.example .env
-
Start dependencies:
make dev
-
Run the service:
make run
The service will be available at http://localhost:8083
# Build and run with Docker Compose
make docker-compose-up
# Or build and run individually
make docker-build
make docker-run
Method | Endpoint | Description | Auth Required |
---|---|---|---|
GET | /health |
Health check | No |
GET | /metrics |
Prometheus metrics | No |
GET | /api/v1/ping |
Service ping | No |
GET | /api/v1/protected |
Protected endpoint example | Yes |
Protected endpoints require a valid JWT token in the Authorization header:
curl -H "Authorization: Bearer <jwt-token>" \
http://localhost:8083/api/v1/protected
Configuration is managed through environment variables:
Variable | Description | Default |
---|---|---|
PORT |
Server port | 8083 |
DB_HOST |
Database host | localhost |
DB_PORT |
Database port | 5432 |
DB_NAME |
Database name | notification_service_db |
REDIS_HOST |
Redis host | localhost |
REDIS_PORT |
Redis port | 6379 |
JWT_SECRET |
JWT signing secret | your-secret-key |
LOG_LEVEL |
Logging level | info |
See .env.example
for a complete list.
make help # Show all available commands
make deps # Download dependencies
make build # Build the application
make run # Run the application
make test # Run tests
make test-coverage # Run tests with coverage
make bench # Run benchmarks
make lint # Run linter
make format # Format code
make clean # Clean build artifacts
notificationservice/
├── cmd/notification-service/ # Application entrypoint
├── internal/ # Private application code
│ ├── config/ # Configuration management
│ ├── handlers/ # HTTP handlers
│ ├── services/ # Business logic
│ ├── repositories/ # Data access layer
│ ├── middleware/ # Custom middleware
│ └── models/ # Data models
├── pkg/ # Public packages
│ ├── database/ # Database utilities
│ ├── redis/ # Redis utilities
│ ├── logger/ # Logging utilities
│ └── metrics/ # Metrics utilities
├── test/ # Test files
├── deployments/ # Deployment configs
│ ├── docker/ # Docker configs
│ └── k8s/ # Kubernetes manifests
└── .github/workflows/ # CI/CD workflows
# Run all tests
make test
# Run with coverage
make test-coverage
# Run only unit tests
go test ./test/unit/...
# Run only integration tests
go test ./test/integration/...
# Run benchmarks
make bench
- Add models in
internal/models/
- Create repositories in
internal/repositories/
- Implement services in
internal/services/
- Add handlers in
internal/handlers/
- Register routes in
cmd/notification-service/main.go
- Add tests in
test/unit/
andtest/integration/
# Build image
make docker-build
# Run container
make docker-run
# Deploy to Kubernetes
kubectl apply -k deployments/k8s/
# Check deployment status
kubectl get pods -n notificationservice
The service includes Kustomize configurations for different environments:
- Development: Basic setup with minimal resources
- Staging: Production-like setup with monitoring
- Production: Full setup with HPA, ingress, and security policies
- Liveness:
GET /health
- Readiness:
GET /health
(customize as needed)
Prometheus metrics are available at /metrics
:
- HTTP request metrics (count, duration)
- Database connection metrics
- Redis connection metrics
- Custom business metrics
Structured JSON logging with configurable levels:
{
"time": "2024-01-01T12:00:00Z",
"level": "INFO",
"msg": "Server started",
"port": "8083"
}
- JWT Authentication: Secure token-based auth
- CORS: Configurable cross-origin policies
- Rate Limiting: Built-in request rate limiting
- Security Headers: Helmet middleware for security headers
- Input Validation: Request validation and sanitization
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Commit changes:
git commit -m 'Add amazing feature'
- Push to branch:
git push origin feature/amazing-feature
- Open a Pull Request
- Follow Go best practices and conventions
- Write tests for new features
- Update documentation as needed
- Run linter and formatter before submitting
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
- Author: PyAirTable Team
- Issues: GitHub Issues
- Documentation: Wiki
Generated with Go Microservice Template