MCPcopy
hub / github.com/LyricTian/gin-admin

github.com/LyricTian/gin-admin @v10.0.2 sqlite

repository ↗ · DeepWiki ↗ · release v10.0.2 ↗
629 symbols 1,779 edges 101 files 237 documented · 38%
README

Gin-Admin

A lightweight, flexible, elegant and full-featured RBAC scaffolding based on GIN + GORM 2.0 + Casbin 2.0 + Wire DI.

English | 中文

LICENSE Language Go Report Card GitHub release GitHub release date GoDoc

Features

  • :scroll: Follow the RESTful API design specification & interface-based programming specification
  • :house: More concise project structure, modular design, improve code readability and maintainability
  • :toolbox: Based on the GIN framework, it provides rich middleware support (JWTAuth, CORS, RequestLogger, RequestRateLimiter, TraceID, Casbin, Recover, GZIP, StaticWebsite)
  • :closed_lock_with_key: RBAC access control model based on Casbin
  • :card_file_box: Database access layer based on GORM 2.0
  • :electric_plug: Dependency injection based on WIRE -- the role of dependency injection itself is to solve the cumbersome initialization process of hierarchical dependencies between modules
  • :zap: Log output based on Zap & Context, and unified output of key fields such as TraceID/UserID through combination with Context (also supports log hooks written to GORM)
  • :key: User authentication based on JWT
  • :microscope: Automatically generate Swagger documentation based on Swaggo - Preview
  • :test_tube: Implement API unit testing based on testify
  • :100: Stateless service, horizontally scalable, improves service availability - dynamic permission management of Casbin is implemented through scheduled tasks and Redis
  • :hammer: Complete efficiency tools, can develop complete code modules through configuration - gin-admin-cli

swagger

Frontend

Dependencies

  • Go 1.19+
  • Wire go install github.com/google/wire/cmd/wire@latest
  • Swag go install github.com/swaggo/swag/cmd/swag@latest
  • GIN-ADMIN-CLI go install github.com/gin-admin/gin-admin-cli/v10@latest

Quick Start

Create a new project

gin-admin-cli new -d ~/go/src --name testapp --desc 'A test API service based on golang.' --pkg 'github.com/xxx/testapp'

Start the service

cd ~/go/src/testapp
make start
# or
go run main.go start

Generate a new module

For more detailed usage instructions, please refer to gin-admin-cli

gin-admin-cli gen -d . -m CMS -s Article --structs-comment 'Article management'

Remove a module

gin-admin-cli rm -d . -m CMS -s Article

Build the service

make build
# or
go build -ldflags "-w -s -X main.VERSION=v1.0.0" -o ginadmin

Generate swagger docs

make swagger
# or
swag init --parseDependency --generalInfo ./main.go --output ./internal/swagger

Generate wire inject

make wire
# or
wire gen ./internal/wirex

Project Layout

├── cmd
│   ├── start.go
│   ├── stop.go
│   └── version.go
├── configs
│   ├── dev
│   │   ├── logging.toml           (Log configuration file)
│   │   ├── middleware.toml        (Middleware configuration file)
│   │   └── server.toml            (Service configuration file)
│   ├── menu.json                  (Initialize menu file)
│   └── rbac_model.conf            (Casbin RBAC model configuration file)
├── internal
│   ├── bootstrap
│   │   ├── bootstrap.go          (Initialization)
│   │   ├── http.go               (HTTP service)
│   │   └── logger.go             (Log service)
│   ├── config                    (Configuration file)
│   │   ├── config.go
│   │   ├── consts.go
│   │   ├── middleware.go
│   │   └── parse.go
│   ├── mods
│   │   ├── rbac                  (RBAC module)
│   │   │   ├── api               (API layer)
│   │   │   ├── biz               (Business logic layer)
│   │   │   ├── dal               (Data access layer)
│   │   │   ├── schema            (Data model layer)
│   │   │   ├── casbin.go         (Casbin initialization)
│   │   │   ├── main.go           (Module initialization)
│   │   │   └── wire.go           (Dependency injection)
│   │   ├── sys
│   │   │   ├── api
│   │   │   ├── biz
│   │   │   ├── dal
│   │   │   ├── schema
│   │   │   ├── main.go
│   │   │   └── wire.go
│   │   └── mods.go
│   ├── utility
│   │   └── prom
│   │       └── prom.go           (Prometheus)
│   └── wirex                     (Dependency injection)
│       ├── injector.go
│       ├── wire.go
│       └── wire_gen.go
├── test                          (Unit test)
│   ├── menu_test.go
│   ├── role_test.go
│   ├── test.go
│   └── user_test.go
├── Dockerfile
├── Makefile
├── README.md
├── go.mod
├── go.sum
└── main.go                       (Entry)

Community

Extension points exported contracts — how you extend this code

Cacher (Interface)
Cacher is the interface that wraps the basic Get, Set, and Delete methods. [3 implementers]
pkg/cachex/cache.go
IClient (Interface)
IClient is an interface for oss client [2 implementers]
pkg/oss/oss.go
Storer (Interface)
Storer is the interface that storage the token. [1 implementers]
pkg/jwtx/store.go
RateLimiterStorer (Interface)
(no doc) [2 implementers]
pkg/middleware/ratelimiter.go
HookOption (FuncType)
HookOption a hook parameter options
pkg/logging/hook.go
TransFunc (FuncType)
(no doc)
pkg/util/db.go
Option (FuncType)
(no doc)
pkg/cachex/cache.go
Cacher (Interface)
(no doc) [3 implementers]
pkg/jwtx/store.go

Core symbols most depended-on inside this repo

Error
called by 60
pkg/errors/errors.go
ResError
called by 55
pkg/util/gin.go
String
called by 45
pkg/util/context.go
Get
called by 36
pkg/cachex/cache.go
Context
called by 28
pkg/logging/logger.go
BadRequest
called by 24
pkg/errors/errors.go
Delete
called by 22
pkg/jwtx/store.go
NotFound
called by 19
pkg/errors/errors.go

Shape

Method 296
Function 171
Struct 138
Interface 9
TypeAlias 9
FuncType 6

Languages

Go100%

Modules by API surface

pkg/util/context.go24 symbols
pkg/errors/errors.go23 symbols
pkg/cachex/cache.go22 symbols
pkg/cachex/redis.go21 symbols
pkg/jwtx/store.go20 symbols
pkg/logging/logger.go18 symbols
pkg/jwtx/jwt.go18 symbols
pkg/promx/prom.go17 symbols
internal/mods/rbac/schema/menu.go15 symbols
internal/mods/rbac/dal/menu.dal.go14 symbols
pkg/oss/oss.go13 symbols
pkg/logging/hook.go13 symbols

Dependencies from manifests, versioned

github.com/BurntSushi/tomlv1.2.1 · 1×
github.com/Knetic/govaluatev3.0.1-0.20171022003 · 1×
github.com/KyleBanks/depthv1.2.1 · 1×
github.com/LyricTian/captchav1.2.0 · 1×
github.com/ajg/formv1.5.1 · 1×
github.com/andybalholm/brotliv1.0.4 · 1×
github.com/aws/aws-sdk-gov1.44.300 · 1×
github.com/beorn7/perksv1.0.1 · 1×
github.com/bytedance/sonicv1.8.7 · 1×
github.com/casbin/casbin/v2v2.68.0 · 1×
github.com/cespare/xxhashv1.1.0 · 1×
github.com/cespare/xxhash/v2v2.2.0 · 1×

For agents

$ claude mcp add gin-admin \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact