Giter Club home page Giter Club logo

gin-base's Introduction

Gin Base

A template of clean architecture with gin framework, go-fx as dependency container, gorm as orm for database related operations.

To learn about project structure and dependency injection please go through here

Running the project

  • Make sure you have docker installed.
  • Copy .env.example to .env
  • Run docker-compose up -d
  • Go to localhost:8080 to verify if the server works.
  • Pgadmin Database Management runs at 5051 .
  • Adminer Database Management runs at 8081

If you are running without docker be sure database configuration is provided in .env file and run go run . app:serve

Environment Variables

Variables Defined in the project
Key Value Desc
SERVER_PORT 8080 Port at which app runs
ENV development,production App running Environment
LOG_OUTPUT ./server.log Output Directory to save logs
LOG_LEVEL info Level for logging (check lib/logger.go:172)
DB_USER username Database Username
DB_PASS password Database Password
DB_HOST 0.0.0.0 Database Host
DB_PORT 5432 or 3306 Database Port
DB_NAME test Database Name
JWT_SECRET secret JWT Token Secret key
ADMINER_PORT 5051 or 8081 Adminer DB Port
DEBUG_PORT 8082 Port that delve debugger runs in

Migration Commands

⚓️   Add argument p=host if you want to run the migration runner from the host environment instead of docker environment. Check #19 for more details. eg; make p=host migrate-up

Migration commands available
Command Desc
make migrate-up runs migration up command
make migrate-down runs migration down command
make force Set particular version but don't run migration
make goto Migrate to particular version
make drop Drop everything inside database
make create Create new migration file(up & down)

Implemented Features

  • Dependency Injection (go-fx)
  • Routing (gin web framework)
  • Environment Files
  • Logging (file saving on production) zap
  • Middlewares (cors)
  • Database Setup (postgres or mysql)
  • Models Setup and Automigrate (gorm)
  • Repositories
  • Implementing Basic CRUD Operation
  • Authentication (JWT)
  • Migration Runner Implementation
  • Live code refresh
  • Dockerize Application with Debugging Support Enabled. Debugger runs at 8082. Vs code configuration is at .vscode/launch.json which will attach debugger to remote application. Learn More
  • Cobra Commander CLI Support. try: go run . --help

Contributing

Please open issues if you want the template to add some features that is not in todos. 🙇‍♂️

Create a PR with relevant information if you want to contribute in this template.

License

This project is licensed under the terms of the MIT license.

gin-base's People

Contributors

thinhhuynh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.