A production-ready backend API built with Go, following clean architecture principles.
- Clean Architecture structure
- PostgreSQL with pgx driver
- MinIO for object storage
- JWT authentication
- REST API with chi router
- Structured logging with zap
- Docker & Docker Compose ready
- Database migrations
- Graceful shutdown
- Language: Go 1.22+
- Web Framework: Chi Router
- Database: PostgreSQL 16
- Object Storage: MinIO
- Authentication: JWT
- Logging: Zap
- Containerization: Docker
- π API Testing with Postman - Complete guide for testing all endpoints
- π¦ Postman Collection - Import into Postman
- π§ Postman Environment - Environment variables
mlp/
βββ cmd/
β βββ main.go # Application entry point
βββ internal/
β βββ config/
β β βββ config.go # Configuration management
β βββ middleware/
β β βββ auth.go # JWT authentication middleware
β βββ user/
β β βββ handler.go # HTTP handlers
β β βββ service.go # Business logic
β β βββ repository.go # Database access
β β βββ model.go # Data models
β βββ lecture/
β βββ audio/
β βββ video/
β βββ storage/
β βββ minio.go # MinIO client
βββ migrations/
β βββ 001_init.sql # Database migrations
βββ lipsync-service/ # Python service placeholder
βββ .env # Environment variables
βββ .env.example # Environment variables template
βββ docker-compose.yml # Docker services configuration
βββ Dockerfile # Application container
βββ Makefile # Build and run commands
βββ go.mod # Go dependencies
- Go 1.22+
- Docker & Docker Compose
- PostgreSQL 16 (if running locally)
- MinIO (if running locally)
- Clone the repository
- Copy environment variables:
cp .env.example .env- Update
.envwith your configuration
Start all services:
make docker-upStop all services:
make docker-downView logs:
make docker-logs- Install dependencies:
make deps- Start PostgreSQL and MinIO (via Docker):
docker-compose up db minio -d- Run migrations:
make migrate- Run the application:
make runGET /api/v1/health
POST /api/v1/auth/register
POST /api/v1/auth/login
POST /api/v1/lectures
GET /api/v1/lectures
GET /api/v1/lectures/{id}
GET /api/v1/audios/{id}
GET /api/v1/audios/lecture/{lecture_id}
GET /api/v1/videos/{id}
GET /api/v1/videos/audio/{audio_id}
See .env.example for all available configuration options.
Key variables:
APP_PORT: Server port (default: 8080)DB_HOST: PostgreSQL hostDB_PORT: PostgreSQL portDB_USER: PostgreSQL userDB_PASSWORD: PostgreSQL passwordDB_NAME: Database nameJWT_SECRET: JWT signing secretJWT_EXPIRATION: Token expiration timeMINIO_ENDPOINT: MinIO server endpointMINIO_ACCESS_KEY: MinIO access keyMINIO_SECRET_KEY: MinIO secret keyMINIO_BUCKET: MinIO bucket name
id(UUID, Primary Key)email(VARCHAR, Unique)password_hash(VARCHAR)created_at(TIMESTAMP)
id(UUID, Primary Key)user_id(UUID, Foreign Key)topic(VARCHAR)content(TEXT)created_at(TIMESTAMP)
id(UUID, Primary Key)lecture_id(UUID, Foreign Key)url(TEXT)created_at(TIMESTAMP)
id(UUID, Primary Key)audio_id(UUID, Foreign Key)url(TEXT)created_at(TIMESTAMP)
make run # Run the application locally
make build # Build the application binary
make migrate # Run database migrations
make docker-up # Start all services with docker-compose
make docker-down # Stop all services
make docker-logs # Show docker logs
make clean # Clean build artifacts and stop docker
make test # Run tests
make deps # Download and tidy dependencies
make fmt # Format code
make lint # Run linter- Port: 5432
- Admin UI: N/A
- API Port: 9000
- Console Port: 9001
- Access console at: http://localhost:9001
- Port: 5000
- Python-based service for future lip sync integration
Create a new SQL file in the migrations/ directory with format XXX_description.sql.
Format your code:
make fmtRun linter:
make lint- Update JWT secret in production
- Use strong database passwords
- Enable SSL for MinIO in production
- Configure proper CORS settings
- Set appropriate rate limits
- Enable request logging
- Use environment-specific configurations
- Implement proper backup strategies
MIT