Backend scaffolding for generating civic personas, simulating reactions to housing plans, and producing scenario summaries.
- Install dependencies:
pip install -r requirements.txt
- Provide your OpenAI credentials (optional for mock mode):
# .env BLOCKQUOTE_OPENAI_API_KEY=sk-... BLOCKQUOTE_OPENAI_MODEL=gpt-4.1-mini # override if desired
- Launch the API:
uvicorn backend.app:app --reload
- Test the persona pipeline:
curl -X POST http://127.0.0.1:8000/api/personas/generate \ -H "Content-Type: application/json" \ -d @./example_payload.json
If an API key is not supplied, the service falls back to deterministic mock personas/responses backed by the Jacksonville census CSV in data/jacksonville.csv. SQLite persistence writes to blockquote.db in the project root.
POST /api/personas/generate- Body:
{ "city": "Jacksonville", "census_tracts": ["12031000100"], "persona_count": 8, "housing_plan": "Build 120 mixed-income apartments...", "seed": 42 } - Response:
{ "session_id": "474ce8d3-0b46-43ac-8342-f96752ff371b", "personas": [ ... ], "responses": [ ... ], "summary": { ... } // may be null if no personas }
- Body:
Mock generation supports reproducible seeds; OpenAI mode ignores the seed.
-
GET /api/sessions
Returns recent sessions with metadata (city, tract list, timestamps). -
GET /api/sessions/{session_id}
Loads a full session pack (personas, responses, summary) from the database. -
POST /api/sessions/{session_id}/personas
Adds a persona (accepts the full persona payload) and immediately generates a new reaction + refreshed summary. -
PATCH /api/sessions/{session_id}/personas/{persona_id}
Updates specific persona fields, regenerating that persona's reaction and the session summary. -
DELETE /api/sessions/{session_id}/personas/{persona_id}
Removes a persona and returns the updated session snapshot. -
POST /api/sessions/{session_id}/responses/regenerate
Re-runs persona reactions for the whole session or a supplied subset. Optionally skip summary regeneration by settingrefresh_summarytofalse. -
GET /api/sessions/{session_id}/messages
Fetches the summary-agent thread (default) or a specific persona thread by supplyingpersona_id. -
POST /api/sessions/{session_id}/messages
Sends a user message to the summary agent (omitpersona_id) or to a specific persona (includepersona_id); both user and AI messages are persisted.
The API auto-creates tables on startup. Delete blockquote.db to reset state during development.
- Sessions – landing page lists prior scenarios and offers a “New Session” button.
- Create – form collects city, housing plan, persona count, and optional census tracts before triggering persona generation.
- Curate – review, edit, add, or remove personas before locking the scenario.
- Dashboard – explore persona decisions, chat with the summary agent, and message individual personas.
Configure the frontend with VITE_API_BASE_URL (defaults to http://localhost:8000) and run npm run dev.