thousand-sunny

module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 27, 2025 License: MIT

README ΒΆ

πŸ΄β€β˜ οΈ 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.

Thousand-Sunny-Image

πŸ—‚ 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!

πŸ“§ Contact

For more information or support, you can reach out to us.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL