This repository now contains:
- Go backend (
supost serve) exposing REST APIs - Next.js 16.1.6 + TypeScript frontend (
frontend/) rendering the SUpost-style homepage - Supabase/Postgres integration through the Go repository layer
- Command layer:
cmd/ - Business logic:
internal/service/ - Domain contracts:
internal/domain/ - Data access adapters:
internal/repository/(inmemoryandpostgres) - Vercel Functions handlers:
frontend/api/*/index.go - Vercel Go runtime module:
frontend/go.mod
The backend API surface is the same for local server and Vercel functions:
GET /api/categoriesGET /api/subcategories?category_id=<id>GET /api/posts?category_id=&subcategory_id=&status=&limit=&offset=GET /api/health
All responses are JSON, with structured error envelopes for validation/internal failures.
frontend/ includes:
app/page, layout, loading/error statescomponents/modular homepage sectionsservices/typed API client to Go backendtypes/API response/domain typeshooks/UI helper hooks
The homepage is rendered from modular React components and fetches data only from the Go API.
Use .env.example at repo root:
DATABASE_URL(optional; if empty uses in-memory repository)PORT(default 8080)CORS_ORIGINS(comma-separated origins in addition to localhost:3000 defaults)SUPABASE_URL,SUPABASE_ANON_KEY(for shared config compatibility)
Use frontend/.env.example:
NEXT_PUBLIC_API_BASE_URL=http://localhost:8080DATABASE_URL=postgresql://...(required for Vercel Go functions)CORS_ORIGINS=http://localhost:3000,http://127.0.0.1:3000
go run . serve --port 8080cd frontend
npm install
npm run devOpen http://localhost:3000.
Deploy frontend and Go API together as one Vercel project.
| Setting | Value |
|---|---|
| Root Directory | frontend |
| Framework Preset | Next.js |
| Node.js Version | 20.x or newer |
Vercel will deploy:
- Next.js app from
frontend/app - Go serverless functions from
frontend/api
Add these for Production and Preview:
| Variable | Value | Required |
|---|---|---|
DATABASE_URL |
postgresql://... (Supabase pooler URL) |
Yes |
CORS_ORIGINS |
https://<your-project>.vercel.app (no trailing slash) |
Yes |
NEXT_PUBLIC_API_BASE_URL |
Leave empty to use same-origin /api on Vercel |
No |
Your local .env/.env.local files are not deployed. Set vars in the Vercel dashboard.
vercel --prodThe homepage and API will be served from the same URL:
https://<project>.vercel.app/— Next.js homepagehttps://<project>.vercel.app/api/healthhttps://<project>.vercel.app/api/categories
Backend:
go build ./...
go test ./...Frontend:
cd frontend
npm ci
npm run typecheck
npm run build- If
DATABASE_URLis set, backend reads from Supabase/Postgres. - If
DATABASE_URLis empty, backend serves seed-backed in-memory data. - Frontend route
/is intentionally dynamic (force-dynamic) so production builds do not require a live API at build time. - Local CLI server (
go run . serve) and Vercel functions share the same service/repository business logic.