Getting started¶
Prerequisites¶
Install the CLI¶
This installs two commands: bluefox and bfx (a shorter alias).
Create a project¶
This will:
- Create the
myapp/directory with all project files - Run
uv initto set up the Python project - Run
uv add bluefox-core alembic asyncpgfor runtime dependencies - Run
uv add --dev bluefox-test pytestfor test dependencies
Start developing¶
Docker Compose starts a local Postgres container, runs Alembic migrations, and launches the FastAPI app with --reload. Visit http://localhost:8000 to see the interactive welcome page with system status and a message playground.
Project structure¶
myapp/
main.py # App factory (welcome=True)
models.py # Root-level models (auto-discovered)
items/ # Example module (auto-discovered)
__init__.py
api.py # Router → auto-mounted at /items
models.py # Item model → auto-discovered
.env # Dev environment variables
.env.example # Template for production
Makefile # Dev workflow commands
Dockerfile # Multi-stage production build
docker-compose.yml # Production compose
docker-compose.dev.yml # Dev compose (local Postgres)
alembic.ini # Migration config
migrations/
env.py # One-line Alembic setup
versions/ # Migration files
tests/
conftest.py # Test fixtures
test_health.py # Smoke test
pyproject.toml # Dependencies
Auto-discovery¶
bluefox-core automatically discovers your code by convention:
- Models: any
models.pyor*/models.pyfile is imported, registering tables inBluefoxBase.metadata - Routers: any
api.pyor*/api.pyfile with arouter = APIRouter()is mounted at/{dirname}
No manual imports or registration needed. Just create a module directory, add api.py and/or models.py, and it works.
Create your first migration¶
The generated project includes an Item model in items/models.py. To create a migration for it:
This generates a migration file in migrations/versions/. The next time you run make dev, it will be applied automatically.
Run tests¶
Tests use bluefox-test with real Postgres via testcontainers. Each test runs inside a SAVEPOINT — no cleanup needed.
Next steps¶
- Add a new module: create
users/api.pywith arouterandusers/models.py— they're auto-discovered - See Generated files for details on each file
- See Deployment for deploying with Dokploy