Monorepo with a Next.js frontend, Flask API, and PostgreSQL, orchestrated with Docker Compose.
- Docker and Docker Compose v2
- (Optional) Node.js and Python if you develop services outside Docker
-
Copy environment defaults and adjust if needed:
cp .env.example .env
-
Start all services (builds images on first run):
docker compose up --build
This repo is optimized for faster container rebuilds:
- Backend image uses
uvfor Python dependency installation. - Frontend image uses
npm ciwith a Docker cache mount for reliable rebuilds. - Compose mounts use cache-friendly settings for local development.
Note: Bun can crash on some Linux arm64 Docker environments during install, so Docker uses npm by default for stability.
Useful commands:
# Rebuild only app images
docker compose build backend frontend
# Start without forcing a rebuild
docker compose up
# Recreate containers if dependency layer changed
docker compose up --build --force-recreate-
Open the app:
- Frontend: http://localhost:3000 — use the buttons to call the API.
- Backend: http://localhost:5001/health
- Postgres:
localhost:5433(credentials match.env)
-
In the UI, click POST /db/write to insert a row, then GET /db/read to see the latest rows (up to 10).
-
Or use curl:
curl -s http://localhost:5001/db/write -H "Content-Type: application/json" \ -d '{"message":"manual test"}' curl -s http://localhost:5001/db/read
Postgres files live in the Docker named volume postgres_data. Removing containers does not remove this volume unless you run docker compose down -v.
-
Verify ngrok account can open TCP endpoints:
- If
ERR_NGROK_8013appears, complete account verification at ngrok dashboard.
- If
-
Start postgres + tunnel:
./scripts/start-hex-ngrok.sh
-
Use printed values in Hex connection settings:
- Name:
Local Docker Postgres - Host:
<ngrok host> - Port:
<ngrok port> - Database/Username/Password: read from
.env
- Name:
-
Stop tunnel when finished:
./scripts/stop-hex-ngrok.sh
frontend/— Next.js app (NEXT_PUBLIC_API_BASE_URLpoints at the Flask API from the browser).backend/— Flask app; usesDATABASE_URL(hostnamepostgresinside Compose).db/schema.sql— applied automatically on first database initialization via/docker-entrypoint-initdb.d.
To re-run schema after the DB already exists, apply SQL manually or reset the volume (this deletes data):
docker compose down -v
docker compose up --build