A REST API developed in Go using the Gin framework, integrated with Elasticsearch for logging, Redis for caching, and MongoDB for data persistence.
βββ cmd/ # Application entry point
β βββ api/
β βββ main.go # Main application file
β βββ main_test.go # Main tests
βββ docker-compose.yml # Docker Compose configuration
βββ dockerfile # Application Docker image
βββ go.mod # Go dependencies
βββ go.sum # Dependencies checksums
βββ index_tickets.json # Elasticsearch index configuration
βββ internal/ # Internal application code
β βββ config/
β β βββ config.go # Application configuration
β βββ middleware/ # HTTP middlewares
β β βββ cors.go # CORS middleware
β β βββ id.go # ID generation middleware
β β βββ jwt.go # JWT authentication middleware
β β βββ logger.go # Logging middleware
β β βββ server.go # Server configuration
β β βββ throttling.go # Rate limiting middleware
β βββ models/
β β βββ generic_response.go # Generic response models
β βββ repositories/ # Data access layer
β β βββ elsearch/
β β β βββ connection.go # Elasticsearch connection
β β βββ mongo/
β β β βββ connection.go # MongoDB connection
β β βββ redis/
β β βββ connection.go # Redis connection
β β βββ methods.go # Redis methods
β βββ routes/
β β βββ routes.go # API routes definition
β βββ service/ # Service layer
β β βββ healthcheck/
β β βββ health.go # Health check service
β βββ utils/
β βββ hosts.go # Host utilities
βββ pkg/ # Reusable packages
β βββ logger/
β βββ logger.go # Custom logging system
βββ README.md # This file
The application follows a layered architecture:
- cmd/: Entry point and initial configuration
- internal/: Application-specific code (non-exportable)
- config/: Configuration management
- middleware/: HTTP middlewares (CORS, JWT, logging, etc.)
- models/: Data structures
- repositories/: Data access (Elasticsearch, MongoDB, Redis)
- routes/: API routes definition
- service/: Business logic
- utils/: Various utilities
- pkg/: Reusable and exportable packages
- Docker and Docker Compose installed
- SSL certificates in
./certs/(for HTTPS)
Clone the repository and run:
# Start all services
docker-compose up -d
# Check logs
docker-compose logs -f vision-data-api
# Stop services
docker-compose down
# Rebuild and start (after code changes)
docker-compose up -d --build# Check running containers
docker-compose ps
# Follow logs in real-time
docker-compose logs -f
# Access container shell
docker-compose exec vision-data-api shThe application uses the following environment variables (configured in .env):
# Application settings - PRODUCTION
ENVIRONMENT_APP=prod
APP_PORT=8080
APP_PORT_TLS=8443
APP_CERT_FILE=/app/certs/server.crt
APP_KEY_FILE=/app/certs/server.key
# Elasticsearch - PRODUCTION
ELASTICSEARCH_URL=https://********:9200/
ELASTICSEARCH_USERNAME=elastic
ELASTICSEARCH_PASSWORD=**********
# Redis - PRODUCTION
REDIS_HOST=redis
REDIS_PORT=6379For HTTPS execution, place certificates in the ./certs/ folder:
server.crt- Public certificateserver.key- Private key
GET /healthcheck/
Returns the application status and its dependencies.
- URL:
https://********:9200/ - Username:
elastic - Application logs are automatically sent to Elasticsearch
- Host:
redis:6379 - Used for caching and sessions
- Interface for Elasticsearch log visualization
- Configure access through Elasticsearch
The Docker Compose setup includes:
- Ports: 8080 (HTTP), 8443 (HTTPS)
- Volumes: SSL certificates mounted as read-only
- Dependencies: Redis
- Image: redis:7.4-alpine
- Port: 6379
- Persistence: Local volume for data storage
- Configuration: Appendonly disabled for performance
- REST API: Built with Gin Framework
- Logging: Elasticsearch integration via custom middleware
- Caching: Redis for performance optimization
- Authentication: JWT middleware for security
- CORS: Cross-origin access configuration
- Rate Limiting: Request throttling control
- Health Check: Application monitoring endpoint
- HTTPS: TLS support with custom certificates
- Port conflicts: Make sure ports 8080, 8443, and 6379 are available
- SSL certificates: Ensure certificates are properly placed in
./certs/ - Elasticsearch connection: Verify the Elasticsearch URL and credentials
- Redis connection: Check if Redis service is running
# View application logs
docker-compose logs vision-data-api
# View Redis logs
docker-compose logs redis
# View all services logs
docker-compose logs- Fork the project
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License. See the LICENSE file for details.
For support and questions:
- Open an issue in the repository
- Contact the development team