Open-source media tracking backend (TV/movies via Trakt later, plus books and more).
- Go + Chi (package-by-feature)
- PostgreSQL 16
- Redis 7
- sqlc + golang-migrate
- JWT access tokens + hashed refresh tokens
cp .env.example .env
make up
make migrate
make sqlc # only needed after changing SQL
make runDefault .env.example maps Postgres to host port 5433 and Redis to 6380 (to avoid clashes with other local stacks). API listens on HTTP_ADDR (default :8080 in example; change if needed).
| Method | Path | Auth |
|---|---|---|
| GET | /health |
no |
| GET | /ready |
no |
| POST | /v1/auth/register |
no |
| POST | /v1/auth/login |
no |
| POST | /v1/auth/refresh |
no |
| POST | /v1/auth/logout |
no |
| GET | /v1/users/me |
Bearer access token |
curl -s localhost:8080/v1/auth/register \
-H 'content-type: application/json' \
-d '{"email":"you@example.com","password":"password1","display_name":"You"}'make up
make migrate
make testUnit tests run without Docker. Integration tests skip if Postgres/Redis are unavailable.
cmd/api/ entrypoint
internal/core/ health/ready
internal/user/ auth + profile
internal/platform/ config, db, http helpers, jwt
db/migrations/ SQL migrations
db/queries/ sqlc queries
tests/integration/ HTTP integration tests
cp .env.example .env
# Edit JWT secrets (min 32 chars)
make deploycurl -s http://localhost:8080/health
curl -s http://localhost:8080/ready1. Data server (copy the repo or at least Compose + .env, then):
cp .env.example .env
# Set strong POSTGRES_PASSWORD and REDIS_PASSWORD
# Bind POSTGRES_PORT / REDIS_PORT as needed
make deploy-infra
# docker compose -f docker-compose.infra.yml up -dFirewall that host so only the API server can reach Postgres and Redis ports.
2. API server .env must point at the data host:
DATABASE_URL=postgres://trax:YOUR_PG_PASSWORD@DATA_SERVER_IP:5432/trax?sslmode=disable
REDIS_URL=redis://:YOUR_REDIS_PASSWORD@DATA_SERVER_IP:6379/0
JWT_ACCESS_SECRET=...at-least-32-chars...
JWT_REFRESH_SECRET=...at-least-32-chars...
API_PORT=8080Then:
make deploy-api
# docker compose -f docker-compose.api.yml up -d --buildMigrations run automatically before the API starts (migrate service).
3. Verify from the API server:
curl -s http://localhost:8080/ready
# expect postgres and redis "up"Stop each side independently:
make down-api # API server
make down-infra # data server| File | Purpose |
|---|---|
docker-compose.yml |
Local all-in-one |
docker-compose.infra.yml |
Data server (Postgres + Redis) |
docker-compose.api.yml |
API server (migrate + api) |
make up-deps
make migrate
make rundocker compose ps
make logs-api
docker compose -f docker-compose.api.yml up -d --build apiSee CONTRIBUTING.md for setup, conventions, and pull request guidelines.
Licensed under the Apache License 2.0.
Thanks to everyone who has contributed to Trax API.