Learning project. I'm building this to explore Rust, PostgreSQL vector search, face recognition, Docker, and web development. It isn't meant to compete with commercial products.
🚧 Work in progress. The app runs end to end (register, live camera recognition, personalized output), but it's slow and not pretty yet. See ROADMAP.md for current status.
Facebase recognizes the person in front of a camera and shows them a personalized display, such as a greeting, weather, to-dos, or calendar, generated by an LLM from their profile. Unknown faces get a generic guest view.
- Register: take a photo from the webcam (or give one to the CLI) along with a name. The face embedding is stored in Postgres (pgvector) and linked to that person's profile. The photo itself is not kept.
- Recognize: every few seconds, the current camera frame is embedded and compared against the stored embeddings using cosine distance. If the closest match is under the threshold, that person is identified. Otherwise they're treated as a guest.
- Personalize: the recognized person's profile is sent to Claude, which writes their personalized output. If the same person is still in front of the camera, the previous output is reused instead of calling the LLM again.
- Display: the output appears on the web page and updates when someone new steps in front of the camera.
browser (web page + webcam)
│ POST /api/recognize, /api/register (image)
▼
Rust server (axum) ──▶ Python embedding (DeepFace / ArcFace)
│
├──▶ PostgreSQL + pgvector (people, face embeddings)
└──▶ Claude API (personalized output)
- Rust (
organizer/): CLI, web server, database, and LLM logic - Python (
python/): generates face embeddings with DeepFace - Frontend (
organizer/static/index.html): plain HTML + JS, no framework - Database (
db/schema.sql): tables and the pgvector extension - Docker (
Dockerfile,docker-compose.yml): runs the app and the database in containers
| Feature | Status |
|---|---|
| Register a face (CLI and web app) | ✅ Done |
| Recognize a face (CLI and web app) | ✅ Done |
| Personalized LLM output | ✅ Done |
| Guest view | ✅ Done |
| Live camera recognition | ✅ Done |
| One-command install with Docker | ✅ Done |
| Speed and cleanup | ⏳ Planned |
The easiest way to run Facebase. You only need Docker Desktop and an Anthropic API key.
git clone <repo-url> facebase
cd facebase
cp .env.example .envEdit .env: set ANTHROPIC_API_KEY and change POSTGRES_PASSWORD. Then:
docker compose up -d --buildOpen http://localhost:3000:
- Type a name and click Register. This takes a photo from the webcam.
- Click Start camera. The page recognizes you every few seconds and shows your personalized output.
Good to know:
- The first build is slow and the image is about 3GB, mostly TensorFlow.
- The first photo is slow too, because DeepFace downloads its model weights (about 500MB). They're saved in a Docker volume, so this only happens once.
- Use
localhost. Browsers only allow camera access onlocalhostor HTTPS, so opening the page from another device won't work. POSTGRES_*values are only used the first time the database starts. To change them later, wipe the database withdocker compose down -v. This deletes all registered people.
Everyday commands:
docker compose up -d --build # start, or rebuild after code changes
docker compose down # stop (data and model weights are kept)
docker compose logs -f app # follow the app's output
docker compose down -v # stop and DELETE all data and model weightsFor working on the code with cargo run.
- Rust (via rustup)
- PostgreSQL with the pgvector extension, or just the Docker database (see below)
- uv, which manages the Python environment and DeepFace
- An Anthropic API key
Copy .env.example to .env in the repo root and fill it in:
| Variable | Required | Used for |
|---|---|---|
ANTHROPIC_API_KEY |
Yes | Generating personalized output |
DATABASE_URL |
Yes | Connecting to Postgres, e.g. postgres://user:password@localhost:5432/facebase |
POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB |
Docker only | Creating the database in the db container |
BIND_ADDR |
No | Address the web server listens on (default 127.0.0.1:3000) |
PYTHON_DIR |
No | Folder holding embedding.py (default ./python, relative to where you run the command) |
Choose one:
- Use the Docker database (easiest). Start only the
dbservice. It's exposed on port 5433 so it won't clash with a local Postgres:Then setdocker compose up -d db
DATABASE_URL=postgres://<POSTGRES_USER>:<POSTGRES_PASSWORD>@localhost:5433/<POSTGRES_DB>. - Use your own Postgres. Create a database and load the schema:
createdb facebase psql -d facebase -f db/schema.sql
schema.sqlis safe to run more than once.
The Rust binary shells out to uv run for the embedding script, so you don't need to activate a virtualenv yourself. uv reads python/pyproject.toml and creates python/.venv automatically on the first run.
To pre-install the dependencies (optional; otherwise this happens on the first run):
cd python
uv syncuv installs the pinned Python (3.13) and DeepFace + TensorFlow into python/.venv. The first embedding also downloads the ArcFace and RetinaFace model weights.
Run these from the repo root, so the default PYTHON_DIR=./python resolves correctly (or set PYTHON_DIR to an absolute path):
# Web app: open http://localhost:3000
cargo run --manifest-path organizer/Cargo.toml -- serve
# Register a person from the CLI (the photo is deleted after registration)
cargo run --manifest-path organizer/Cargo.toml -- register path/to/photo.jpg --name "Alice"
# Recognize a face and print personalized output
cargo run --manifest-path organizer/Cargo.toml -- recognize path/to/unknown.jpg
⚠️ The CLIregistercommand deletes the source photo after storing the embedding. Don't point it at your only copy.
Each person's profile (a JSONB column in people) holds the information the LLM uses to personalize their output, such as interests, location, or to-dos. New people start with an empty profile {}, and for now you fill it in manually:
# With Docker
docker compose exec db psql -U facebase -d facebase
# Then, in psql
UPDATE people SET profile = '{"interests": ["running"], "location": "Boston"}' WHERE name = 'Alice';- Each photo starts a fresh Python process, which reloads TensorFlow and takes several seconds. Live recognition updates about every 3 seconds.
- The match threshold (cosine distance
0.4) is hardcoded. - Only the first confidently detected face in a photo is used.
- Names are unique: registering an existing name again fails instead of adding another photo.
- Errors show up in the web app as a generic "Something went wrong". Check
docker compose logs appfor details.
Claude code was used to write the markdown files and walk me through the html and some debugging. Claude will also be used later for frontend work as I am not interested in learning it deeply.
See LICENSE.