Skip to content

quangdangfit/go-admin

Repository files navigation

Go Admin

Master

RBAC scaffolding based on Gin + Gorm + Casbin + Dig
Documentation here.

How to run

Required

  • Postgres
  • Redis

Config

Simply run make startup, or run following commands step - by - step:

  • Copy config file: cp config/config.sample.yaml config/config.yaml

  • You should modify config/config.yaml

database:
  host: localhost
  port: 5432
  name: goadmin
  env: production
  user: postgres
  password: 1234
  sslmode: disable

redis:
  enable: true
  host: localhost
  port: 6397
  password:
  database: 0

cache:
  enable: true
  expiry_time: 3600

Migration - Create Admin User

$ make admin

Run

$ go run main.go 

Run with docker

$ docker-compose up -d

Document

  • API document at: http://localhost:8888/swagger/index.html

Structure

├── app
│   ├── api             # Handle request & response
│   ├── dbs             # Database Layer
│   ├── middleware      # Middlewares
│   │   ├── cache           # Cache middleware
│   │   ├── jwt             # JWT middleware
│   │   └── roles           # Authorization middleware
│   ├── migration       # Migration
│   ├── mocks           # Mocks
│   ├── models          # Models
│   ├── repositories    # Repository Layer
│   │   └── impl            # Implement repositories
│   ├── router          # Router api
│   ├── schema          # Schemas
│   ├── services        # Business Logic Layer
│   │   └── impl            # Implement services
│   └── test            # Test
├── cmd                 # Contains commands 
├── config              # Config files 
├── docs                # Swagger API document
├── pkg                 # Internal packages
│   ├── app                 # App packages
│   ├── errors              # Errors packages
│   ├── http                # HTTP packages
│   ├── jwt                 # JWT packages
│   └── utils               # Utils packages
├── scripts             # Scripts

Techstack

  • RESTful API
  • Gorm
  • Swagger
  • Logging
  • Jwt-go
  • Gin
  • Graceful restart or stop (fvbock/endless)
  • Cron Job
  • Redis
  • Dig (Dependency Injection)