Documentation
Run the API locally, upload policies, process a questionnaire, and export answers.
Quickstart
git clone https://github.com/Nikhil-creat/questionnaire-ai.git
cd questionnaire-ai/apps/api
pip install -r requirements.txt
uvicorn main:app --reload # http://localhost:8000
Example
TOKEN=$(curl -s -X POST localhost:8000/api/auth/register -H 'Content-Type: application/json' -d '{"email":"you@company.com","password":"a-long-password","org":"Acme"}' | python -c "import sys,json;print(json.load(sys.stdin)['token'])")
curl -H "Authorization: Bearer $TOKEN" -F file=@policy.md localhost:8000/api/documents
curl -H "Authorization: Bearer $TOKEN" -F file=@questionnaire.xlsx localhost:8000/api/questionnaires
API reference
| Method and path | Purpose |
|---|---|
POST /api/auth/register and /login | Create an account or log in; returns a bearer token |
POST /api/documents | Upload a policy (pdf, docx, txt, md) |
POST /api/questionnaires | Upload XLSX; returns drafted, cited answers |
GET /api/questionnaires/{id} | Fetch a run |
POST /api/questionnaires/{id}/items/{n}/approve | Approve (optionally edit) an answer; adds it to the library |
GET /api/questionnaires/{id}/export | Download the answered XLSX |
GET /api/questionnaires/{id}/gaps | Why answers were escalated |
GET /api/stale-documents | Policies past their review date |
GET /api/audit | Audit log |
GET /health | Health check |
Configuration
| Variable | Meaning |
|---|---|
ANTHROPIC_API_KEY | Enables LLM drafting. Without it, offline extractive mode is used. |
ANTHROPIC_MODEL | Model name for drafting |
JWT_SECRET | Required in production: 32+ random characters for signing tokens |
DATABASE_URL | Postgres connection string. Empty means in-memory dev mode |
ALLOW_REGISTER | Set to 0 to close open registration |
RATE_LIMIT | Max /api requests per minute per client (default 60) |
All data is scoped to the tenant inside your login token. Clients cannot choose a tenant.
Limits
Without DATABASE_URL data lives in memory and is lost on restart. Postgres mode is built but should be independently tested before real customer data. See the Security page.