Welcome aboard the Going-Merry-Go! Inspired by the iconic ship from the anime One Piece, this project is a robust and flexible Go project starter kit. It's designed to help you quickly set up your Go applications with the right structure and essential tools.
βββ app
β βββ bootstrap # Contains initialization logic for starting the application
β βββ registry # Manages dependency injection or service registration
βββ bin # Holds executable files and scripts for running the application
βββ cmd
β βββ grpc # Entry point for starting the gRPC server
β βββ restapi # Entry point for starting the REST API server
β βββ scheduler # Entry point for the scheduler service
β βββ worker # Entry point for worker processes or background jobs
βββ config # Configuration files for the application
βββ constant
β βββ ctxkey # Constants for context keys used across the application
β βββ rediskey # Redis-related key constants
β βββ restkey # Constants specific to the REST API
βββ database
β βββ migrations # Database migration scripts to manage schema changes
β βββ seeders # Seed data for initializing the database with default values
βββ docs
β βββ vscode-ext # Documentation for Visual Studio Code extensions or related setup
βββ gen
β βββ grpc
β β βββ greating # Auto-generated code for the "greating" gRPC service
β β βββ health # Auto-generated code for the health check gRPC service
β βββ pkl
β βββ appconfig # Generated code for application configuration
β βββ grpcconfig # gRPC configuration details
β βββ httpconfig # HTTP server configuration details
β βββ jwtconfig # JWT (JSON Web Token) configuration settings
β βββ logconfig
β β βββ timeformat # Time format settings for logging
β βββ minioconfig # MinIO (object storage) configuration
β βββ mysqlconfig # MySQL database configuration
β βββ natsconfig # NATS (messaging system) configuration
β βββ otelconfig # OpenTelemetry configuration for distributed tracing
β βββ redisconfig # Redis database configuration
βββ internal
β βββ entity # Data models and entities used in the application
β βββ grpc
β β βββ interceptor
β β β βββ stream # Stream interceptors for gRPC requests
β β β βββ unary # Unary interceptors for gRPC requests
β β β βββ util # Utility functions for gRPC interceptors
β β βββ service # gRPC service implementations
β βββ http
β β βββ dto # Data Transfer Objects for HTTP requests and responses
β β βββ handler # Handlers for processing HTTP requests
β β βββ interceptor # Interceptors for HTTP requests
β β βββ middleware # Middleware components for HTTP processing
β β βββ router # Routing logic for HTTP endpoints
β βββ provider
β β βββ api # API providers or service interfaces
β β βββ attribute # Attribute-related logic or utilities
β β βββ impl # Implementation of the providers
β βββ repo
β β βββ api # API for the repository layer
β β βββ attribute # Attribute-related logic for the repository layer
β β βββ impl # Implementation of repositories
β βββ scheduler # Scheduler logic for timed or recurring tasks
β βββ service
β β βββ api # Service interfaces
β β βββ attribute # Attribute-related logic for services
β β βββ impl # Implementation of services
β βββ worker
β βββ pub # Publishing logic for worker processes
β βββ sub # Subscription logic for worker processes
βββ pkg
β βββ xfilter # Utility for data filtering
β βββ xhttpin # Helper functions for HTTP input processing
β βββ xhttputil # Utilities for working with HTTP
β βββ xlazy # Lazy evaluation utilities
β βββ xlogger # Logging utilities and helpers
β βββ xresponse # Utility for handling HTTP responses
β βββ xtracer # Tools for distributed tracing
β βββ xvalidate # Input validation utilities
βββ pkl # Placeholder for Pickle files for configuration
βββ protos # Protocol buffer (.proto) files for defining gRPC services
βββ storage
βββ assets # Static assets such as images or other resources
βββ logs # Log files generated by the application
The project is organized to support different modules such as REST API, gRPC, Pub/Sub, and Cron Jobs, making it easier for you to develop scalable and maintainable applications.
- APP HTTP/1.1 - REST API β
- APP HTTP/2 - gRPC β
- APP Nats.io - Worker Pub/Sub β³ (In Progress)
- APP CronJob - Scheduler Cron Job β³ (In Progress)
Here's a quick look at what's done and what's still in progress:
- ποΈ Base Structural Directory: Well-organized code structure to get you started quickly.
- βοΈ Setup Basic Generator Configuration: Tools to generate handlers, services, and more.
- π§ Registry Dependency, Repository, and Service: Dependency injection setup.
- π HTTP Handler and Router Loader: Load and manage routes effortlessly.
- π‘οΈ HTTP Interceptor Handler: Middleware to handle requests seamlessly.
- π DTO Validation: Validate incoming data with ease.
- π¦ DB Migrations and Seeders: Database migration and seeding tools.
- π Logging: Integrated logging for better observability.
- π Makefile Runner: Simple command runners for building and testing.
- π Open Telemetry Integration: Track and monitor your services.
- π³ Docker Integration: Containerize the application.
- π Open API Generator Docs: Auto-generate API documentation.
- βοΈ CMD Generator: Tool to generate handlers, middleware, routers, repos, and services.
- π§ͺ Unit Tests: Comprehensive unit testing setup.
To get started with Going-Merry-Go, follow these steps:
# Clone the repository
git clone https://github.com/Mind2Screen-Dev-Team/going-merry-go.git
# Navigate to the project directory
cd going-merry-go
# Install dependencies and set up the project
make setup
# Run the application
make go-run app=restapi
The Makefile provides a set of commands to help you manage and interact with your Go project efficiently. Below is a list of the available commands:
make setup
: Sets up the project by installing necessary tools likeprotoc-gen-go
,protoc-gen-go-grpc
,goose
, andpkl-gen-go
.
make go-tidy
: Cleans up thego.mod
file by removing unnecessary dependencies.make go-run app=<application>
: Runs the specified application.make go-build app=<application>
: Builds the specified application.make go-gen-proto
: Generates Go code from.proto
files.
make migrate-up
: Migrates the database to the most recent version.make migrate-up-by-one
: Migrates the database up by one version.make migrate-down
: Rolls back the database version by one.make migrate-status
: Displays the migration status of the database.make migrate-create n=<migration_name> t=<sql|go>
: Creates a new migration file.
make seeder-up
: Runs the seeders to populate the database.make seeder-down
: Rolls back the seeders by one version.make seeder-create n=<seeder_name> t=<sql|go>
: Creates a new seeder file.
make print-path
: Displays the currentPATH
environment variable.make migrate-help
: Provides help on migration commands.make go-help
: Provides help on Go commands.
# Setup your project workspace
make setup
# Generate Go code from protobuf files
make go-gen-proto
# Run a Go application (example: restapi)
make go-run app=restapi
# Migrate the database to the latest version
make migrate-up
# Create a new migration file
make migrate-create n=create_users_table t=sql
These commands make it easy to manage your Go application, including its dependencies, database migrations, and proto file generation.
For detailed documentation and advanced usage, please refer to the Wiki page.
This project is licensed under the MIT License. See the LICENSE file for details.
We welcome contributions! Feel free to submit issues, fork the repository, and send pull requests.
Give a βοΈ if you like this project!
For more information or support, you can reach out to us.