Main backend service for Recova, handling authentication, profiles, routines/check-ins, journaling, community features, educational content, AI Coach, and API observability.
Active runtime for this repository: Go + Fiber. Legacy runtime archive (Node/Express): README.md.
- Service Scope
- Domain Modules
- Tech Stack
- Quick Start
- Environment Configuration
- Make Commands
- Testing and Quality Gates
- OpenAPI and API Docs
- Deployment Overview
- Repository Structure
- Documentation Map
- Quick Troubleshooting
This service handles:
- Google Login + JWT session flow (
/api/v1/auth/*) - User profiles, onboarding, and settings (
/api/v1/users/*) - Routine check-ins, relapse tracking, and activity statistics (
/api/v1/routine/*) - Personal journals (
/api/v1/journals) - Community posts, comments, replies, and likes (
/api/v1/community*) - Educational content and daily content (
/api/v1/education,/api/v1/content/daily) - AI Coach chat, summaries, onboarding analysis, and persona preferences (
/api/v1/ai/*) - Health checks, metrics, and OpenAPI runtime routes (
/health/*,/metrics,/openapi.yaml,/docs/api)
Active modules are located in internal/modules/:
authusersroutinejournalscommunityeducationcontentaiachievements
Runtime route inventory is automatically synchronized in: docs/generated/routes.md.
| Area | Technology |
|---|---|
| Language | Go 1.25.x (toolchain pinned in go.mod) |
| HTTP Framework | Fiber v3.1.x |
| Database | PostgreSQL |
| ORM | GORM |
| Migration | golang-migrate (SQL up/down) |
| API Contract | OpenAPI 3.1 |
| API Docs UI | Scalar |
| Authentication | JWT + Google OAuth token verification |
| Metrics | Prometheus client |
| Build/Task Runner | Make |
| Container Runtime | Docker + Docker Compose |
- Go
>= 1.25 - Make
- Git
- Docker + Docker Compose (required for local DB/container profile)
Check the baseline setup:
make preflightcp .env.example .envUpdate the minimum required values:
JWT_SECRETGOOGLE_CLIENT_IDAI_API_KEYDATABASE_URL
Default local configuration:
PORT=3001API_PREFIX=/api/v1APP_ENV=local
docker compose -f docker-compose.local.yml up -d db
make migrate-up
make seed
make rundocker compose -f docker-compose.local.yml up -d --build
make migrate-up
make seed
docker compose -f docker-compose.local.yml logs -f apicurl -fsS http://localhost:3001/health/live
curl -fsS http://localhost:3001/health/ready
curl -I http://localhost:3001/docs/apiComplete references are available in:
docs/environment.md.env.example
Main environment variable groups:
- Application:
APP_NAME,APP_ENV,NODE_ENV,PORT,API_PREFIX,APP_URL,DOCS_URL - Database:
DATABASE_URL,DIRECT_DATABASE_URL, pooling, SSL mode - Authentication:
JWT_SECRET, token TTL, cookie policy,GOOGLE_CLIENT_ID - AI:
AI_PROVIDER,AI_MODEL,AI_API_KEY, fallback provider/model - Security: CORS, rate limiting, request body limit
- Observability: log level, request ID header, health timeout
Notes:
make run,make migrate-*, andmake seedautomatically load.envviascripts/with-env.sh- Override the env file using:
ENV_FILE=.env.staging make run
All tasks are available in the Makefile. Core commands:
make preflightcheck tools and project structure baselinemake fmtformat Go code (gofmt -w .)make lintstatic checks (go vet ./...)make buildbuild binary./bin/recova-apimake runrun the local API
make migrate-upmake migrate-downmake migrate-statusmake migrate-checkmake migrate-force VERSION=<n>make seed
make openapi-generatemake openapi-checkmake openapi-autogenmake openapi-autogen-watchmake openapi-autogen-install-hookmake scalar-checkmake scalar-preview
make testmake test-integrationmake test-e2emake test-performancemake coveragemake release-validationmake module-consistency-checkmake module-consistency-full-checkmake security-scanmake compose-smoke
make staging-deploymake cutover-wave WAVE=<64|65|66|67|68>make cutover-allmake stabilization-gatemake rollback-rehearsalmake runtime-decommissionmake post-migration-maintenance
Baseline checks before merge:
make fmt
make lint
make test
make test-integration
make openapi-check
make scalar-check
make module-consistency-checkFor higher confidence before release:
make release-validation
make module-consistency-full-checkDetailed strategy: docs/operations/testing.md.
API contract source:
api/openapi/openapi.yaml
Generated artifacts:
docs/generated/openapi.yamldocs/generated/routes.mdscalar.config.json(Scalar navigation + docs wiring)
Runtime endpoints:
- Raw OpenAPI:
GET /openapi.yaml - Scalar UI:
GET /docs/api
Recommended workflow:
make openapi-generate
make openapi-checkNotes:
make openapi-autogen-watchmaintains.openapi-watch-filesand regenerates artifacts on change.- Runbook:
docs/operations/api-docs-generation.md.
make staging-deployScript: scripts/staging-deploy.sh
Compose target: docker-compose.staging.yml
Main CI/CD workflow:
.github/workflows/deploy-staging.ymlscripts/deploy/remote-deploy.sh
Deployment smoke checks include:
/health/live/health/ready/openapi.yaml
Complete reference: docs/operations/deployment.md.
.
├── api/ # OpenAPI source
├── artifacts/ # Test/deployment artifact outputs
├── cmd/ # Application/tool entrypoints
├── docs/ # Technical documentation
├── internal/ # Application code (app, modules, platform, shared)
├── migrations/ # SQL migrations + seeds
├── scripts/ # Dev/ops automation scripts
├── test/ # Integration harness and validation scripts
├── docker-compose.local.yml # Local runtime
├── docker-compose.staging.yml # Staging runtime
├── Dockerfile # Production-style image build
├── scalar.config.json # Scalar docs configuration
└── Makefile # Task runner
Start here:
docs/overview.md
Important documents:
- Architecture:
docs/architecture.md - API:
docs/api/index.mdanddocs/api-reference.md - Database:
docs/database.md - Environment:
docs/environment.md - Project structure:
docs/project-structure.md - Tech stack:
docs/tech-stack.md - Local development:
docs/operations/local-development.md - Testing:
docs/operations/testing.md - Deployment:
docs/operations/deployment.md - Security:
docs/operations/security.md - API docs generation:
docs/operations/api-docs-generation.md - Documentation sync:
docs/operations/documentation-sync.md - Modules index:
docs/modules/index.md
config errorduring startup: check required environment variables in.envanddocs/environment.md- Missing
migratebinary: scripts will automatically fallback to the Docker imagemigrate/migrate:v4.19.0if Docker is available openapi-checkfailed: runmake openapi-generateand commit changes insidedocs/generated/*health/readyfailed: check DB connectivity and migration status (make migrate-status,make migrate-check)