Overview
The API service is the central authority of the Huddle platform. It owns business logic, identity, persistence, and object storage, and acts as the Temporal client that triggers every background workflow. Almost every other service reads its data through the generated SDK that this service produces.
- Language: Go 1.27
- Web framework: Echo v5
- Database: PostgreSQL via pgx v5, typed with sqlc
- Migrations: goose
- Cache / rate-limit: Redis
- Object storage: S3-compatible (Tigris), presigned URLs
- API docs: swaggo/swag v2 → OpenAPI, from which the TypeScript and Python SDKs are generated
Project structure
Section titled “Project structure”Directorycmd/
Directoryserver/ API server entry point
- …
Directorymigrate/ goose-backed migrate CLI (up / status / down)
- …
Directoryseed/ Inserts the root org + its admin (seed.json)
- …
Directorydb/ Unified SQL tree — see the note below
Directory_global/ schema.sql — the six schemas; page.sql — the page type
- …
Directoryauth/organization/ schema.sql (what you edit) + query.sql, per table
- …
Directory_migrations/ Generated goose migrations (also sqlc’s schema)
- …
- embed.go Embeds the migrations for cmd/migrate
- docker-compose.yaml Optional local Postgres + Redis
Directoryinternal/
Directoryapi/ Echo HTTP layer — routes, middleware, handlers
- …
Directoryservice/ Business logic (core impls + decorators), one dir per domain (auth, bond, premium, document, project, audit)
Directorybond/pdf/ pdfcpu wrapper — trim / merge / render / seal-stamp bond forms
- …
Directorydb/ sqlc-generated persistence code
- …
Directorymodel/ Domain types, enums, FromDB converters, base_spec/ (embedded base bond request specs)
- …
Directoryauthn/ JWT minting (session, password-reset, workflow) + purpose model, bcrypt passwords, OTP hashing
- …
Directoryauthz/ RBAC — Action/Check/ScopeOrgs (enforced; see Architecture)
- …
Directoryaudit/ Audit logger behind the WithAudit decorators
- …
Directoryworkflow/ Temporal client wrapper, status Watcher, requester propagator
- …
Directorycache/ Redis wrapper (behind EnableCache)
- …
Directoryo11y/ OpenTelemetry setup
- …
Directorystorage/ S3 client + presigning
- …
Directoryid/ ULID type (stored as Postgres uuid)
- …
Directoryconfig/ Viper-backed config
- …
Directoryutils/ Context helpers, generic Map
- …
Directorydocs/ Generated OpenAPI spec (docs.go, swagger.json)
- …
Directoryscripts/
- openapi_query.jq Rewrites the spec for QUERY endpoints (see Architecture)
- schema.sh psqldef plan / check behind db:schema and db:check
- sqlc.yaml sqlc configuration
- .sql-formatter.json sql-formatter config (formats query.sql)
- .swaggo swag type overrides
Reference
Section titled “Reference”- Swagger UI: api.huddlesurety.com/docs/index.html
- OpenAPI spec: api.huddlesurety.com/docs/doc.json
- SDKs:
@huddlesurety/api(TypeScript, Python)