NigehbaanDastak is a clinic-management MVP built for portfolio and interview presentation. It focuses on practical backend architecture, clear API behavior, security-minded defaults, and a demo-ready frontend.
- patient management (CRUD + archive)
- appointment management (CRUD + status transitions)
- visit/encounter management (linked to patient and optional appointment)
- role-based permissions via demo roles (
admin,doctor,receptionist) - audit logging for sensitive write actions
- standardized API errors with request IDs
- basic write-rate limiting
- prescriptions management with medication items and printing
- queue management system for clinic workflow optimization
- follow-up tracking for patient care coordination
- analytics dashboard with clinic metrics and insights
- patient timeline for comprehensive history tracking
- React demo UI for auth simulation + complete clinic workflows
Intentionally deferred:
- notifications
- billing
- attachments
- patient self-service portals
- backend: FastAPI + SQLAlchemy + Alembic
- pattern: route -> service -> repository
- frontend: React + TypeScript + React Router
- testing: pytest API/integration/unit coverage for critical flows
Detailed module architecture:
Base path: /api/v1
- system:
/health - patients: list/create/detail/update/archive/timeline
- appointments: list/create/detail/update/delete/queue management
- visits: create/detail/update
- prescriptions: create/detail/update/delete/print
- queue: clinic queue management with status tracking
- follow-ups: create/update/complete/cancel
- analytics: clinic summary and insights
Role behavior and response conventions:
- PostgreSQL installed and running locally
- Node.js (v18+) for frontend
- Python (v3.8+) for backend
- Docker (optional, for containerized setup)
cd infra
cp .env.example .env
docker compose up --build
docker compose exec backend alembic upgrade headServices:
- Backend:
http://localhost:8000/api/v1 - Frontend:
http://localhost:5173 - Health Check:
http://localhost:8000/api/v1/health
# Start PostgreSQL service
brew services start postgres
# Create database
createdb nigehbaan_dastak
# Create postgres user (if doesn't exist)
psql postgres
CREATE USER postgres WITH SUPERUSER PASSWORD 'postgres';
\qcd backend
# Create and activate virtual environment
python3 -m venv .venv
source .venv/bin/activate
# Install dependencies
pip install -e ".[dev]"
# Configure environment
cp .env.example .env
# Ensure .env contains:
# ND_POSTGRES_SERVER=localhost
# ND_POSTGRES_PORT=5432
# ND_POSTGRES_USER=postgres
# ND_POSTGRES_PASSWORD=postgres
# ND_POSTGRES_DB=nigehbaan_dastak
# ND_CORS_ORIGINS=["http://localhost:5173"]
# Run database migrations
alembic upgrade head
# Start backend server
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000cd frontend
# Install dependencies
npm install
# Configure API URL (optional, defaults to localhost:8000/api/v1)
echo "VITE_API_URL=http://localhost:8000/api/v1" > .env
# Start frontend development server
npm run dev- Backend Health: Open
http://localhost:8000/api/v1/healthin browser - Frontend: Open
http://localhost:5173- should show "API Status: Connected" - API Documentation: Open
http://localhost:8000/api/v1/docsfor Swagger UI
# Find process using port 8000
lsof -i :8000
# Kill the process
sudo lsof -ti :8000 | xargs kill -9# Check PostgreSQL is running
brew services list | grep postgres
# Verify database exists
psql -l
# Test connection
psql -h localhost -U postgres -d nigehbaan_dastak- Ensure backend is running on port 8000
- Check CORS origins in backend
.envincludeshttp://localhost:5173 - Verify API URL in frontend
.envis correct
Frontend (React) Backend (FastAPI) Database (PostgreSQL)
| | |
| HTTP Requests | SQLAlchemy ORM |
|---------------------->| |
| | SQL Queries |
| |---------------------->|
| | |
| JSON Response | |
|<----------------------| |
The application uses demo role-based authentication via HTTP headers:
- Admin Role: Full access to patient lifecycle, appointment deletion
- Doctor Role: Patient read/search, appointment/visit management
Frontend Role Selection: The UI provides role switcher to simulate different user types
Backend Authorization: All API endpoints validate the X-Demo-Role header
Patients (1) -----> (N) Appointments (1) -----> (N) Visits
| | |
v v v
Archive/Restore Status Transitions Clinical Notes
| | |
v v v
Prescriptions Queue System Follow-ups
Audit Logs Doctor Workload Patient Timeline
Users Analytics Care Coordination
-
Patient Management
- Create patients with medical record numbers
- Search and filter patients
- Archive inactive patients
- Comprehensive patient timeline
- Prescription and follow-up history
-
Appointment Workflow
- Schedule appointments for patients
- Status tracking (scheduled, completed, cancelled, no_show)
- Link appointments to clinical visits
- Queue management for clinic operations
- Doctor assignment and workload tracking
-
Visit Documentation
- Create clinical encounters
- Record complaints and diagnoses
- Optional appointment linking
- Prescription creation during visits
- Follow-up scheduling
-
Prescription Management
- Create prescriptions with multiple medications
- Detailed dosage and frequency instructions
- Prescription printing for patients
- Link prescriptions to visits and patients
-
Queue System
- Real-time clinic queue management
- Patient check-in/check-out workflow
- Queue status tracking (waiting, in_progress, completed)
- Doctor queue assignment
-
Follow-up Tracking
- Schedule patient follow-ups
- Status management (pending, completed, cancelled, overdue)
- Care coordination reminders
- Link follow-ups to visits
-
Analytics Dashboard
- Clinic summary statistics
- Appointment trends and patterns
- Doctor workload analysis
- Patient acquisition metrics
-
Audit Trail
- Automatic logging of all sensitive operations
- Track who did what and when
- Essential for healthcare compliance
| Method | Endpoint | Purpose | Required Role |
|---|---|---|---|
| GET | /health |
System health check | Any |
| GET/POST | /patients |
List/create patients | Admin/Doctor |
| GET/PATCH/DELETE | /patients/{id} |
Patient operations | Admin/Doctor |
| GET | /patients/{id}/timeline |
Patient timeline | Admin/Doctor |
| GET/POST | /appointments |
List/create appointments | Admin/Doctor |
| GET/PATCH/DELETE | /appointments/{id} |
Appointment operations | Admin (delete) |
| POST | /appointments/{id}/check-in |
Check-in patient | Admin/Doctor |
| GET/POST | /visits |
List/create visits | Admin/Doctor |
| GET | /visits/{id} |
Visit details | Admin/Doctor |
| GET/POST | /prescriptions |
List/create prescriptions | Admin/Doctor |
| GET/PATCH/DELETE | /prescriptions/{id} |
Prescription operations | Admin/Doctor |
| GET | /prescriptions/{id}/print |
Print prescription | Admin/Doctor |
| GET | /queue |
View clinic queue | Admin/Doctor |
| POST | /queue/{id}/call |
Call next patient | Admin/Doctor |
| POST | /queue/{id}/complete |
Complete queue entry | Admin/Doctor |
| GET/POST | /follow-ups |
List/create follow-ups | Admin/Doctor |
| GET/PATCH | /follow-ups/{id} |
Update follow-up | Admin/Doctor |
| POST | /follow-ups/{id}/complete |
Complete follow-up | Admin/Doctor |
| GET | /analytics/summary |
Clinic analytics | Admin/Doctor |
| GET | /analytics/appointments-by-day |
Appointment trends | Admin/Doctor |
| GET | /analytics/doctor-workload |
Doctor workload | Admin/Doctor |
- Start Backend:
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000 - Start Frontend:
npm run dev - Access Application:
http://localhost:5173 - API Documentation:
http://localhost:8000/api/v1/docs
- Replace demo role auth with JWT/session-based authentication
- Add database connection pooling
- Implement distributed rate limiting
- Add background job processing
- Set up monitoring and observability
Run all backend tests:
cd backend
python3 -m pytestTargeted confidence suites:
python3 -m pytest tests/test_auth_api.py tests/test_integration_flows.py
python3 -m pytest tests/test_schema_validation.py tests/test_audit_service_unit.pyFrontend build confidence check:
cd frontend
npm run buildDetailed plan:
Quick recommendation for lowest complexity/cost:
- Frontend on Vercel
- Backend on Railway (or Render)
- Postgres on same backend vendor
Why:
- minimal ops overhead for solo maintenance
- straightforward environment variable management
- easy interview explanation
- local:
infra/.env.example - production template:
infra/.env.production.example
Core production settings:
ND_ENVIRONMENT=productionND_DEBUG=falseND_DATABASE_URL=<managed postgres url>ND_CORS_ORIGINS=["https://<frontend-domain>"]
This MVP uses demo auth role simulation with doctor-profile linking.
admin: patient lifecycle + appointment delete + full analyticsdoctor: patient read/search + appointment/visit/prescription managementreceptionist: read-only intake simulation with queue management
Doctor flows are profile-scoped. The app now resolves and stores the logged-in doctor profile automatically during demo login (no manual doctor profile ID entry required).
Use synthetic data only. Current demo dataset:
- 34 active patients with comprehensive demographics
- 12 appointments with various statuses
- 7 completed visits with clinical documentation
- 15 prescriptions across multiple patients
- 8 follow-ups for care coordination
- Queue system with real-time status tracking
This rich dataset demonstrates all major clinic workflows and analytics capabilities.
Use this as your portfolio/project blurb:
Modular clinic MVP with FastAPI + React, covering patient, appointment, and visit workflows, with audit logging, standardized API error handling, and practical test coverage for critical flows.
Suggested screenshots and live demo script:
- demo-role header auth only (no production auth/session model yet)
- in-memory rate limiting (single instance)
- no background workers
- no file attachments
- no notifications system
- no billing module
- no patient self-service portal
- replace demo-role auth with real authentication and user model
- notifications and reminders system with async task processing
- file attachments for documents and medical images
- billing and insurance processing
- patient self-service portal
- stronger production controls (distributed rate limiting, observability, CI/CD)
- mobile-responsive design improvements
- advanced reporting and export capabilities
- architecture:
docs/architecture.md - API summary:
docs/api.md - deployment guide:
docs/deployment.md - portfolio notes/demo script:
docs/portfolio.md