AI revenue intelligence platform for boutique hotels. Combines the hotel's booking history with events to recommend optimal room rates.
- uv — Python package manager
- Docker — for PostgreSQL (and optional containerized backend)
- just — command runner
# Build the backend image
just build
# Start everything (db + backend with hot reload)
just dev
# Run migrations
just migrate
# View logs
just logs
# Stop everything
just destroyjust frontend-install # once, and after package.json changes
just frontend # http://localhost:5173, calls the API from `just dev`
just frontend --mocks # fake data, no backend neededSettings and conventions are in frontend/README.md.
just lint checks the backend and the frontend.
Recipes that touch the database take an optional --neon flag. Without it
they use the local Docker Postgres; with it, the Neon production branch
(URLs from .env).
just dev # local Docker Postgres
just dev --neon # same stack, pointed at Neon (local db container not started)
just migrate --neon # migrations against Neon (direct, non-pooled URL)
just run --neon # API on the host, outside Docker--neon works on dev, destroy, run, migrate, migrate-create,
migrate-down and test. Re-run just dev / just dev --neon to switch;
Compose recreates the backend. Neon URLs come from neon env pull. See
docs/decisions/0027-neon-postgres.md.
The API will be available at http://localhost:8000
API docs at http://localhost:8000/docs
Re-run just build whenever you change backend dependencies or the Dockerfile — source code changes hot-reload automatically while just dev is running.
# Create a new migration after changing models
just migrate-create "add_hotels_table"
# Run pending migrations
just migrate
# Rollback last migration
just migrate-down- In the Google Cloud console, create an
OAuth client of type Web application with the redirect URI
http://localhost:8000/auth/google/callback. While the consent screen is in Testing, add your Google account as a test user. - Set these in
.env:
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
SESSION_SECRET= # openssl rand -hex 32- Open http://localhost:8000/auth/google/login, then check
http://localhost:8000/auth/me. Every other route needs this login, and you
only see hotels you're linked to: create one with
POST /hotels(you're linked automatically), and add a colleague withPOST /hotels/{id}/users.
For production, register https://<api-domain>/auth/google/callback too and
set GOOGLE_REDIRECT_URI, FRONTEND_URL and the SESSION_* settings (see
.env.example). The frontend must call the API with credentials: "include".
render.yaml declares the API on Render's free plan, with Neon as the database.
See docs/decisions/0054-hosted-on-render.md for why.
- Check the Neon
productionhost saysus-east-1. For another region, changeregioninrender.yamlfirst, because Render can't change it afterwards. - In Render, choose New > Blueprint and pick this repo. Enter the values it
asks for:
DATABASE_URL: the pooled (-pooler) Neon URLDATABASE_URL_UNPOOLED: the direct Neon URLPREDICTHQ_TOKEN,GOOGLE_CLIENT_ID,GOOGLE_CLIENT_SECRETGOOGLE_REDIRECT_URI:https://<service>.onrender.com/auth/google/callback. The service's URL appears once it exists, so correct this afterwards if the name was taken.
- Add the same redirect URI to the Google OAuth client.
- Check it:
https://<service>.onrender.com/healthreturns{"status":"ok"}.- Open
/auth/google/loginand sign in. You land onFRONTEND_URL, which is a dead page until a frontend is hosted. Then/auth/meshows your user.
Each deploy applies migrations before the server starts, and a failed migration fails the deploy. The service sleeps after 15 minutes without requests, so the first request after that is slow, and any job still running is killed.
# Lint
just lint
# Format
just format
# Fix lint issues + format
just fix# Install hooks (ruff formatting/linting + conventional commits)
just hooksCommit messages must follow Conventional Commits:
feat: add pricing endpointfix: correct rate calculationdocs: update README
foresight/
├── backend/
│ ├── foresight/ # Installable package (see pyproject.toml)
│ │ ├── main.py # FastAPI app (foresight.main:app)
│ │ ├── config.py # Settings (pydantic-settings)
│ │ ├── worker.py # Runs background jobs
│ │ ├── routes/ # HTTP: routers and their schemas
│ │ ├── services/ # Business logic: domain, ingest, adapters, ml
│ │ ├── repository/ # Data access
│ │ └── database/ # Models, enums, session, Alembic migrations
│ ├── tests/
│ ├── pyproject.toml
│ └── Dockerfile
├── docs/
│ ├── system-design.md # How the backend fits together
│ └── decisions/ # One design decision per file
├── frontend/ # React app; see frontend/README.md
├── docker-compose.yml
├── justfile
└── .env.example
See docs/system-design.md for the layers, data
model, jobs and API.