Backend API for AI-Powered Multilingual Healthcare Platform
Powering intelligent healthcare with N-ATLaS β our custom multilingual AI model for Nigerian languages and medical contexts.
Kliniq API is a production-ready FastAPI backend that powers the Kliniq healthcare platform. It provides secure, scalable APIs for:
- π€ AI-powered symptom triage with N-ATLaS multilingual model
- π€ Voice transcription and translation across 4 Nigerian languages
- π₯ Patient and clinician management with role-based access
- π₯ Hospital integration and appointment scheduling
- π Real-time health analytics and medical records
At the heart of Kliniq is N-ATLaS (Nigerian-Adapted Translation and Language System), a custom AI model deployed on Modal cloud infrastructure:
| Feature | Description |
|---|---|
| π£οΈ Multilingual Chat | Fluent in English, Hausa, Igbo, and Yoruba |
| π©Ί Medical Triage | Symptom assessment with urgency classification |
| π§ Tool Calling | Structured function calls for appointments and triage creation |
| π Context Awareness | Incorporates patient history, doctor notes, and appointments |
| π Translation | Seamless translation between all supported languages |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Kliniq Frontend β
βββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Kliniq API (FastAPI) β
β βββββββββββββββ βββββββββββββββ βββββββββββββββββββββββ β
β β Dashboard β β Clinician β β Messages Module β β
β β Module β β Module β β (Voice + Text) β β
β ββββββββ¬βββββββ ββββββββ¬βββββββ ββββββββββββ¬βββββββββββ β
β β β β β
β ββββββββββββββββββΌββββββββββββββββββββββ β
β βΌ β
β βββββββββββββββββββββββββ β
β β LLM Service β β
β β (N-ATLaS Interface) β β
β βββββββββββββ¬ββββββββββββ β
ββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββ
β Modal Cloud GPU β
β (N-ATLaS Model) β
βββββββββββββββββββββββββ
- JWT-based authentication with refresh tokens
- Email verification and password reset
- Role-based access control (Patient, Nurse, Doctor)
- Personal health dashboard data
- AI chat with conversation history
- Hospital linking via codes
- Medical notes and vitals tracking
- Nurse/Doctor dashboard with statistics
- Patient list with triage status
- Detailed patient profiles with AI analysis
- Appointment request management
- Gamification with points system
- Real-time messaging between patients and clinicians
- Voice message support with transcription
- Multi-language translation
- Appointment scheduling and management
- Calendar integration
- Automated reminders
| Category | Technology |
|---|---|
| Framework | FastAPI 0.115 |
| Database | PostgreSQL 15 + SQLAlchemy 2.0 |
| Async | asyncpg, aiohttp |
| Authentication | PyJWT, bcrypt, passlib |
| AI/LLM | Modal (GPU cloud), Custom N-ATLaS model |
| Validation | Pydantic 2.10 |
| Migrations | Alembic |
| aiosmtplib |
- Python 3.11+
- PostgreSQL 15+
- Modal account (for AI features)
# Clone the repository
git clone https://github.com/your-repo/kliniq-api.git
cd kliniq-api
# Create virtual environment
python -m venv venv
# Activate virtual environment
# Windows:
venv\Scripts\activate
# macOS/Linux:
source venv/bin/activate
# Install dependencies
pip install -r requirements.txtCreate a .env file:
# Database
DATABASE_URL=postgresql+asyncpg://user:password@localhost:5432/kliniq
# JWT Authentication
SECRET_KEY=your-secret-key-here
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30
REFRESH_TOKEN_EXPIRE_DAYS=7
# Email (optional)
MAIL_USERNAME=your-email@gmail.com
MAIL_PASSWORD=your-app-password
MAIL_FROM=noreply@kliniq.com
MAIL_SERVER=smtp.gmail.com
MAIL_PORT=587
# Modal AI Endpoint
MODAL_ENDPOINT_URL=https://your-modal-endpoint.modal.run/generate# Create database
createdb kliniq
# Run migrations
alembic upgrade head
# Seed test data (optional)
python -m scripts.seed_test_datauvicorn src.main:app --reload --port 8001API documentation available at:
- Swagger UI: http://localhost:8001/docs
- ReDoc: http://localhost:8001/redoc
kliniq-api/
βββ src/
β βββ main.py # FastAPI application entry
β βββ auth/ # Authentication module
β β βββ dependencies.py # Auth dependencies
β β βββ auth_controller.py
β βββ common/
β β βββ database/ # Database configuration
β β βββ llm/ # N-ATLaS LLM service
β β βββ llm_service.py
β β βββ modal_app.py # Modal deployment
β β βββ tool_executor.py
β βββ models/
β β βββ models.py # SQLAlchemy models
β βββ modules/
β β βββ dashboard/ # Patient dashboard
β β βββ clinician/ # Clinician portal
β β βββ messages/ # Messaging system
β β βββ appointments/ # Appointment management
β βββ router/
β βββ routers.py # API router aggregation
βββ alembic/ # Database migrations
βββ scripts/ # Utility scripts
βββ requirements.txt
| Method | Endpoint | Description |
|---|---|---|
| POST | /auth/register |
Register new user |
| POST | /auth/login |
Login and get tokens |
| POST | /auth/refresh |
Refresh access token |
| GET | /auth/me |
Get current user |
| Method | Endpoint | Description |
|---|---|---|
| GET | /dashboard |
Get dashboard data |
| POST | /dashboard/chat |
Send AI chat message |
| GET | /dashboard/chat/history |
Get chat history |
| POST | /dashboard/hospitals/link |
Link to hospital |
| Method | Endpoint | Description |
|---|---|---|
| GET | /clinician |
Get clinician dashboard |
| GET | /clinician/patients |
List patients |
| GET | /clinician/patient/{id} |
Patient detail with AI analysis |
| GET | /clinician/requests |
Get appointment requests |
| POST | /clinician/requests/{id}/approve |
Approve request |
| GET | /clinician/doctors/{hospital_id} |
Get doctors by hospital |
# Run tests
pytest
# With coverage
pytest --cov=srcThis API was built for Awarri Developer Challenge 2025 demonstrating:
- AI Innovation β Custom N-ATLaS model for Nigerian healthcare
- Production Quality β Async architecture, proper error handling, migrations
- Security β JWT auth, role-based access, input validation
- Scalability β Modular design, cloud AI deployment on Modal
- Real Impact β Solving language barriers in Nigerian healthcare
MIT License - See LICENSE for details.
Built with β€οΈ for Nigerian Healthcare