This is a professional, production-ready template for building Go applications following the Modular Monolith (Modulith) pattern. Designed for high-performance, maintainability, and scalability, it allows your application to evolve from a monolith to microservices without architectural friction.
- ποΈ Modular Architecture: Clean domain boundaries with decoupling via an internal Event Bus.
- π¦ Registry Pattern: Explicit dependency injection without magic for maximum control and testability.
- π gRPC & Protobuf: High-performance, type-safe RPC communication with automated generation via
buf. - ποΈ SQLC & Migrations: Type-safe data access and multi-module schema management with
golang-migrate. - β‘ High-Performance Caching: Native support for Valkey (the open-source Valkey alternative) for sessions and rate limiting.
- π Complete Auth System: Passwordless login, sessions, JWT, refresh tokens, and RBAC.
- π OAuth/Social Login: Integrated with Goth for Google, Facebook, GitHub, Apple, Microsoft, and Twitter/X.
- π€ Messaging Bot Engine: Built-in support for WhatsApp and Telegram provider integrations.
- π WebSocket Real-Time: Bidirectional communication integrated with the event bus for instant notifications.
- π Observability Stack: Native integration with OpenTelemetry, Jaeger (Tracing), Prometheus (Metrics), and Grafana dashboards.
- βοΈ Flexible Configuration: Hierarchy-based system (PORT > YAML > .env > system ENV > defaults) with source logging.
- β‘ Resilience & Errors: Integrated circuit breakers, retries, and a domain-specific error system mapped to gRPC codes.
- π§ Notification System: Extensible providers (SendGrid, Twilio, AWS SES/SNS) with template support.
- π Optional GraphQL: Advanced support with gqlgen for flexible frontend APIs (subscriptions included).
- π§ͺ Test Utilities: Comprehensive suite (
internal/testutil) for integration tests with Testcontainers, gRPC servers, and mocks. - π οΈ DevX Excellence: Hot reload with Air, task automation with Just, and environment diagnostics with
doctor.
- Go 1.25+
- Docker & Docker Compose
- Development tools:
sqlc,buf,migrate,air,golangci-lint,just.
The fastest way to get started is using the integrated setup and run command:
git clone https://github.com/LoopContext/go-modulith-template.git my-project
cd my-project
just devThis single command will:
- Start the minimal Docker infrastructure (DB + Valkey).
- Wait for the database to be ready.
- Run all database migrations.
- Seed the database with test users (
admin,system,user). - Install frontend dependencies (
web/solid-example). - Start the full stack (Backend + Frontend) with Hot Reload in a 3-pane tmux session.
To run a complete representative flow (E2E) and see how the system handles Auth, Events, and Logic:
just exampleπ‘ Tip: For a full "setup + example" demo in one go, use
just demo.
Run the monolith with hot reload (monitors code, proto, sql, and configs):
just devRun a specific module (e.g., auth):
just dev-module authcmd/: Main entry points (server, worker, admin tasks, migration ops).internal/: Core shared services (registry, cache, events, authz, telemetry).modules/: Domain-specific modules (auth, stock, etc.). Each module is independent.proto/: Protobuf definitions for gRPC and Event schemas.scripts/: Utility scripts for DevX (scaffolding, validation, e2e).web/: Documentation site and optional frontend examples.
- Architecture Guide - Patterns, internal communication, and error handling.
- Module Communication - In-process vs Network gRPC and the Event Bus.
- OAuth/Social Integration - Social login setup guide.
- Messaging Bot Engine - WhatsApp and Telegram provider setup.
- Real-Time WebSocket - Bidirectional event broadcasting.
- GraphQL Integration - Optional gqlgen setup.
- Deployment Guide - Kubernetes, Helm Charts, and IaC (OpenTofu).
just proto: Generate gRPC and OpenAPI code.just sqlc: Generate type-safe SQL code.just new-module <name>: Scaffold a new domain module.just setup: Automated, non-interactive setup (infra + migrate + seed).just example: Run a representative example flow (E2E) to see the system in action.just demo: Complete end-to-end demo (setup + example).just test: Run all unit and integration tests.just lint: Run strict linter (MANDATORY for quality).just visualize: Generate an interactive module graph (docs/module-graph.html) with modules (gRPC + event bus) and database (tables from migrations) views; alsoFORMAT=json|dotfor machine-readable output.just admin TASK=<name>: Execute maintenance tasks (e.g.,cleanup-sessions).
Made with β€οΈ for developers seeking operational excellence.
