-
Notifications
You must be signed in to change notification settings - Fork 0
Gin Architecture
The Go stack uses explicit compile-time dependency wiring. It is not a classical inheritance architecture: structs hold dependencies, interfaces define boundaries, constructors assemble implementations, Gin handlers own HTTP transport, services own policy, and query/repository code owns persistence.
cmd/api/main.go
cmd/worker/ # when selected
internal/
config/
database/
httpserver/
...selected services/integrations
db/
migrations/
queries/
openapi/openapi.yaml
go.mod
sqlc.yaml
Dockerfile
docker-compose.yml
k8s/ # when selected
infra/terraform/ # when selected
cmd/api/main.go loads configuration, constructs pools/clients/services, creates the Gin router, starts HTTP, and coordinates signals. Capability modules may add cmd/worker or scheduler commands. SQL migrations and sqlc queries form the persistence boundary.
flowchart LR
Client --> Gin
Gin --> Middleware
Middleware --> Handler
Handler --> Service
Service --> Interface[typed repository/integration interface]
Interface --> SQLC[sqlc query implementation]
SQLC --> PostgreSQL
Service --> Handler
Handler --> Response
Recovery, request ID, structured logging, and selected auth/telemetry middleware run before handlers. Handlers validate/map transport data, services apply domain policy, and typed interfaces isolate persistence/integration details.
Praxis patches named anchors in cmd/api/main.go and router construction. Generated constructors create selected clients and pass them explicitly; there is no reflection-based container or runtime plugin discovery. Capability closure ensures prerequisites such as Redis are constructed before workers/realtime features that use them.
Configuration and dependencies are validated before the HTTP listener becomes ready. Database migrations remain an explicit operational step. Signal handling drains the HTTP server with a deadline, then closes workers, clients, and pools. Separate worker/scheduler commands own separate signal lifecycles in Compose/Kubernetes.
JWT middleware authenticates requests; policy services implement fine-grained authorization. Redis, jobs, schedules, storage, search, Kafka, realtime, flags, observability, resilience, and infrastructure capabilities add typed packages and constructor wiring. Compile failures expose incomplete wiring early.
Compose includes API, PostgreSQL, and selected supporting services/commands. Kubernetes defines independent API, worker, scheduler, migration, and dependency workloads. Terraform creates cloud infrastructure selected for the same resolved capabilities but does not compile Go, apply migrations, or apply Kubernetes resources.
Add handlers through the router, keep business policy in services, define narrow interfaces at their consumer, generate query implementations with sqlc, and wire dependencies in entry points. Template changes must keep constructors, shutdown ownership, Compose services, probes, and tests consistent.
- Stack:
cli/templates/pro.gin/ - Core:
cli/templates/pro.core/ - Capability examples:
cli/templates/pro.capability.jwt-auth/,pro.capability.redis-cache/ - Runtime contracts:
cli/tests/generator/proRuntime.test.ts - Capability contracts:
cli/tests/generator/proCapabilities.test.ts
This Wiki is generated from the repository's versioned docs/ source. Update and review the source files; do not rely on hand edits to generated Wiki pages.
- Core-Internals
- Architecture
- Repository-Map
- Code-Architecture
- Generation-Pipeline
- Manifest-System
- UI-Templates
- Testing
- Agent-Guide
- Wiki-Publishing
- Template-Architecture
- Standard-Projects
- Standard-Frontend-Architecture
- Express-Architecture
- Fullstack-Architecture
- Praxis-Pro
- Django-Architecture
- Gin-Architecture
- Capability-Architecture
- Compose-Architecture
- Kubernetes-Architecture
- Terraform-Architecture
- Extending-Generated-Projects
- Generated-Backends