# NOMAZRA API — Complete Endpoint Index
Base URL: `https://nomazra.kelthos.com/api/nomazra/`
WebSocket: `wss://nomazra.kelthos.com/ws/nomazra/`

## Authentication (01_AUTH.md)
| Method | Endpoint | Auth | Description |
|--------|----------|------|-------------|
| POST | /auth/register/ | No | Register new account |
| POST | /auth/login/ | No | Login, get JWT tokens |
| POST | /auth/refresh/ | No | Refresh access token |
| GET | /auth/me/ | Yes | Get current user profile |
| PATCH | /auth/me/update/ | Yes | Update display name |
| POST | /auth/me/password/ | Yes | Change password |
| POST | /auth/me/fcm-token/ | Yes | Store FCM device token |
| POST | /auth/delete-account/ | Yes | Soft delete account |

## Conversations & Chat (02_CONVERSATIONS.md)
| Method | Endpoint | Auth | Description |
|--------|----------|------|-------------|
| GET | /conversations/ | Yes | List all conversations |
| POST | /conversations/ | Yes | Create new conversation |
| GET | /conversations/{id}/ | Yes | Get conversation with messages |
| DELETE | /conversations/{id}/ | Yes | Delete conversation |
| GET | /conversations/{id}/messages/ | Yes | Get messages |
| POST | /conversations/{id}/messages/ | Yes | Send message + get AI response |

## Documents & Upload (03_DOCUMENTS.md)
| Method | Endpoint | Auth | Description |
|--------|----------|------|-------------|
| POST | /upload/ | Yes | Upload file to R2 storage |
| GET | /documents/ | Yes | List all documents |
| POST | /documents/ | Yes | Upload + analyze document |
| GET | /documents/{id}/ | Yes | Get document detail |
| DELETE | /documents/{id}/ | Yes | Delete document |

## Voice (04_VOICE.md)
| Method | Endpoint | Auth | Description |
|--------|----------|------|-------------|
| POST | /voice/start-session/ | Yes | Start voice session |
| POST | /voice/end-session/ | Yes | End voice session + summary |
| POST | /voice/transcribe/ | Yes | Transcribe audio (Whisper) |
| GET | /voice/sessions/ | Yes | List voice sessions |
| POST | /voice/tts/ | Yes | Text-to-speech (OpenAI TTS) |

## Rights Cards (05_RIGHTS_CARDS.md)
| Method | Endpoint | Auth | Description |
|--------|----------|------|-------------|
| GET | /rights-cards/ | Yes | List rights cards |
| GET | /rights-cards/{id}/ | Yes | Get rights card detail |
| GET | /rights-cards/category/{cat}/ | Yes | Filter by category |

## Glossary (06_GLOSSARY.md)
| Method | Endpoint | Auth | Description |
|--------|----------|------|-------------|
| GET | /glossary/ | No | List legal terms |
| GET | /glossary/search/?q= | No | Search terms |
| GET | /glossary/{term}/ | No | Get term detail |

## Legal Tools (07_TOOLS.md)
| Method | Endpoint | Auth | Description |
|--------|----------|------|-------------|
| POST | /statute-check/ | Yes | Check statute of limitations |
| POST | /cost-estimate/ | Yes | Estimate legal costs |
| POST | /contract-draft/ | Yes | Draft a legal contract |
| POST | /law-search/ | Yes | Search applicable laws |

## Bookmarks & Reminders (08_BOOKMARKS_REMINDERS.md)
| Method | Endpoint | Auth | Description |
|--------|----------|------|-------------|
| GET | /bookmarks/ | Yes | List bookmarks |
| POST | /bookmarks/ | Yes | Bookmark a message |
| DELETE | /bookmarks/{id}/ | Yes | Remove bookmark |
| GET | /reminders/ | Yes | List reminders |
| POST | /reminders/ | Yes | Create reminder |
| PATCH | /reminders/{id}/ | Yes | Update reminder |
| DELETE | /reminders/{id}/ | Yes | Delete reminder |

## Stats, Feedback & Emergency (09_STATS_FEEDBACK_EMERGENCY.md)
| Method | Endpoint | Auth | Description |
|--------|----------|------|-------------|
| GET | /stats/ | Yes | User activity stats |
| POST | /feedback/{message_id}/ | Yes | Submit feedback on AI response |
| GET | /emergency-info/ | Yes | Emergency legal hotlines |

## PDF Export (11_EXPORT_TTS.md)
| Method | Endpoint | Auth | Description |
|--------|----------|------|-------------|
| POST | /export/pdf/{message_id}/ | Yes | Export AI response as PDF |

## Countries
| Method | Endpoint | Auth | Description |
|--------|----------|------|-------------|
| GET | /countries/ | Yes | List supported countries |
| GET | /countries/{code}/topics/ | Yes | Get country's legal topics |

## Real-Time Voice Call — WebSocket (10_REALTIME_CALL.md)
| Protocol | URL | Auth |
|----------|-----|------|
| WSS | /ws/nomazra/call/{conversation_id}/?token=JWT | Query param |

**Client → Server:** `call.start`, `audio.chunk`, `audio.stop`, `call.interrupt`, `call.end`
**Server → Client:** `call.connected`, `transcription.final`, `response.text.done`, `response.audio.delta`, `response.audio.done`, `call.summary`, `call.ended`, `error`

---

## Total: 38 REST endpoints + 1 WebSocket channel

## Backend Stack
- Django 5 + DRF + Daphne ASGI
- Django Channels 4.3.2 + Redis (WebSocket)
- OpenAI GPT-4o-mini (chat), Whisper (transcription), TTS-1 (voice)
- Cloudflare R2 (file storage)
- ReportLab (PDF generation)
- PostgreSQL (database)
- Firebase Admin SDK (FCM push only)
