The ultimate Go microservice template—optimized for speed, reliability, and seamless AI-driven collaboration.
https://github.com/aquasecurity/trivy?tab=readme-ov-file
command:
trivy fs .
- ✨ Key Features
- ⚙️ Prerequisites
- 🔧 Installation & Setup
- 🐳 Docker & Compose
- 💻 Local Development
- 📡 Main Endpoints
- 🛡️ Security & Auth
- 📝 Environment Variables
- 🤝 Contributing
- 📜 License
- 🏗️ RESTful API with Gin in Release mode.
- 🔒 JWT Authentication for access & refresh tokens.
- 🗄️ GORM ORM with automatic migrations & seeding (admin role + initial user).
- ⏰ cron jobs via robfig/cron (daily tasks).
- 🤖 LLM‑Friendly code structure—designed for easy snippet sharing, AI-assisted edits, and smooth integration with large language models.
- 🐳 Full containerization: Docker + Distroless + Compose with healthchecks.
- 📜 Clean architecture: clear separation of layers (db, handlers, middleware, infra, utils).
- Go ≥ 1.24
- Docker ≥ 20.10 & Docker Compose v2
- PostgreSQL ≥ 17.4
- Bash or Make (optional)
-
Clone the repo
git clone https://github.com/your-org/ia-boilerplate.git cd ia-boilerplate
-
Copy & edit your
.env
cp .env.example .env # Fill in your credentials and secrets
-
Build the Go binary
go mod download go build -o ia-boilerplate .
Bring up your full stack (API + DB) in one command:
docker compose up --build
- db-ia-boilerplate → PostgreSQL on port 5432
- ia-boilerplate → API on port 8080
- Healthchecks ensure DB readiness before app startup.
Teardown:
docker compose down --volumes
Skip Docker and run directly:
export $(grep -v '^#' .env | xargs)
go run main.go
Open your browser at http://localhost:8080
and you’re ready!
Method | Route | Description |
---|---|---|
POST | /login |
Authenticate: returns access & refresh JWT |
POST | /access-token/refresh |
Refresh access token with refresh token |
GET | /api/device |
Device info (requires JWT) |
GET | /api/users |
List users |
GET | /api/users/:id |
Get user by ID |
POST | /api/users |
Create new user |
PUT | /api/users/:id |
Update user |
DELETE | /api/users/:id |
Delete user |
GET | /api/medicines/search-paginated |
Paginated medicine search |
GET | /api/icd-cie/search-paginated |
Paginated ICD‑CIE code search |
🔎 Explore additional endpoints for roles, devices, ICD‑CIE, etc., under
/api
.
- Use header
Authorization: Bearer <token>
for protected routes. - Token lifetimes controlled by
ACCESS_TOKEN_TTL
&REFRESH_TOKEN_TTL
(minutes). - Secrets managed entirely via environment variables.
Variable | Description | Example |
---|---|---|
DB_HOST |
PostgreSQL host | db-ia-boilerplate |
DB_PORT |
PostgreSQL port | 5432 |
DB_USER |
DB username | app_user |
DB_PASSWORD |
DB password | yourpassword |
DB_NAME |
DB name | ia-boilerplate |
DB_SSLMODE |
SSL mode (disable/require) | disable |
APP_PORT |
API port | 8080 |
ACCESS_SECRET_KEY |
JWT access token secret | yourAccessSecretKey |
REFRESH_SECRET_KEY |
JWT refresh token secret | yourRefreshSecretKey |
ACCESS_TOKEN_TTL |
Access token TTL (minutes) | 15 |
REFRESH_TOKEN_TTL |
Refresh token TTL (minutes) | 10080 |
JWT_ISSUER |
JWT issuer | my-app |
IMGUR_CLIENT_ID |
(Optional) Imgur integration | yourImgurClientId |
START_USER_EMAIL |
Seed admin user email | [email protected] |
START_USER_PW |
Seed admin user password | qweqwe |
- Fork the repo.
- Create your feature branch:
git checkout -b feature/my-feature
- Commit your changes:
git commit -am "Add awesome feature"
- Push to branch:
git push origin feature/my-feature
- Open a Pull Request—let’s make this the best boilerplate of 2025 together! 🚀
This project is licensed under the MIT License. Open source, future‑proof, and AI‑ready! 😊
“The best way to predict the future is to create it.” – Peter Drucker 🤖