A small Go + PostgreSQL backend for a Chirp-style API with JWT auth, refresh tokens, webhook-based user upgrades, and basic admin metrics.
- Go (
net/http) - PostgreSQL (
lib/pq) - SQLC-generated queries (
internal/database) - JWT + refresh-token auth
- Go 1.25+
- PostgreSQL
- Optional:
sqlc(if regenerating DB code)
Create a .env file in the project root:
DB_URL— Postgres connection stringSECRET_KEY— key used to sign/validate JWTsPOLKA_KEY— API key for/api/polka/webhooks
- Create the database schema from files in
sql/schema/. - (Optional) Regenerate SQLC code:
sqlc generate
- Start the server:
go run .
Server runs on http://localhost:8080.
GET /api/healthzPOST /api/usersPOST /api/loginPUT /api/usersPOST /api/refreshPOST /api/revokePOST /api/chirpsGET /api/chirpsGET /api/chirps/{id}DELETE /api/chirps/{chirpID}POST /api/polka/webhooks
GET /admin/metricsPOST /admin/resetGET /app/*serves static files from project root