π΄ββ οΈ Thousand Sunny π΄ββ οΈ - Project Skeleton
Embark on your next adventure with the Thousand Sunny! Inspired by the legendary ship from One Piece, this Go project skeleton is designed for speed, flexibility, and scalability. Whether youβre building small tools or large applications, the Thousand Sunny will guide your journey to success.

π Project Structure
βββ app
β βββ dependency # External dependencies or libraries used across the application.
β β βββ ... # Create Dependency Here.
β βββ module # Application-specific modules encapsulating core features.
β β βββ ... # Create Module Here.
β βββ registry # Manages the initialization and registration of application components.
β βββ ... # Create Registry Here.
βββ bin # Compiled binaries or executables for the application.
βββ cmd
β βββ asynq # Main entry point for the 'asynq' application.
β βββ core # Main entry point for the 'core' application.
βββ config # Configuration files for managing application settings.
βββ constant # Application-wide constants to avoid hardcoding values.
βββ database
β βββ migrations # Database schema migrations for version control.
β β βββ ... # List of migration files.
β βββ queries # Custom Generator For SQLC queries for specific operations.
β β βββ ... # List of sqlc generator queries.
β βββ seeders # Seed data for initializing or populating the database.
β β βββ ... # List of seeder files.
β βββ ... # database codes.
βββ gen
β βββ repo # Auto-generated repository code for data access.
βββ internal # Internal packages for application-specific functionality.
β βββ schema # Collections of schema.
β β βββ ... # list of schema.
β βββ helper # Collections of short function for helpers.
β β βββ ... # list of helpers
β βββ asynq # Handles asynchronous task queues.
β β βββ router # Base Asynq routing configuration (No need to add Something here).
β β βββ worker # Specific handlers for processing workers.
β β β βββ ... # Other Worker Routing Handlers.
β β βββ scheduler # Specific handlers for processing schedulers.
β β βββ ... # Other Scheduler Routing Handlers.
β βββ http # HTTP server and related components.
β β βββ handler
β β β βββ health # Example. Handlers for health-related endpoints.
β β β βββ user # Example. Handlers for user-related endpoints.
β β β βββ ... # Other Routing Handlers.
β β βββ middleware # HTTP middleware for request processing.
β β β βββ global # Middleware applied to all requests globally.
β β β β βββ ... # Other Global Middleware.
β β β βββ private # Middleware for restricted/private routes.
β β β βββ ... # Other Private Middleware.
β β βββ router # Base HTTP routing configuration (No need to add Something here).
β βββ schema # Defind Schema Database Object Table and column.
β βββ provider # External Provider Data access layer.
β β βββ api # External Provider interfaces for APIs.
β β β βββ ... # Other API External Provider.
β β βββ attr # External Providers for handling attributes.
β β β βββ ... # Other Attribute External Provider.
β β βββ impl # Implementation of repository interfaces.
β β βββ ... # Other Implementaion External Provider.
β βββ repo # Data access layer.
β β βββ api # Repository interfaces for APIs.
β β β βββ ... # Other API Repository.
β β βββ attr # Repositories for handling attributes.
β β β βββ ... # Other Attribute Repository.
β β βββ impl # Implementation of repository interfaces.
β β βββ ... # Other Implementaion Repository.
β βββ service # Business logic layer.
β βββ api # API-specific services.
β β βββ ... # Other API Service.
β βββ attr # Services for managing attributes.
β β βββ ... # Other Attribute Service.
β βββ impl # Implementation of service interfaces.
β βββ ... # Other Implementaion Service.
βββ pkg # Utility and reusable packages.
β βββ xasynq # Asynq sever helpers and utilities.
β βββ xauth # Authentication helpers and utilities.
β βββ xecho # Extensions for the Echo web framework.
β βββ xfilter # Utilities for filtering data in requests.
β βββ xhttp # General HTTP helpers and utilities.
β βββ xlog # Logging utilities.
β βββ xmail # Email helpers and utilities.
β βββ xpanic # Panic recovery utilities for error handling.
β βββ xresp # Response utilities for standardizing HTTP responses.
β βββ xsecurity # Security for encryption and decryption utilities.
β βββ xtracer # Open-Telemtry Pkg Helper.
β βββ xvalidate # Validation Pkg for helper mapping / defind error.
βββ storage # Storage for static files and logs.
βββ assets # Static assets like images or documents.
β βββ ... # Add other assets here.
βββ cron # Cron configuration.
β βββ ... # Add other cron configuration here.
βββ template # Template files.
β βββ ... # Add other template here.
βββ logs # Application log files.
βββ <server.name> # Based `config.yaml` on server section.
βββ debug # Debug-level logs.
βββ io # Input/output (incoming logs) operation logs.
βββ trx # Transaction logs for auditing or debugging.
π Features
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 Uber Fx: Uber Dependency injection tool setup.
- π§ Setup Uber Config: Uber Configuration tool setup.
- π¦ SQLC Repositories Generator: Repository generator tools.
- π Asynq Redis Queue Worker and Scheduler Handler and Router Loader: Load and manage routes effortlessly.
- π HTTP Handler and Router Loader: Load and manage routes effortlessly.
- π 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.
- π³ Docker Integration: Containerize the application.
- π Open-Telemetry: Add Tracer, Metric and Logs Configuration.
π¦ Installation and Setup
To get started, follow these steps:
# Clone the repository
git clone git@github.com:Mind2Screen-Dev-Team/thousand-sunny.git
# Navigate to the project directory
cd thousand-sunny
# Install dependencies and set up the project
make setup
# Copy example config and fill the value of configuration for deployment.
cp stack.example.env stack.asynq.env
cp stack.example.env stack.core.env
# The `config.yaml` file for application configuration.
cp config.example.yaml config.yaml
# Run LOCAL for simplify step
# Run the application
make go-run a=core
# Run on Docker
# The `config.yaml` file for application configuration.
cp config.example.yaml config.yaml
# Make it script deployment executeable
chmod +x ./deploy.*.sh
# Version must follow the sematic versioning format 'X.Y.Z' (e.g., 1.0.0).
# Please refer on this docs: https://semver.org/
# For deploy up
make deploy-asynq-up v=<version>
make deploy-core-up v=<version>
# For deploy down
make deploy-asynq-down
make deploy-core-down
βοΈ Makefile Commands
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:
Setup Commands
make setup: Sets up the project by installing necessary tools like goose and sqlc.
Sqlc Commands
make sqlc-gen: Sets up the project by generating sqlc repositories.
Go Commands
make go-tidy: Cleans up the go.mod file by removing unnecessary dependencies.
make go-run a=<application>: Runs the specified application.
make go-run a=<application> c=<configuration file>: Runs the specified application with configuration.
make go-build a=<application>: Builds the specified application.
Utility Commands
make print-path: Displays the current PATH environment variable.
make go-help: Provides help on Go commands.
Examples
# Setup your project workspace
make setup
# Run a Go application (example: core, asynq)
make go-run a=asynq
make go-run a=core
These commands make it easy to manage your Go application, including its dependencies, database migrations, and proto file generation.
π Documentation
For detailed documentation and advanced usage, please refer to the Wiki page.
π License
This project is licensed under the MIT License. See the LICENSE file for details.
π€ Contributing
We welcome contributions! Feel free to submit issues, fork the repository, and send pull requests.
π Show Your Support
Give a βοΈ if you like this project!
For more information or support, you can reach out to us.