A modern, production-ready Go web application built with Clean Architecture, Domain-Driven Design (DDD), and Enterprise patterns. Features comprehensive observability, AI-powered development, automated CI/CD, and self-documenting code standards.
- AI Code Generation: Auto-generate complete APIs from User Stories
- Self-Documenting Code: Minimal comments, maximum clarity through naming
- AI Coding Standards: Comprehensive rules for consistent, clean code
- Production-Ready Output: Generated code includes validation, error handling, tests
- Architecture Compliance: AI follows Clean Architecture patterns automatically
- Clean Architecture: Clear separation of Domain, Application, Infrastructure, Presentation layers
- Domain-Driven Design: Rich domain models with business logic encapsulation
- Dependency Injection: Uber FX for modular dependency management
- CQRS Pattern: Command Query Responsibility Segregation
- Repository Pattern: Abstract data access layer
- Self-Documenting Code: Clear naming eliminates need for comments
- HTTP Framework: Gin with custom middleware stack
- Database: PostgreSQL with GORM ORM
- Cache: Redis for high-performance caching
- Message Queue: RabbitMQ for async processing
- Authentication: JWT-based with security middleware
- Email Service: SMTP integration with MailCatcher for development testing
- Metrics: Prometheus + Grafana dashboards
- Distributed Tracing: Jaeger with OpenTelemetry
- Logging: Structured logging with Zap
- Health Checks: Comprehensive health monitoring
- Performance Profiling: pprof integration
- Hot Reload: Air for development
- Code Quality: golangci-lint, gosec, gofumpt
- Testing: Unit, integration, and benchmark tests
- Documentation: Swagger/OpenAPI generation
- Database Migrations: golang-migrate/migrate v4.19.0+ with timestamp-based versioning
- MCP Agents: AI-powered API testing, database management, and GitHub automation agents
- API Testing Agent: 6 tools for REST API testing (GET, POST, PUT, PATCH, DELETE, TEST)
- Database Agent: 6 tools for PostgreSQL management (connect, query, schema, migrate, analyze, generate SQL)
- GitHub Agent: 10 tools for GitHub automation (repo info, issues, PRs, workflows, code search, branches)
- Modular Architecture: Scalable, maintainable TypeScript implementation
- Full Documentation: Architecture, quick reference, and user guides included
- Integration Ready: Works with Claude Desktop and other MCP clients
go-mvc/
βββ cmd/ # Application entry points
β βββ main.go # Main server application
β βββ cli/ # Command-line interface
β βββ worker/ # Background worker
β βββ migrate/ # Database migration tool
βββ internal/ # Private application code
β βββ domain/ # Domain Layer - Business logic & entities
β β βββ auth/ # Authentication domain
β β βββ user/ # User domain
β β βββ job/ # Background job domain
β β βββ messaging/ # Messaging domain
β β βββ shared/ # Shared domain objects
β βββ application/ # Application Layer - Use cases
β β βββ commands/ # Write operations (CQRS)
β β βββ queries/ # Read operations (CQRS)
β β βββ dto/ # Data transfer objects
β β βββ services/ # Application services
β β βββ validators/ # Input validation
β β βββ event_handlers/ # Domain event handlers
β βββ infrastructure/ # Infrastructure Layer - Technical details
β β βββ cache/ # Cache implementations (Redis)
β β βββ database/ # Database setup
β β βββ persistence/ # Repository implementations
β β βββ messaging/ # Message queue (NATS)
β β βββ jobs/ # Background job system
β β βββ security/ # Security utilities
β β βββ tracing/ # Distributed tracing
β β βββ metrics/ # Prometheus metrics
β βββ presentation/ # Presentation Layer - HTTP handlers
β β βββ http/ # HTTP transport
β β βββ handlers/ # Request handlers
β β βββ middleware/ # HTTP middleware
β βββ modules/ # Dependency injection modules
βββ pkg/ # Public reusable packages
β βββ errors/ # Error utilities
β βββ jwt/ # JWT utilities
β βββ pagination/ # Pagination helpers
β βββ response/ # Response formatting
β βββ validator/ # Validation utilities
βββ configs/ # Configuration files
β βββ development.yaml # Development config
β βββ production.yaml # Production config
β βββ grafana/ # Grafana dashboards
βββ docs/ # Complete documentation (ebook format)
β βββ BOOK.md # Main table of contents
β βββ INDEX.md # Quick access index
β βββ README.md # Documentation overview
β βββ book/ # Organized chapters
β βββ 01-getting-started/
β βββ 02-architecture/
β βββ 03-development-guide/
β βββ 04-features/
β βββ 05-ai-development/
β βββ 06-operations/
β βββ appendix/
βββ scripts/ # Build and deployment scripts
π See Project Structure Guide for detailed explanations
- Go 1.24.5+
- Docker & Docker Compose
- Make (for build automation)
git clone https://github.com/tranvuongduy2003/go-mvc.git
cd go-mvc
# Setup development environment
make setup# Start database and cache
make docker-up-db
# Start monitoring stack
make monitoring# Development with hot reload
make dev
# Or run without hot reload
make run# Setup and build MCP agents
make mcp-all
# Test MCP agents
make mcp-test
# View MCP configuration
make mcp-config-show
# Check status
make mcp-statusπ See MCP Agents Documentation for detailed usage
make run
### 4. Access Services
- **Application**: http://localhost:8080
- **Health Check**: http://localhost:8080/health
- **Metrics**: http://localhost:8080/metrics
- **MailCatcher**: http://localhost:1080 (email testing interface)
- **Prometheus**: http://localhost:9091
- **Grafana**: http://localhost:3000 (admin/admin)
- **Jaeger**: http://localhost:16686
## π DevOps & CI/CD
### Automated CI/CD Pipeline
Complete DevOps automation vα»i GitHub Actions vΓ AI Assistant:
**6 Workflows Tα»± Δα»ng**:
- β
**CI Pipeline**: Build, test, lint vα»i PostgreSQL/Redis/NATS
- β
**Security**: Gosec, Trivy, CodeQL, secret scanning
- β
**Docker**: Multi-platform builds, GHCR publishing
- β
**Release**: Automated releases, binaries, deployment
- β
**Dependencies**: Auto-update Go modules, Actions, Docker
- β
**AI Assistant**: AI code review, docs, coverage analysis
**AI Development Scripts**:
```bash
# AI code review
./.github/scripts/ai-code-review.sh
# Generate CRUD code
./.github/scripts/ai-code-generator.sh Product full
# Analyze workflow
./.github/scripts/ai-workflow-optimizer.sh
AI Bot Commands (trong PR comments):
/ai review # Trigger AI code review
/ai optimize # Analyze workflow
/ai docs # Generate documentation
/ai help # Show available commandsQuick Start:
# 1. Push code triggers CI/CD automatically
git push origin master
# 2. Create PR vα»i AI assistance
gh pr create
# Comment: /ai review
# 3. Release vα»i tag
git tag -a v1.0.0 -m "Release v1.0.0"
git push origin v1.0.0
# Auto: build binaries, create release, deployπ Complete DevOps Guide:
- CI/CD Documentation - Workflows and automation
- AI DevOps - AI-powered development features
- MCP Agents - AI testing and automation tools
This application follows Clean Architecture principles with clear separation of concerns:
- Entities: Core business objects with rich behavior
- Value Objects: Immutable data structures
- Domain Events: Business event definitions
- Repository Interfaces: Data access contracts
- Domain Services: Complex business logic
- Commands: Write operations (CQRS)
- Queries: Read operations (CQRS)
- Application Services: Use case orchestration
- DTOs: Data transfer objects
- Validators: Input validation logic
- Event Handlers: Domain event processing
- Persistence: Database repository implementations
- Cache: Redis caching layer
- Messaging: NATS message broker
- Jobs: Background job processing
- Security: Authentication & authorization
- Tracing: OpenTelemetry integration
- Metrics: Prometheus metrics
- HTTP Handlers: REST API endpoints
- Middleware: Cross-cutting concerns (auth, logging, tracing)
- Response Formatting: Consistent API responses
- Dependency Injection: Uber FX modules for each domain
- Lifecycle Management: Startup/shutdown coordination
π See AGENT.md for comprehensive architecture guide and AI assistant instructions
This project includes comprehensive AI assistance for development. The AGENT.md file contains complete instructions for AI assistants working on this codebase.
AI will auto-generate complete, production-ready code following Clean Architecture:
- β Domain Layer: Entities, value objects, repository interfaces
- β Application Layer: Commands/queries, DTOs, validators, services
- β Infrastructure Layer: Repository implementations, migrations
- β Presentation Layer: HTTP handlers, routes, middleware
- β Integration: Complete dependency injection setup
- β Self-Documenting Code: Clear names, minimal comments
- AGENT.md - Complete AI assistant guide
- AI Coding Standards - Self-documenting code principles
- AI DevOps - AI-powered development workflow
Self-Documenting Code - Code should be clear through naming, not comments:
// β BAD - Unnecessary comments
// CreateUser creates a new user
func CreateUser(email, password string) (*User, error) {
// Validate email
if !isValid(email) {
return nil, errors.New("invalid")
}
...
}
// β
GOOD - Clear naming, no comments needed
func CreateUser(email, password string) (*User, error) {
if err := ValidateEmail(email); err != nil {
return nil, err
}
...
}π See AI Coding Standards for complete self-documenting code guide
make build # Build server binary
make build-all # Build all binaries
make run # Run server
make dev # Run with hot reloadmake validate-generated [entity] # Validate AI-generated code
make test-generated [entity] # Test generated components
make integrate-generated [entity] # Integrate with existing codebasemake test # Run all tests
make test-unit # Run unit tests
make test-integration # Run integration tests
make test-coverage # Run with coverage report
make benchmark # Run benchmarksmake lint # Run linter
make format # Format code
make vet # Run go vet
make security # Security scan# Migration management (golang-migrate/migrate v4.19.0+)
make migrate-up # Apply all pending migrations
make migrate-down # Rollback last migration
make migrate-create # Create new timestamped migration
make migrate-status # Show migration status
make migrate-version # Show current versionmake docker-up # Start all services
make docker-up-db # Start database only
make docker-up-monitoring # Start monitoring stack
make docker-down # Stop servicesmake mcp-setup # Install MCP dependencies
make mcp-build # Build MCP agents
make mcp-test # Run MCP tests
make mcp-all # Setup, build, and test
make mcp-status # Check MCP status
make mcp-docs # View MCP documentation
make mcp-config-show # Show configuration example
make mcp-dev # Watch mode (rebuild on changes)
make mcp-clean # Clean MCP artifacts
make mcp-rebuild # Clean rebuildπ MCP Agent Documentation:
- MCP README - Complete user guide with all 3 agents
- GitHub Agent Setup - GitHub automation guide
- MCP Architecture - Technical architecture
make monitoring # Start monitoring with URLs
make metrics # View metrics
make health # Health check
make trace-test # Generate test traces- HTTP Metrics: Request duration, status codes, throughput
- System Metrics: CPU, memory, goroutines
- Database Metrics: Connection pool, query performance
- Cache Metrics: Hit/miss ratios, operation latency
- Request Tracing: End-to-end request flow
- Database Queries: Query execution traces
- External Calls: Third-party service calls
- Error Tracking: Exception and error traces
- Structured Logging: JSON formatted logs
- Log Levels: Debug, Info, Warn, Error
- Request Logging: HTTP request/response logs
- Error Logging: Detailed error information
# Build Docker image
make docker-build
# Start production stack
docker-compose up -d- Development:
configs/development.yaml - Production:
configs/production.yaml
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow Clean Architecture principles
- Use self-documenting code (see AI Coding Standards)
- Write comprehensive tests
- Add proper documentation to AGENT.md or README.md
- Use conventional commits
- Ensure code quality with linters
- NO unnecessary comments - code should be clear through naming
- DO NOT create summary markdown files after implementing features
- AGENT.md - Complete AI assistant guide and architecture
- README.md - This file, project overview and quick start
- CI/CD Guide - Complete CI/CD automation documentation
- AI DevOps - AI-powered development workflow
- AI Coding Standards - Self-documenting code principles
- MCP README - API Testing, Database, and GitHub agents
- GitHub Agent Setup - GitHub automation setup
- MCP Architecture - Technical architecture details
- MCP Changelog - Version history and changes
- JWT Authentication: Secure token-based auth
- CORS Protection: Cross-origin resource sharing
- Rate Limiting: Request throttling
- Security Headers: XSS, CSRF protection
- Input Validation: Comprehensive request validation
- SQL Injection Prevention: Parameterized queries
- Connection Pooling: Database connection optimization
- Caching Strategy: Redis-based caching
- Goroutine Management: Efficient concurrent processing
- Memory Management: Optimized memory usage
- Profiling: Built-in performance profiling
This project is licensed under the MIT License - see the LICENSE file for details.
For questions, issues, or contributions:
- GitHub Issues: Create an issue
- Documentation: See AGENT.md for comprehensive guide
- Email: [email protected]
- π€ AGENT.md - AI assistant complete guide
- π README.md - Project overview (this file)
- π CI/CD Guide - DevOps automation
- π€ AI DevOps - AI development workflow
- π AI Coding Standards - Code quality principles
- π§ MCP Agents - Testing and automation tools
β Star this repository if you find it helpful!
Built with β€οΈ using Clean Architecture, DDD, and Self-Documenting Code principles