How apknation/afyatrust works
AfyaTrust is a patient-consented clinical-record sharing platform: patients and care teams use role-specific Angular workspaces, while a Django API enforces authentication, grants and referrals, stores clinical data in PostgreSQL, and anchors record integrity to Ethereum. The documented workflow includes record verification, referral handoffs, and audited emergency access; custodial patient wallets support chain transactions. The README documents these stages, but unsampled backend and contract internals limit call-level wiring, so some documented relationships are shown with dashed, uncited edges.
Main entry points: app.routes.ts Role routing · views.py REST endpoints · api.service.ts API client · models.py Clinical records
Components 20
Web experience
- Role routing
frontend/src/app/app.routes.ts - Login and signup
frontend/src/app/pages/login/login.component.ts - Registration
frontend/src/app/pages/register/register.component.ts - Session state
frontend/src/app/services/auth.service.ts - Patient workspace
frontend/src/app/pages/patient/patient-dashboard/patient-dashboard.component.ts - Doctor workspace
frontend/src/app/pages/doctor/doctor-landing/doctor-landing.component.ts - Hospital workspace
frontend/src/app/pages/hospital/hospital-dashboard/hospital-dashboard.component.ts - Account settings
frontend/src/app/pages/account/account.component.ts - Workspace cache
frontend/src/app/services/workspace-state.service.ts
API and access
- API client
frontend/src/app/services/api.service.ts - REST endpoints
backend/afyatrust/api/views.py - Authentication
backend/afyatrust/api/auth_views.py - Custodial wallets
backend/afyatrust/api/wallet_manager.py
Clinical data
- Clinical records
backend/afyatrust/api/models.py - Consent and referrals
backend/afyatrust/api/models.py - PostgreSQL
Blockchain audit
- Chain adapter
backend/afyatrust/api/blockchain.py - Ethereum Sepolia
Other components
- Patient
- Care team
Connections 28
- Patient → Role routing: opens
frontend/src/app/app.routes.ts - Care team → Role routing: opens
frontend/src/app/app.routes.ts - Role routing → Login and signup: routes to
frontend/src/app/app.routes.ts - Role routing → Registration: routes to
frontend/src/app/app.routes.ts - Role routing → Patient workspace: guards route
frontend/src/app/app.routes.ts - Role routing → Doctor workspace: guards route
frontend/src/app/app.routes.ts - Role routing → Hospital workspace: guards route
frontend/src/app/app.routes.ts - Role routing → Account settings: guards route
frontend/src/app/app.routes.ts - Login and signup → Session state: sets session
frontend/src/app/pages/login/login.component.ts - Registration → API client: submits registration
frontend/src/app/pages/register/register.component.ts - Patient workspace → API client: requests data
frontend/src/app/pages/patient/patient-dashboard/patient-dashboard.component.ts - Doctor workspace → API client: requests data
frontend/src/app/pages/doctor/doctor-landing/doctor-landing.component.ts - Hospital workspace → API client: requests data
frontend/src/app/pages/hospital/hospital-dashboard/hospital-dashboard.component.ts - Account settings → API client: requests data
frontend/src/app/pages/account/account.component.ts - Patient workspace → Workspace cache: loads state
frontend/src/app/pages/patient/patient-dashboard/patient-dashboard.component.ts - Doctor workspace → Workspace cache: loads state
frontend/src/app/pages/doctor/doctor-landing/doctor-landing.component.ts - Hospital workspace → Workspace cache: loads state
frontend/src/app/pages/hospital/hospital-dashboard/hospital-dashboard.component.ts - API client → REST endpoints: HTTP requests
- REST endpoints → Authentication: authenticates
backend/afyatrust/api/views.py - REST endpoints → Clinical records: reads and writes
backend/afyatrust/api/views.py - REST endpoints → Consent and referrals: checks access
backend/afyatrust/api/views.py - Clinical records → PostgreSQL: persists
- Consent and referrals → PostgreSQL: persists
- REST endpoints → Custodial wallets: uses keys
backend/afyatrust/api/views.py - REST endpoints → Chain adapter: anchors and verifies
backend/afyatrust/api/views.py - Chain adapter → Ethereum Sepolia: reads and writes
- Clinical records → Chain adapter: hash integrity
- Consent and referrals → Clinical records: authorizes handoff
backend/afyatrust/api/models.py