# tis-emman/cognilab-lis architecture

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

- Interactive diagram: https://gitdiagram.com/tis-emman/cognilab-lis
- Repository: https://github.com/tis-emman/cognilab-lis

## Overview

CogniLab is a laboratory information system for managing users, patients, test requests, specimens, results, quality checks, reports, and billing. Lab staff use dashboard pages to perform these tasks; the pages call shared data-access code, which uses Supabase or demo data. Administration includes user management and audit history. The README is only a generic Next.js starter description, so domain capabilities and links here are based on the source index and sampled excerpts; links between lab stages are not assumed where calls were not shown.

Main entry points: [`lib/database.ts`](https://github.com/tis-emman/cognilab-lis/blob/main/lib/database.ts) (Data access), [`lib/authContext.tsx`](https://github.com/tis-emman/cognilab-lis/blob/main/lib/authContext.tsx) (Authentication), [`lib/supabaseClient.ts`](https://github.com/tis-emman/cognilab-lis/blob/main/lib/supabaseClient.ts) (Supabase client), [`app/login/page.tsx`](https://github.com/tis-emman/cognilab-lis/blob/main/app/login/page.tsx) (Sign in)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and navigation"]
  node_login["Sign in<br/>[page.tsx]"]
  node_auth["Authentication<br/>[authContext.tsx]"]
  node_navigation["Dashboard navigation<br/>[Sidebar.tsx]"]
end

subgraph group_lab["Laboratory workflow"]
  node_dashboard["Dashboard overview<br/>[page.tsx]"]
  node_patients["Patient records<br/>[page.tsx]"]
  node_requests["Test requests<br/>[page.tsx]"]
  node_specimens["Specimen tracking<br/>[page.tsx]"]
  node_results["Test results<br/>[page.tsx]"]
  node_quality["Quality checks<br/>[page.tsx]"]
  node_reports["Lab reports<br/>[page.tsx]"]
  node_billing["Billing<br/>[page.tsx]"]
end

subgraph group_admin["Administration"]
  node_history["Access history<br/>[page.tsx]"]
  node_profile["User profile<br/>[page.tsx]"]
  node_users["User administration<br/>[page.tsx]"]
  node_audit["Audit log<br/>[page.tsx]"]
end

subgraph group_data["Data services"]
  node_dataapi["Data access<br/>[database.ts]"]
  node_mock["Demo data<br/>[mockData.ts]"]
  node_client["Supabase client<br/>[supabaseClient.ts]"]
end

node_staff(("Lab staff"))
node_supabase[("Supabase")]

node_staff -->|"signs in"| node_login
node_login -->|"authenticates through"| node_auth
node_auth -->|"uses"| node_client
node_auth -->|"uses demo users"| node_mock
node_auth -->|"authenticates with"| node_supabase
node_navigation -->|"reads session"| node_auth
node_dashboard -->|"loads data"| node_dataapi
node_patients -->|"reads and updates"| node_dataapi
node_requests -->|"uses"| node_dataapi
node_specimens -->|"loads and records"| node_dataapi
node_results -->|"loads and updates"| node_dataapi
node_quality -->|"reads and logs"| node_dataapi
node_reports -->|"uses"| node_dataapi
node_billing -->|"uses"| node_dataapi
node_history -->|"uses"| node_dataapi
node_profile -->|"reads session"| node_auth
node_users -->|"manages users through"| node_dataapi
node_audit -->|"reads logs through"| node_dataapi
node_dataapi -->|"queries"| node_client
node_dataapi -->|"uses demo records"| node_mock
node_client -->|"connects to"| node_supabase

click node_login "https://github.com/tis-emman/cognilab-lis/blob/main/app/login/page.tsx"
click node_auth "https://github.com/tis-emman/cognilab-lis/blob/main/lib/authContext.tsx"
click node_navigation "https://github.com/tis-emman/cognilab-lis/blob/main/components/Sidebar.tsx"
click node_dashboard "https://github.com/tis-emman/cognilab-lis/blob/main/app/dashboard/page.tsx"
click node_patients "https://github.com/tis-emman/cognilab-lis/blob/main/app/dashboard/patients/page.tsx"
click node_requests "https://github.com/tis-emman/cognilab-lis/blob/main/app/dashboard/test-request/page.tsx"
click node_specimens "https://github.com/tis-emman/cognilab-lis/blob/main/app/dashboard/specimen-tracking/page.tsx"
click node_results "https://github.com/tis-emman/cognilab-lis/blob/main/app/dashboard/results/page.tsx"
click node_quality "https://github.com/tis-emman/cognilab-lis/blob/main/app/dashboard/quality-checking/page.tsx"
click node_reports "https://github.com/tis-emman/cognilab-lis/blob/main/app/dashboard/report/page.tsx"
click node_billing "https://github.com/tis-emman/cognilab-lis/blob/main/app/dashboard/billing/page.tsx"
click node_history "https://github.com/tis-emman/cognilab-lis/blob/main/app/dashboard/history/page.tsx"
click node_profile "https://github.com/tis-emman/cognilab-lis/blob/main/app/dashboard/profile/page.tsx"
click node_users "https://github.com/tis-emman/cognilab-lis/blob/main/app/admin/users/page.tsx"
click node_audit "https://github.com/tis-emman/cognilab-lis/blob/main/app/admin/audit-log/page.tsx"
click node_dataapi "https://github.com/tis-emman/cognilab-lis/blob/main/lib/database.ts"
click node_mock "https://github.com/tis-emman/cognilab-lis/blob/main/lib/mockData.ts"
click node_client "https://github.com/tis-emman/cognilab-lis/blob/main/lib/supabaseClient.ts"

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_login,node_auth,node_navigation toneBlue
class node_dashboard,node_patients,node_requests,node_specimens,node_results,node_quality,node_reports,node_billing,node_supabase toneAmber
class node_history,node_profile,node_users,node_audit toneMint
class node_dataapi,node_mock,node_client toneRose
class node_staff toneIndigo
```

## Components

### Access and navigation

- [Sign in](https://github.com/tis-emman/cognilab-lis/blob/main/app/login/page.tsx): `app/login/page.tsx`
- [Authentication](https://github.com/tis-emman/cognilab-lis/blob/main/lib/authContext.tsx): `lib/authContext.tsx`
- [Dashboard navigation](https://github.com/tis-emman/cognilab-lis/blob/main/components/Sidebar.tsx): `components/Sidebar.tsx`

### Laboratory workflow

- [Dashboard overview](https://github.com/tis-emman/cognilab-lis/blob/main/app/dashboard/page.tsx): `app/dashboard/page.tsx`
- [Patient records](https://github.com/tis-emman/cognilab-lis/blob/main/app/dashboard/patients/page.tsx): `app/dashboard/patients/page.tsx`
- [Test requests](https://github.com/tis-emman/cognilab-lis/blob/main/app/dashboard/test-request/page.tsx): `app/dashboard/test-request/page.tsx`
- [Specimen tracking](https://github.com/tis-emman/cognilab-lis/blob/main/app/dashboard/specimen-tracking/page.tsx): `app/dashboard/specimen-tracking/page.tsx`
- [Test results](https://github.com/tis-emman/cognilab-lis/blob/main/app/dashboard/results/page.tsx): `app/dashboard/results/page.tsx`
- [Quality checks](https://github.com/tis-emman/cognilab-lis/blob/main/app/dashboard/quality-checking/page.tsx): `app/dashboard/quality-checking/page.tsx`
- [Lab reports](https://github.com/tis-emman/cognilab-lis/blob/main/app/dashboard/report/page.tsx): `app/dashboard/report/page.tsx`
- [Billing](https://github.com/tis-emman/cognilab-lis/blob/main/app/dashboard/billing/page.tsx): `app/dashboard/billing/page.tsx`

### Administration

- [Access history](https://github.com/tis-emman/cognilab-lis/blob/main/app/dashboard/history/page.tsx): `app/dashboard/history/page.tsx`
- [User profile](https://github.com/tis-emman/cognilab-lis/blob/main/app/dashboard/profile/page.tsx): `app/dashboard/profile/page.tsx`
- [User administration](https://github.com/tis-emman/cognilab-lis/blob/main/app/admin/users/page.tsx): `app/admin/users/page.tsx`
- [Audit log](https://github.com/tis-emman/cognilab-lis/blob/main/app/admin/audit-log/page.tsx): `app/admin/audit-log/page.tsx`

### Data services

- [Data access](https://github.com/tis-emman/cognilab-lis/blob/main/lib/database.ts): `lib/database.ts`
- [Demo data](https://github.com/tis-emman/cognilab-lis/blob/main/lib/mockData.ts): `lib/mockData.ts`
- [Supabase client](https://github.com/tis-emman/cognilab-lis/blob/main/lib/supabaseClient.ts): `lib/supabaseClient.ts`

### Other components

- **Lab staff**
- **Supabase**

## Connections

- Lab staff → Sign in: signs in (evidence: `app/login/page.tsx`)
- Sign in → Authentication: authenticates through (evidence: `app/login/page.tsx`)
- Authentication → Supabase client: uses (evidence: `lib/authContext.tsx`)
- Authentication → Demo data: uses demo users (evidence: `lib/authContext.tsx`)
- Authentication → Supabase: authenticates with (evidence: `lib/authContext.tsx`)
- Dashboard navigation → Authentication: reads session (evidence: `components/Sidebar.tsx`)
- Dashboard overview → Data access: loads data (evidence: `app/dashboard/page.tsx`)
- Patient records → Data access: reads and updates (evidence: `app/dashboard/patients/page.tsx`)
- Test requests → Data access: uses (evidence: `app/dashboard/test-request/page.tsx`)
- Specimen tracking → Data access: loads and records (evidence: `app/dashboard/specimen-tracking/page.tsx`)
- Test results → Data access: loads and updates (evidence: `app/dashboard/results/page.tsx`)
- Quality checks → Data access: reads and logs (evidence: `app/dashboard/quality-checking/page.tsx`)
- Lab reports → Data access: uses (evidence: `app/dashboard/report/page.tsx`)
- Billing → Data access: uses (evidence: `app/dashboard/billing/page.tsx`)
- Access history → Data access: uses (evidence: `app/dashboard/history/page.tsx`)
- User profile → Authentication: reads session (evidence: `app/dashboard/profile/page.tsx`)
- User administration → Data access: manages users through (evidence: `app/admin/users/page.tsx`)
- Audit log → Data access: reads logs through (evidence: `app/admin/audit-log/page.tsx`)
- Data access → Supabase client: queries (evidence: `lib/database.ts`)
- Data access → Demo data: uses demo records (evidence: `lib/database.ts`)
- Supabase client → Supabase: connects to (evidence: `lib/supabaseClient.ts`)
