Local Development¶
This runbook covers setting up the Curaway backend and frontend for local development.
Prerequisites¶
| Tool | Version | Purpose |
|---|---|---|
| Python | 3.12+ | Backend runtime |
| Node.js | 18+ | Frontend runtime |
| npm | 9+ | Frontend package manager |
| Git | 2.40+ | Version control |
| Docker | 24+ (optional) | Running PostgreSQL, Neo4j, Qdrant locally |
Docker is Optional
In production, Curaway uses managed services (Railway PostgreSQL, Aura Neo4j, Qdrant Cloud). For local development, you can either run these via Docker or point your .env at the staging instances.
Backend Setup¶
1. Clone the Repository¶
2. Create the Environment File¶
Edit .env and fill in the required values. See the configuration reference for all variables. At minimum, you need:
DATABASE_URL-- PostgreSQL connection stringOPENAI_API_KEY-- For LLM and embeddingsCLERK_SECRET_KEY-- For JWT validation (or setAUTH_DISABLED=true)
For local development with auth disabled:
3. Set Up a Virtual Environment¶
python -m venv .venv
source .venv/bin/activate # On macOS/Linux
# .venv\Scripts\activate # On Windows
4. Install Dependencies¶
This installs the application in editable mode along with development dependencies (pytest, ruff, mypy, etc.).
5. Run Database Migrations¶
This applies all pending Alembic migrations to your PostgreSQL database. See the database operations runbook for more details.
6. Seed the Database¶
This runs the base seed (tenant + consent records). For a fully populated local environment, run the full seed sequence described in the seed data runbook.
7. Start the Development Server¶
The server will start at http://localhost:8000 with auto-reload enabled. The interactive API docs are available at:
- Swagger UI:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc - OpenAPI JSON:
http://localhost:8000/openapi.json
8. Verify the Server Is Running¶
Expected response:
Frontend Setup¶
1. Navigate to the Frontend Directory¶
The frontend is in a separate repository or directory (depending on your setup):
2. Install Dependencies¶
3. Create the Environment File¶
Key frontend environment variables:
NEXT_PUBLIC_API_URL=http://localhost:8000/api/v1
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_xxxx
CLERK_SECRET_KEY=sk_test_xxxx
NEXT_PUBLIC_FLAGSMITH_API_KEY=xxxx
4. Start the Development Server¶
The frontend will start at http://localhost:3000 with hot module replacement enabled.
Running Tests¶
Backend Tests¶
# Run all tests
pytest
# Run with coverage
pytest --cov=app --cov-report=html
# Run a specific test file
pytest tests/test_cases.py
# Run tests matching a keyword
pytest -k "test_patient_create"
# Run with verbose output
pytest -v
Linting and Type Checking¶
# Lint with ruff
ruff check .
# Auto-fix lint issues
ruff check --fix .
# Type checking with mypy
mypy app/
Frontend Tests¶
Local Services via Docker (Optional)¶
If you want to run databases locally instead of using managed staging instances:
# PostgreSQL
docker run -d \
--name curaway-postgres \
-e POSTGRES_USER=curaway \
-e POSTGRES_PASSWORD=curaway \
-e POSTGRES_DB=curaway \
-p 5432:5432 \
postgres:16
# Neo4j
docker run -d \
--name curaway-neo4j \
-e NEO4J_AUTH=neo4j/curaway123 \
-p 7474:7474 \
-p 7687:7687 \
neo4j:5
# Qdrant
docker run -d \
--name curaway-qdrant \
-p 6333:6333 \
qdrant/qdrant:latest
Then update your .env accordingly:
DATABASE_URL=postgresql+asyncpg://curaway:curaway@localhost:5432/curaway
NEO4J_URI=bolt://localhost:7687
NEO4J_USERNAME=neo4j
NEO4J_PASSWORD=curaway123
QDRANT_URL=http://localhost:6333
Common Development Tasks¶
Adding a New Endpoint¶
- Create or update the route in
app/api/v1/routes/. - Add Pydantic request/response schemas in
app/schemas/. - Add business logic in
app/services/. - Write tests in
tests/. - Run
pytestandruff check .to validate.
Adding a New Alembic Migration¶
Resetting the Local Database¶
Updating Dependencies¶
IDE Setup¶
VS Code (Recommended)¶
Install these extensions:
- Python (ms-python.python)
- Pylance (ms-python.vscode-pylance)
- Ruff (charliermarsh.ruff)
- ESLint (dbaeumer.vscode-eslint)
Recommended settings.json: