The API server for Sous, a cooking app for households. Members share one recipe box, meal plan, pantry and shopping list, and changes show up on everyone's devices as they happen. The web app is sous-web.
soupi stores the household's data in Postgres, handles sign-in through Clerk, imports recipes from web pages, and streams changes to connected clients.
- Households. Signing up creates a household with a pantry and a default set of categories. Other people join it with the household's join code.
- Recipes. Create, edit and delete recipes with per-household tags, ratings and free-text notes, and track when each was last made. Ingredients can be marked optional; a line that says "optional" is optional unless the client says otherwise. Marking a recipe as made can mark the pantry items it used up as out of stock or running low, add a line to its notes, and removes it from the meal plan.
- Recipe import. Given a URL, soupi loads the page in headless Chromium (presenting
as regular Chrome, since many recipe sites refuse headless browsers) and reads
the recipe with rules: the page's schema.org data (JSON-LD, then microdata), else
the "Ingredients" and "Directions" sections of the post (an "Optional:" section marks
its lines optional; a video or full-recipe link goes in the notes when the steps
aren't written out). For TikTok and Instagram it reads the post caption the same way.
Only when the rules find nothing, and
OPENAI_API_KEYis set, does an OpenAI model read the text instead (and follow a recipe link it finds there). A Python parser (ingredient-parser-nlp) splits each ingredient line into amount, unit and item. - Pantry and shopping list. Items with a category, stock status (in stock, running low or out), staple flag, quantity and expiration date. The shopping list is the items flagged for it.
- Timer alerts. sous-web registers each running cooking timer, and soupi sends a web push to that device when it ends, so the alert arrives with the app closed (on iPhone, in the app added to the Home Screen). Pending timers are stored in the database and re-armed when the server restarts. A device that hasn't opened the app (or had an alert) for 90 days loses its subscription in a daily cleanup. Off unless configured (see Configuration).
- Meal plan. Dated plan days (and an "any time" day) holding recipes and meals. A meal is a planned dish that isn't a recipe: a name and the pantry items it needs, no amounts, with optional items. Marking it made updates the pantry like a recipe does; it leaves the plan but is kept, so the app can offer it again.
- Live updates. Every change is pushed to the household's open
/events/:householdIdServer-Sent Events streams.
API documentation (Swagger UI) is served at /docs. GET /health reports database
connectivity.
Node 22, Express 5, TypeScript, Prisma 6, PostgreSQL 17, Clerk, Zod, Pino, Puppeteer, web-push, Python 3, Vitest.
You need Node 22, Python 3, a Postgres database and a Clerk application; an OpenAI API key is optional (see Configuration).
npm ci # also downloads Chromium for Puppeteer
python3 -m venv python/venv
python/venv/bin/pip install -r python/requirements.txt
cp .env.example .env # fill in the values
npx prisma generate
npx prisma migrate deploy
npm run dev # http://localhost:8080To start with sample data, set SEED_USER_ID to your Clerk user ID and run
npx prisma db seed.
Point a local sous-web at
http://localhost:8080 to use the app.
Environment variables are validated at startup; the server won't start without the required ones.
| Variable | Required | Description |
|---|---|---|
DATABASE_URL |
yes | Postgres connection string. |
CLERK_PUBLISHABLE_KEY, CLERK_SECRET_KEY |
yes | Keys from your Clerk application. sous-web must use the same application. |
OPENAI_API_KEY |
no | Recipe import's fallback for pages and captions its rules can't read. Without it, those imports find no recipe. |
NLP_PYTHON_PATH, NLP_PARSER_PATH |
yes* | Python interpreter and python/parser.py. *The server starts without them, but saving a recipe fails. |
CORS_ORIGINS |
no | Comma-separated origins allowed to call the API, such as your sous-web URL. Unset allows any origin. |
PORT, HOST |
no | Listen address. Defaults: 3000 and 0.0.0.0. .env.example and the Docker image use 8080. |
APP_URL, VAPID_PUBLIC_KEY, VAPID_PRIVATE_KEY |
no | Timer alerts by web push. APP_URL is your sous-web URL (notifications link to it); generate the key pair with npx web-push generate-vapid-keys, one pair per environment. All three set turns push on. |
LOG_LEVEL |
no | fatal, error, warn, info (default), debug or trace. |
RUN_MIGRATIONS |
no | Docker image only. true (default) runs prisma migrate deploy before the server starts. |
Clerk: sous-web signs users in with an email and password, verified by an
emailed code, so enable those in your Clerk application. Development keys
(pk_test_…) work locally; a production Clerk instance is tied to your own domain.
docker-compose.yml runs three services: db (Postgres 17), api (this server)
and tunnel (an optional
Cloudflare Tunnel).
One env file defines one environment, and container, volume and network names are
suffixed with its ENV, so several environments (say dev and prod) can run on
one host.
-
Copy the template and fill it in:
cp .env.deploy.example .env.prod
Set
ENV=prod, thePOSTGRES_*credentials, aDATABASE_URLthat matches them (hostdb), your Clerk keys (and an OpenAI key, if you want the import fallback),CORS_ORIGINS(your sous-web URL), andAPI_PORT(the host port, bound to127.0.0.1).For timer alerts, also set
APP_URL(your sous-web URL) and a VAPID key pair fromnpx web-push generate-vapid-keys. Use a different pair in each environment, and keep it: changing it invalidates every device's alerts until the app re-subscribes. -
Start it. Pass
--env-fileon everydocker composecommand; without it Compose falls back todevwith empty database credentials.docker compose --env-file .env.prod up -d --build # with the tunnel docker compose --env-file .env.prod up -d --build db api # without it
The API container applies database migrations when it starts.
-
Give the API a public HTTPS URL. The browser calls it directly. Either:
- set
TUNNEL_TOKENto a Cloudflare Tunnel token and route the tunnel's public hostname tohttp://soupi_<ENV>_api:8080, or - put your own reverse proxy in front of
127.0.0.1:<API_PORT>.
- set
-
Check it:
curl http://127.0.0.1:<API_PORT>/health # {"db":"ok","status":"ok"} docker compose --env-file .env.prod logs -f api
Then deploy sous-web with this API's public URL.
Updating: git pull, then rebuild only the API:
docker compose --env-file .env.prod up -d --build api.
Backups: the database is in the soupi_<ENV>_pgdata volume. Dump it with:
docker exec soupi_prod_db pg_dump -U <POSTGRES_USER> -d <POSTGRES_DB> > soupi.sqlRun one API instance per environment: rate limits, live-update connections and the timer-alert schedule are held in memory.
| Command | What it does |
|---|---|
npm run dev |
Dev server with reload |
npm run build |
Compile to dist/ |
npm test |
Unit tests (Vitest) |
npm run test:integration |
Integration tests (needs a local *_test Postgres; see tests/integration/README.md) |
npm run typecheck |
Type-check tests and seed |
npm run lint, npm run format |
ESLint, Prettier |
npx prisma migrate dev --name <name> |
Create a migration |
npm run studio |
Browse the database |
src/routes/ HTTP layer: auth, household access check, request validation
src/services/ Business logic and all database access
src/schemas/ Zod request schemas
src/middleware/ Auth, household membership, error handling
prisma/schema/ Data model (one file per model) and migrations
python/ Ingredient parser and scraper helpers
utils/ Logging, live-update broadcaster, constants
tests/unit/ Vitest tests with a mocked Prisma client
tests/integration/ The app against a real Postgres: household scoping for every route
Data routes live under /household/:householdId/… and require a Clerk session token
belonging to a member of that household. /user, /push and /timers belong to the
signed-in user instead. Request bodies are validated with Zod, which
drops fields the schema doesn't list. Records are soft-deleted (deletedAt) by DELETE
routes.
MIT. See LICENSE.