Guides
Service Template Overview
Service Template Overview
The services/template-api directory contains a production-ready skeleton for new Jan microservices. Highlights:
- Go module with config/logger/observability/http packages mirroring established patterns.
- GORM/PostgreSQL wiring (connection pool, migrations, seed data, repository example).
- Optional Keycloak JWT guard controlled via
AUTH_ENABLED. - Makefile + Dockerfile for local dev and CI.
- Wire entrypoint plus example env and docs.
- Use
jan-cli dev scaffold <service-name>to copy the template with placeholders replaced.
Getting Started
- Run
jan-cli dev scaffold my-service(or copyservices/template-apimanually). - Update
go.mod, the service section inside.env.template, andcmd/server/server.gowith your service-specific names and dependencies. - Configure the database DSN (
DB_POSTGRESQL_WRITE_DSN) and rungo run ./cmd/serveronce so migrations seed the database. - Decide whether to enable JWT auth (
AUTH_ENABLED,AUTH_ISSUER,ACCOUNT,AUTH_JWKS_URL). - Register your handlers inside
internal/interfaces/httpserver. - Add domain packages and migrations as needed.
- Update root
.env.template, README, and deployment manifests to include your service.
This guide provides a detailed checklist covering both greenfield and migration workflows for creating new services.