# kanishkasahal24/lablens architecture

> Architecture diagram of the GitHub repository kanishkasahal24/lablens, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kanishkasahal24/lablens
- Repository: https://github.com/kanishkasahal24/lablens

## Overview

LabLens is a patient-and-doctor app for recording blood-test results, tracking health trends, and sharing reports with linked clinicians. Patients register, complete a profile, enter reports, and review analysis; doctors manage patient links and review linked patients’ reports. The client routes users to these workflows and sends requests through a shared API client; the server routes requests to controllers, which use models and report-analysis utilities. The README is empty, so feature coverage is inferred from the source tree and indexed modules; unsampled page behavior and database wiring are not asserted beyond visible references.

Main entry points: [`client/src/App.jsx`](https://github.com/kanishkasahal24/lablens/blob/main/client/src/App.jsx) (App routes), [`server/controllers/reportController.js`](https://github.com/kanishkasahal24/lablens/blob/main/server/controllers/reportController.js) (Report operations), [`server/server.js`](https://github.com/kanishkasahal24/lablens/blob/main/server/server.js) (Express API), [`server/controllers/linkController.js`](https://github.com/kanishkasahal24/lablens/blob/main/server/controllers/linkController.js) (Doctor-patient links)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client app"]
  node_app["App routes<br/>[App.jsx]"]
  node_authui["Auth state<br/>[AuthContext.jsx]"]
  node_authhook["Auth hook<br/>[useAuth.js]"]
  node_api["API client<br/>[axios.js]"]
  node_onboarding["Profile onboarding<br/>[OnboardingPage.jsx]"]
  node_profileui["Profile management<br/>[ProfilePage.jsx]"]
  node_patientdash["Patient dashboard<br/>[DashboardPage.jsx]"]
  node_addreport["Report entry<br/>[AddReportPage.jsx]"]
  node_reportdetail["Report analysis view"]
  node_trends["Trend view<br/>[TrendsPage.jsx]"]
  node_doctordash["Doctor dashboard"]
  node_doctorrequests["Link requests"]
  node_doctorpatient["Patient detail"]
end

subgraph group_identity["Identity and care links"]
  node_authroutes["Auth routes<br/>[auth.js]"]
  node_authcontroller["Authentication<br/>[authController.js]"]
  node_linkroutes["Link routes<br/>[links.js]"]
  node_linkcontroller["Doctor-patient links<br/>[linkController.js]"]
  node_authmiddleware["JWT and role checks<br/>[authMiddleware.js]"]
  node_userstore[("User records<br/>[User.js]")]
  node_doctorprofile[("Doctor profile<br/>[DoctorProfile.js]")]
  node_patientprofile[("Patient profile<br/>[PatientProfile.js]")]
  node_linkstore[("Care links<br/>[Link.js]")]
  node_profileroutes["Profile routes<br/>[profile.js]"]
  node_profilecontroller["Profile operations"]
  node_doctorroutes["Doctor routes<br/>[doctors.js]"]
end

subgraph group_reports["Reports and insights"]
  node_reportroutes["Report routes<br/>[reports.js]"]
  node_reportcontroller["Report operations"]
  node_reportstore[("Report records<br/>[Report.js]")]
  node_references[("Parameter references")]
  node_status["Parameter status rules<br/>[parameterStatus.js]"]
  node_analysis["Health analysis<br/>[analysisEngine.js]"]
  node_access["Report access control<br/>[accessControl.js]"]
end

subgraph group_server["API runtime"]
  node_server["Express API<br/>[server.js]"]
end

node_user(("Patient or doctor"))

node_user -->|"uses"| node_app
node_app -->|"provides auth"| node_authui
node_app -->|"routes to"| node_onboarding
node_app -->|"routes to"| node_profileui
node_app -->|"routes to"| node_patientdash
node_app -->|"routes to"| node_addreport
node_app -->|"routes to"| node_reportdetail
node_app -->|"routes to"| node_trends
node_app -->|"routes to"| node_doctordash
node_app -->|"routes to"| node_doctorrequests
node_app -->|"routes to"| node_doctorpatient
node_authhook -->|"reads context"| node_authui
node_authui -->|"requests"| node_api
node_onboarding -->|"requests"| node_api
node_profileui -->|"requests"| node_api
node_addreport -->|"requests"| node_api
node_reportdetail -->|"requests"| node_api
node_server -->|"mounts"| node_authroutes
node_server -->|"mounts"| node_reportroutes
node_server -->|"mounts"| node_profileroutes
node_server -->|"mounts"| node_doctorroutes
node_server -->|"mounts"| node_linkroutes
node_authroutes -->|"dispatches"| node_authcontroller
node_authroutes -->|"uses"| node_authmiddleware
node_linkroutes -->|"dispatches"| node_linkcontroller
node_linkroutes -->|"uses"| node_authmiddleware
node_reportroutes -->|"dispatches"| node_reportcontroller
node_reportroutes -->|"uses"| node_authmiddleware
node_profileroutes -->|"dispatches"| node_profilecontroller
node_profileroutes -->|"uses"| node_authmiddleware
node_doctorroutes -->|"uses"| node_authmiddleware
node_authcontroller -->|"reads/writes"| node_userstore
node_authcontroller -->|"reads/writes"| node_doctorprofile
node_linkcontroller -->|"reads"| node_userstore
node_linkcontroller -->|"reads"| node_doctorprofile
node_linkcontroller -->|"reads"| node_patientprofile
node_linkcontroller -->|"reads/writes"| node_linkstore
node_profilecontroller -->|"reads/writes"| node_userstore
node_profilecontroller -->|"reads/writes"| node_patientprofile
node_profilecontroller -->|"reads/writes"| node_doctorprofile
node_reportcontroller -->|"reads/writes"| node_reportstore
node_reportcontroller -->|"checks links"| node_linkstore
node_reportcontroller -->|"reads"| node_patientprofile
node_reportcontroller -->|"reads"| node_references
node_reportcontroller -->|"calculates status"| node_status
node_reportcontroller -->|"builds analysis"| node_analysis
node_reportcontroller -->|"checks access"| node_access
node_access -->|"checks links"| node_linkstore

click node_app "https://github.com/kanishkasahal24/lablens/blob/main/client/src/App.jsx"
click node_authui "https://github.com/kanishkasahal24/lablens/blob/main/client/src/context/AuthContext.jsx"
click node_authhook "https://github.com/kanishkasahal24/lablens/blob/main/client/src/hooks/useAuth.js"
click node_api "https://github.com/kanishkasahal24/lablens/blob/main/client/src/api/axios.js"
click node_onboarding "https://github.com/kanishkasahal24/lablens/blob/main/client/src/pages/OnboardingPage.jsx"
click node_profileui "https://github.com/kanishkasahal24/lablens/blob/main/client/src/pages/ProfilePage.jsx"
click node_patientdash "https://github.com/kanishkasahal24/lablens/blob/main/client/src/pages/DashboardPage.jsx"
click node_addreport "https://github.com/kanishkasahal24/lablens/blob/main/client/src/pages/AddReportPage.jsx"
click node_reportdetail "https://github.com/kanishkasahal24/lablens/blob/main/client/src/pages/ReportDetailPage.jsx"
click node_trends "https://github.com/kanishkasahal24/lablens/blob/main/client/src/pages/TrendsPage.jsx"
click node_doctordash "https://github.com/kanishkasahal24/lablens/blob/main/client/src/pages/DoctorDashboardPage.jsx"
click node_doctorrequests "https://github.com/kanishkasahal24/lablens/blob/main/client/src/pages/DoctorRequestsPage.jsx"
click node_doctorpatient "https://github.com/kanishkasahal24/lablens/blob/main/client/src/pages/DoctorPatientDetailPage.jsx"
click node_server "https://github.com/kanishkasahal24/lablens/blob/main/server/server.js"
click node_authroutes "https://github.com/kanishkasahal24/lablens/blob/main/server/routes/auth.js"
click node_authcontroller "https://github.com/kanishkasahal24/lablens/blob/main/server/controllers/authController.js"
click node_linkroutes "https://github.com/kanishkasahal24/lablens/blob/main/server/routes/links.js"
click node_linkcontroller "https://github.com/kanishkasahal24/lablens/blob/main/server/controllers/linkController.js"
click node_authmiddleware "https://github.com/kanishkasahal24/lablens/blob/main/server/middleware/authMiddleware.js"
click node_userstore "https://github.com/kanishkasahal24/lablens/blob/main/server/models/User.js"
click node_doctorprofile "https://github.com/kanishkasahal24/lablens/blob/main/server/models/DoctorProfile.js"
click node_patientprofile "https://github.com/kanishkasahal24/lablens/blob/main/server/models/PatientProfile.js"
click node_linkstore "https://github.com/kanishkasahal24/lablens/blob/main/server/models/Link.js"
click node_reportroutes "https://github.com/kanishkasahal24/lablens/blob/main/server/routes/reports.js"
click node_reportcontroller "https://github.com/kanishkasahal24/lablens/blob/main/server/controllers/reportController.js"
click node_reportstore "https://github.com/kanishkasahal24/lablens/blob/main/server/models/Report.js"
click node_references "https://github.com/kanishkasahal24/lablens/blob/main/server/models/ParameterReference.js"
click node_status "https://github.com/kanishkasahal24/lablens/blob/main/server/utils/parameterStatus.js"
click node_analysis "https://github.com/kanishkasahal24/lablens/blob/main/server/utils/analysisEngine.js"
click node_access "https://github.com/kanishkasahal24/lablens/blob/main/server/utils/accessControl.js"
click node_profileroutes "https://github.com/kanishkasahal24/lablens/blob/main/server/routes/profile.js"
click node_profilecontroller "https://github.com/kanishkasahal24/lablens/blob/main/server/controllers/profileController.js"
click node_doctorroutes "https://github.com/kanishkasahal24/lablens/blob/main/server/routes/doctors.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_authui,node_authhook,node_api,node_onboarding,node_profileui,node_patientdash,node_addreport,node_reportdetail,node_trends,node_doctordash,node_doctorrequests,node_doctorpatient toneBlue
class node_authroutes,node_authcontroller,node_linkroutes,node_linkcontroller,node_authmiddleware,node_userstore,node_doctorprofile,node_patientprofile,node_linkstore,node_profileroutes,node_profilecontroller,node_doctorroutes toneAmber
class node_reportroutes,node_reportcontroller,node_reportstore,node_references,node_status,node_analysis,node_access toneMint
class node_server toneRose
class node_user toneIndigo
```

## Components

### Client app

- [App routes](https://github.com/kanishkasahal24/lablens/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Auth state](https://github.com/kanishkasahal24/lablens/blob/main/client/src/context/AuthContext.jsx): `client/src/context/AuthContext.jsx`
- [Auth hook](https://github.com/kanishkasahal24/lablens/blob/main/client/src/hooks/useAuth.js): `client/src/hooks/useAuth.js`
- [API client](https://github.com/kanishkasahal24/lablens/blob/main/client/src/api/axios.js): `client/src/api/axios.js`
- [Profile onboarding](https://github.com/kanishkasahal24/lablens/blob/main/client/src/pages/OnboardingPage.jsx): `client/src/pages/OnboardingPage.jsx`
- [Profile management](https://github.com/kanishkasahal24/lablens/blob/main/client/src/pages/ProfilePage.jsx): `client/src/pages/ProfilePage.jsx`
- [Patient dashboard](https://github.com/kanishkasahal24/lablens/blob/main/client/src/pages/DashboardPage.jsx): `client/src/pages/DashboardPage.jsx`
- [Report entry](https://github.com/kanishkasahal24/lablens/blob/main/client/src/pages/AddReportPage.jsx): `client/src/pages/AddReportPage.jsx`
- [Report analysis view](https://github.com/kanishkasahal24/lablens/blob/main/client/src/pages/ReportDetailPage.jsx): `client/src/pages/ReportDetailPage.jsx`
- [Trend view](https://github.com/kanishkasahal24/lablens/blob/main/client/src/pages/TrendsPage.jsx): `client/src/pages/TrendsPage.jsx`
- [Doctor dashboard](https://github.com/kanishkasahal24/lablens/blob/main/client/src/pages/DoctorDashboardPage.jsx): `client/src/pages/DoctorDashboardPage.jsx`
- [Link requests](https://github.com/kanishkasahal24/lablens/blob/main/client/src/pages/DoctorRequestsPage.jsx): `client/src/pages/DoctorRequestsPage.jsx`
- [Patient detail](https://github.com/kanishkasahal24/lablens/blob/main/client/src/pages/DoctorPatientDetailPage.jsx): `client/src/pages/DoctorPatientDetailPage.jsx`

### Identity and care links

- [Auth routes](https://github.com/kanishkasahal24/lablens/blob/main/server/routes/auth.js): `server/routes/auth.js`
- [Authentication](https://github.com/kanishkasahal24/lablens/blob/main/server/controllers/authController.js): `server/controllers/authController.js`
- [Link routes](https://github.com/kanishkasahal24/lablens/blob/main/server/routes/links.js): `server/routes/links.js`
- [Doctor-patient links](https://github.com/kanishkasahal24/lablens/blob/main/server/controllers/linkController.js): `server/controllers/linkController.js`
- [JWT and role checks](https://github.com/kanishkasahal24/lablens/blob/main/server/middleware/authMiddleware.js): `server/middleware/authMiddleware.js`
- [User records](https://github.com/kanishkasahal24/lablens/blob/main/server/models/User.js): `server/models/User.js`
- [Doctor profile](https://github.com/kanishkasahal24/lablens/blob/main/server/models/DoctorProfile.js): `server/models/DoctorProfile.js`
- [Patient profile](https://github.com/kanishkasahal24/lablens/blob/main/server/models/PatientProfile.js): `server/models/PatientProfile.js`
- [Care links](https://github.com/kanishkasahal24/lablens/blob/main/server/models/Link.js): `server/models/Link.js`
- [Profile routes](https://github.com/kanishkasahal24/lablens/blob/main/server/routes/profile.js): `server/routes/profile.js`
- [Profile operations](https://github.com/kanishkasahal24/lablens/blob/main/server/controllers/profileController.js): `server/controllers/profileController.js`
- [Doctor routes](https://github.com/kanishkasahal24/lablens/blob/main/server/routes/doctors.js): `server/routes/doctors.js`

### Reports and insights

- [Report routes](https://github.com/kanishkasahal24/lablens/blob/main/server/routes/reports.js): `server/routes/reports.js`
- [Report operations](https://github.com/kanishkasahal24/lablens/blob/main/server/controllers/reportController.js): `server/controllers/reportController.js`
- [Report records](https://github.com/kanishkasahal24/lablens/blob/main/server/models/Report.js): `server/models/Report.js`
- [Parameter references](https://github.com/kanishkasahal24/lablens/blob/main/server/models/ParameterReference.js): `server/models/ParameterReference.js`
- [Parameter status rules](https://github.com/kanishkasahal24/lablens/blob/main/server/utils/parameterStatus.js): `server/utils/parameterStatus.js`
- [Health analysis](https://github.com/kanishkasahal24/lablens/blob/main/server/utils/analysisEngine.js): `server/utils/analysisEngine.js`
- [Report access control](https://github.com/kanishkasahal24/lablens/blob/main/server/utils/accessControl.js): `server/utils/accessControl.js`

### API runtime

- [Express API](https://github.com/kanishkasahal24/lablens/blob/main/server/server.js): `server/server.js`

### Other components

- **Patient or doctor**

## Connections

- Patient or doctor → App routes: uses (evidence: `client/src/App.jsx`)
- App routes → Auth state: provides auth (evidence: `client/src/App.jsx`)
- App routes → Profile onboarding: routes to (evidence: `client/src/App.jsx`)
- App routes → Profile management: routes to (evidence: `client/src/App.jsx`)
- App routes → Patient dashboard: routes to (evidence: `client/src/App.jsx`)
- App routes → Report entry: routes to (evidence: `client/src/App.jsx`)
- App routes → Report analysis view: routes to (evidence: `client/src/App.jsx`)
- App routes → Trend view: routes to (evidence: `client/src/App.jsx`)
- App routes → Doctor dashboard: routes to (evidence: `client/src/App.jsx`)
- App routes → Link requests: routes to (evidence: `client/src/App.jsx`)
- App routes → Patient detail: routes to (evidence: `client/src/App.jsx`)
- Auth hook → Auth state: reads context (evidence: `client/src/hooks/useAuth.js`)
- Auth state → API client: requests (evidence: `client/src/context/AuthContext.jsx`)
- Profile onboarding → API client: requests (evidence: `client/src/pages/OnboardingPage.jsx`)
- Profile management → API client: requests (evidence: `client/src/pages/ProfilePage.jsx`)
- Report entry → API client: requests (evidence: `client/src/pages/AddReportPage.jsx`)
- Report analysis view → API client: requests (evidence: `client/src/pages/ReportDetailPage.jsx`)
- Express API → Auth routes: mounts (evidence: `server/server.js`)
- Express API → Report routes: mounts (evidence: `server/server.js`)
- Express API → Profile routes: mounts (evidence: `server/server.js`)
- Express API → Doctor routes: mounts (evidence: `server/server.js`)
- Express API → Link routes: mounts (evidence: `server/server.js`)
- Auth routes → Authentication: dispatches (evidence: `server/routes/auth.js`)
- Auth routes → JWT and role checks: uses (evidence: `server/routes/auth.js`)
- Link routes → Doctor-patient links: dispatches (evidence: `server/routes/links.js`)
- Link routes → JWT and role checks: uses (evidence: `server/routes/links.js`)
- Report routes → Report operations: dispatches (evidence: `server/routes/reports.js`)
- Report routes → JWT and role checks: uses (evidence: `server/routes/reports.js`)
- Profile routes → Profile operations: dispatches (evidence: `server/routes/profile.js`)
- Profile routes → JWT and role checks: uses (evidence: `server/routes/profile.js`)
- Doctor routes → JWT and role checks: uses (evidence: `server/routes/doctors.js`)
- Authentication → User records: reads/writes (evidence: `server/controllers/authController.js`)
- Authentication → Doctor profile: reads/writes (evidence: `server/controllers/authController.js`)
- Doctor-patient links → User records: reads (evidence: `server/controllers/linkController.js`)
- Doctor-patient links → Doctor profile: reads (evidence: `server/controllers/linkController.js`)
- Doctor-patient links → Patient profile: reads (evidence: `server/controllers/linkController.js`)
- Doctor-patient links → Care links: reads/writes (evidence: `server/controllers/linkController.js`)
- Profile operations → User records: reads/writes (evidence: `server/controllers/profileController.js`)
- Profile operations → Patient profile: reads/writes (evidence: `server/controllers/profileController.js`)
- Profile operations → Doctor profile: reads/writes (evidence: `server/controllers/profileController.js`)
- Report operations → Report records: reads/writes (evidence: `server/controllers/reportController.js`)
- Report operations → Care links: checks links (evidence: `server/controllers/reportController.js`)
- Report operations → Patient profile: reads (evidence: `server/controllers/reportController.js`)
- Report operations → Parameter references: reads (evidence: `server/controllers/reportController.js`)
- Report operations → Parameter status rules: calculates status (evidence: `server/controllers/reportController.js`)
- Report operations → Health analysis: builds analysis (evidence: `server/controllers/reportController.js`)
- Report operations → Report access control: checks access (evidence: `server/controllers/reportController.js`)
- Report access control → Care links: checks links (evidence: `server/utils/accessControl.js`)
