Go to file
Habib Fatkhul Rohman 465908965e feat: Add new entities for maintenance management and user roles
- Created M_Location, M_MaintenanceGroup, M_MaintenanceGroupRole, M_MaintenanceGroupUser, M_MaintenanceScheduleHeader, M_MaintenanceScheduleLine, M_MaintenanceStaff, M_Menu_Client, M_Menu, M_Permissions, M_Role, M_Role_Menu, M_Role_Permission, M_User, M_User_Role entities.
- Implemented relationships and foreign keys for user roles and permissions.
- Added JSON seed files for roles and user roles, along with corresponding seed functions.
- Updated migration and seeder files to include new entities and ensure proper database setup.
- Commented out legacy product and tenant entities and their seed functions for future reference.
2025-10-21 15:06:43 +07:00
.github Initial commit 2025-09-10 14:38:44 +07:00
cmd Refactor main.go to improve logging setup and remove unused imports 2025-10-15 21:13:11 +07:00
config Initial commit 2025-09-10 14:38:44 +07:00
database feat: Add new entities for maintenance management and user roles 2025-10-21 15:06:43 +07:00
docker Update Dockerfile to run migrations and seed data; add Nginx route for log retrieval 2025-10-21 15:05:49 +07:00
middlewares Replace TenantID with ClientID in authentication middleware for consistency 2025-10-15 21:11:16 +07:00
modules Add logs controller and routes for log retrieval by month 2025-10-21 15:05:22 +07:00
pkg Add utility functions for password hashing and data validation 2025-10-15 21:14:40 +07:00
providers Implement product module with CRUD operations and integrate with multi-tenant architecture 2025-09-16 12:05:24 +07:00
script Add support for fresh migrations in command script 2025-09-16 11:01:13 +07:00
tests Initial commit 2025-09-10 14:38:44 +07:00
.air.toml Initial commit 2025-09-10 14:38:44 +07:00
.env.example Initial commit 2025-09-10 14:38:44 +07:00
.gitignore Update .gitignore and go.mod to include log files and add logrus dependency 2025-10-15 21:15:05 +07:00
LICENSE Initial commit 2025-09-10 14:38:44 +07:00
Makefile Initial commit 2025-09-10 14:38:44 +07:00
README.md Initial commit 2025-09-10 14:38:44 +07:00
docker-compose.yml Initial commit 2025-09-10 14:38:44 +07:00
go.mod Update .gitignore and go.mod to include log files and add logrus dependency 2025-10-15 21:15:05 +07:00
go.sum Update .gitignore and go.mod to include log files and add logrus dependency 2025-10-15 21:15:05 +07:00
logs.html Initial commit 2025-09-10 14:38:44 +07:00

README.md

Golang Gin Clean Starter

You can join in the development (Open Source). Let's Go!!!

Introduction 👋

This project implements Clean Architecture principles with the ControllerServiceRepository pattern. This approach emphasizes clear separation of responsibilities across different layers in Golang applications. The architecture helps keep the codebase clean, testable, and scalable by dividing application logic into distinct modules with well-defined boundaries.

image

Logs Feature 📋

The application includes a built-in logging system that allows you to monitor and track system queries. You can access the logs through a modern, user-friendly interface.

Accessing Logs

To view the logs:

  1. Make sure the application is running
  2. Open your browser and navigate to:
http://your-domain/logs

Features

  • Monthly Filtering: Filter logs by selecting different months
  • Real-time Refresh: Instantly refresh logs with the refresh button
  • Expandable Entries: Click on any log entry to view its full content
  • Modern UI: Clean and responsive interface with glass-morphism design

Logs Interface

Prerequisite 🏆

  • Go Version >= go 1.20
  • PostgreSQL Version >= version 15.0

How To Use

  1. Clone the repository or Use This Template
git clone https://github.com/Caknoooo/go-gin-clean-starter.git
  1. Navigate to the project directory:
cd go-gin-clean-starter
  1. Copy the example environment file and configure it:
cp .env.example .env

Available Make Commands 🚀

The project includes a comprehensive Makefile with the following commands:

Development Commands

make dep          # Install and tidy dependencies
make run          # Run the application locally
make build        # Build the application binary
make test         # Run tests

Local Database Commands (without Docker)

make migrate-local      # Run migrations locally
make seed-local        # Run seeders locally  
make migrate-seed-local # Run migrations + seeders locally

Docker Commands

make init-docker       # Initialize and build Docker containers
make up               # Start Docker containers
make down             # Stop Docker containers
make logs             # View Docker logs

Docker Database Commands

make migrate          # Run migrations in Docker
make seed            # Run seeders in Docker
make migrate-seed    # Run migrations + seeders in Docker
make container-go    # Access Go container shell
make container-postgres # Access PostgreSQL container

There are 2 ways to run the application:

With Docker

  1. Build and start Docker containers:
make init-docker
  1. Run Initial UUID V4 for Auto Generate UUID:
make init-uuid
  1. Run Migration and Seeder:
make migrate-seed

Without Docker

  1. Configure .env with your PostgreSQL credentials:
DB_HOST=localhost
DB_USER=postgres
DB_PASS=
DB_NAME=
DB_PORT=5432
  1. Open the terminal and set up PostgreSQL:
  • If you haven't downloaded PostgreSQL, download it first.
  • Run:
    psql -U postgres
    
  • Create the database according to what you put in .env:
    CREATE DATABASE your_database;
    \c your_database
    CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
    \q
    
  1. Install dependencies and run the application:
make dep              # Install dependencies
make migrate-local    # Run migrations
make seed-local       # Run seeders (optional)
make run              # Start the application

Run Migrations, Seeder, and Script

To run migrations, seed the database, and execute a script while keeping the application running, use the following command:

go run cmd/main.go --migrate --seed --run --script:example_script
  • --migrate will apply all pending migrations.
  • --seed will seed the database with initial data.
  • --script:example_script will run the specified script (replace example_script with your script name).
  • --run will ensure the application continues running after executing the commands above.

Migrate Database

To migrate the database schema

go run cmd/main.go --migrate

This command will apply all pending migrations to your PostgreSQL database specified in .env

Seeder Database

To seed the database with initial data:

go run cmd/main.go --seed

This command will populate the database with initial data using the seeders defined in your application.

Script Run

To run a specific script:

go run cmd/main.go --script:example_script

Replace example_script with the actual script name in script.go at script folder

If you need the application to continue running after performing migrations, seeding, or executing a script, always append the --run option.

What did you get?

By using this template, you get a ready-to-go architecture with pre-configured endpoints. The template provides a structured foundation for building your application using Golang with Clean Architecture principles.

Postman Documentation

You can explore the available endpoints and their usage in the Postman Documentation. This documentation provides a comprehensive overview of the API endpoints, including request and response examples, making it easier to understand how to interact with the API.

Issue / Pull Request Template

The repository includes templates for issues and pull requests to standardize contributions and improve the quality of discussions and code reviews.

  • Issue Template: Helps in reporting bugs or suggesting features by providing a structured format to capture all necessary information.
  • Pull Request Template: Guides contributors to provide a clear description of changes, related issues, and testing steps, ensuring smooth and efficient code reviews.