# nalintiwari36-coder/lifehealth-id-development architecture

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

- Interactive diagram: https://gitdiagram.com/nalintiwari36-coder/lifehealth-id-development
- Repository: https://github.com/nalintiwari36-coder/lifehealth-id-development

## Overview

LifeHealth ID is a privacy-focused health-record organizing experience. The visible workflow is sign-in, access-checked dashboard entry, and protected record upload or download; record files use private blob storage while metadata and audit events use PostgreSQL. The schema also models organizations, patient memberships, consent grants, notifications, and rate limits, though their runtime flows are not shown. The README is brief, so sharing is described as a product goal rather than a verified implemented workflow. Unexcerpted UI and API capabilities are included where the source index identifies them; uncertain links are omitted.

Main entry points: [`lib/db/index.ts`](https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/lib/db/index.ts) (Database client), [`lib/authz.ts`](https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/lib/authz.ts) (Access checks), [`lib/auth.ts`](https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/lib/auth.ts) (Auth service setup), [`app/dashboard/page.tsx`](https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/app/dashboard/page.tsx) (Dashboard route)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_localized["Localized pages"]
  node_landing["Landing page<br/>[landing-page.tsx]"]
  node_signin["Sign-in page<br/>[page.tsx]"]
  node_authform["Authentication form<br/>[auth-form.tsx]"]
  node_dashboardroute["Dashboard route<br/>[page.tsx]"]
  node_healthdashboard["Health dashboard"]
  node_accountmenu["Account menu<br/>[account-menu.tsx]"]
  node_signout["Sign-out control"]
  node_privacy["Privacy information<br/>[page.tsx]"]
  node_i18n["Localization<br/>[i18n.ts]"]
end

subgraph group_identity["Identity and access"]
  node_authclient["Auth client<br/>[auth-client.ts]"]
  node_authformapi["Auth API route<br/>[route.ts]"]
  node_auth["Auth service setup<br/>[auth.ts]"]
  node_authz["Access checks<br/>[authz.ts]"]
  node_otpsend["OTP send endpoint<br/>[route.ts]"]
  node_otpverify["OTP verify endpoint<br/>[route.ts]"]
end

subgraph group_records["Health records"]
  node_recordsupload["Record upload endpoint<br/>[route.ts]"]
  node_recordfile["Record download endpoint<br/>[route.ts]"]
  node_blob[("Private blob storage")]
end

subgraph group_platform["Data and messaging"]
  node_messages["Message send endpoint<br/>[route.ts]"]
  node_postgres[("PostgreSQL database")]
  node_dbclient["Database client<br/>[index.ts]"]
  node_schema["Data schema<br/>[schema.ts]"]
  node_env["Environment config<br/>[env.ts]"]
  node_email["Email delivery"]
end

node_person(("Person"))

node_person -->|"opens"| node_localized
node_localized -->|"renders"| node_landing
node_localized -->|"loads locale"| node_i18n
node_person -->|"signs in"| node_signin
node_signin -->|"renders"| node_authform
node_authform -->|"uses"| node_authclient
node_accountmenu -->|"uses"| node_authclient
node_signout -->|"uses"| node_authclient
node_person -->|"opens"| node_dashboardroute
node_dashboardroute -->|"requires session"| node_authz
node_dashboardroute -->|"renders"| node_healthdashboard
node_dashboardroute -->|"renders"| node_signout
node_landing -->|"renders"| node_accountmenu
node_person -->|"reads"| node_privacy
node_authclient -.->|"sends auth requests"| node_authformapi
node_authformapi -->|"delegates"| node_auth
node_auth -->|"uses pool"| node_dbclient
node_auth -->|"reads settings"| node_env
node_authz -->|"checks session"| node_auth
node_authz -->|"queries access"| node_dbclient
node_otpsend -->|"stores code"| node_dbclient
node_otpsend -->|"sends code"| node_email
node_otpverify -->|"checks code"| node_dbclient
node_recordsupload -->|"requires session"| node_authz
node_recordsupload -->|"writes metadata and audit"| node_dbclient
node_recordsupload -->|"stores file"| node_blob
node_recordfile -->|"requires session"| node_authz
node_recordfile -->|"reads record and audits"| node_dbclient
node_recordfile -->|"fetches file"| node_blob
node_messages -->|"uses access checks"| node_authz
node_messages -->|"reads settings"| node_env
node_dbclient -->|"registers schema"| node_schema
node_dbclient -->|"connects"| node_postgres
node_auth -->|"configures auth database"| node_postgres

click node_localized "https://github.com/nalintiwari36-coder/lifehealth-id-development/tree/main/app/%5Blocale%5D"
click node_landing "https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/components/landing-page.tsx"
click node_signin "https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/app/sign-in/page.tsx"
click node_authform "https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/components/auth-form.tsx"
click node_dashboardroute "https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/app/dashboard/page.tsx"
click node_healthdashboard "https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/components/health-dashboard.tsx"
click node_accountmenu "https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/components/account-menu.tsx"
click node_signout "https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/components/sign-out-button.tsx"
click node_privacy "https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/app/privacy/page.tsx"
click node_i18n "https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/lib/i18n.ts"
click node_authclient "https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/lib/auth-client.ts"
click node_authformapi "https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/app/api/auth/%5B...all%5D/route.ts"
click node_auth "https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/lib/auth.ts"
click node_authz "https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/lib/authz.ts"
click node_otpsend "https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/app/api/otp/send/route.ts"
click node_otpverify "https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/app/api/otp/verify/route.ts"
click node_recordsupload "https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/app/api/records/upload/route.ts"
click node_recordfile "https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/app/api/records/%5Bid%5D/file/route.ts"
click node_messages "https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/app/api/messages/send/route.ts"
click node_dbclient "https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/lib/db/index.ts"
click node_schema "https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/lib/db/schema.ts"
click node_env "https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/lib/env.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_localized,node_landing,node_signin,node_authform,node_dashboardroute,node_healthdashboard,node_accountmenu,node_signout,node_privacy,node_i18n toneBlue
class node_authclient,node_authformapi,node_auth,node_authz,node_otpsend,node_otpverify toneAmber
class node_recordsupload,node_recordfile,node_blob toneMint
class node_messages,node_postgres,node_dbclient,node_schema,node_env,node_email toneRose
class node_person toneIndigo
```

## Components

### User experience

- [Localized pages](https://github.com/nalintiwari36-coder/lifehealth-id-development/tree/main/app/%5Blocale%5D): `app/[locale]`
- [Landing page](https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/components/landing-page.tsx): `components/landing-page.tsx`
- [Sign-in page](https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/app/sign-in/page.tsx): `app/sign-in/page.tsx`
- [Authentication form](https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/components/auth-form.tsx): `components/auth-form.tsx`
- [Dashboard route](https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/app/dashboard/page.tsx): `app/dashboard/page.tsx`
- [Health dashboard](https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/components/health-dashboard.tsx): `components/health-dashboard.tsx`
- [Account menu](https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/components/account-menu.tsx): `components/account-menu.tsx`
- [Sign-out control](https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/components/sign-out-button.tsx): `components/sign-out-button.tsx`
- [Privacy information](https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/app/privacy/page.tsx): `app/privacy/page.tsx`
- [Localization](https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/lib/i18n.ts): `lib/i18n.ts`

### Identity and access

- [Auth client](https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/lib/auth-client.ts): `lib/auth-client.ts`
- [Auth API route](https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/app/api/auth/%5B...all%5D/route.ts): `app/api/auth/[...all]/route.ts`
- [Auth service setup](https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/lib/auth.ts): `lib/auth.ts`
- [Access checks](https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/lib/authz.ts): `lib/authz.ts`
- [OTP send endpoint](https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/app/api/otp/send/route.ts): `app/api/otp/send/route.ts`
- [OTP verify endpoint](https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/app/api/otp/verify/route.ts): `app/api/otp/verify/route.ts`

### Health records

- [Record upload endpoint](https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/app/api/records/upload/route.ts): `app/api/records/upload/route.ts`
- [Record download endpoint](https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/app/api/records/%5Bid%5D/file/route.ts): `app/api/records/[id]/file/route.ts`
- **Private blob storage**

### Data and messaging

- [Message send endpoint](https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/app/api/messages/send/route.ts): `app/api/messages/send/route.ts`
- **PostgreSQL database**
- [Database client](https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/lib/db/index.ts): `lib/db/index.ts`
- [Data schema](https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/lib/db/schema.ts): `lib/db/schema.ts`
- [Environment config](https://github.com/nalintiwari36-coder/lifehealth-id-development/blob/main/lib/env.ts): `lib/env.ts`
- **Email delivery**

### Other components

- **Person**

## Connections

- Person → Localized pages: opens (evidence: `app/[locale]/page.tsx`)
- Localized pages → Landing page: renders (evidence: `app/[locale]/page.tsx`)
- Localized pages → Localization: loads locale (evidence: `app/[locale]/layout.tsx`)
- Person → Sign-in page: signs in (evidence: `app/sign-in/page.tsx`)
- Sign-in page → Authentication form: renders (evidence: `app/sign-in/page.tsx`)
- Authentication form → Auth client: uses (evidence: `components/auth-form.tsx`)
- Account menu → Auth client: uses (evidence: `components/account-menu.tsx`)
- Sign-out control → Auth client: uses (evidence: `components/sign-out-button.tsx`)
- Person → Dashboard route: opens (evidence: `app/dashboard/page.tsx`)
- Dashboard route → Access checks: requires session (evidence: `app/dashboard/page.tsx`)
- Dashboard route → Health dashboard: renders (evidence: `app/dashboard/page.tsx`)
- Dashboard route → Sign-out control: renders (evidence: `app/dashboard/page.tsx`)
- Landing page → Account menu: renders (evidence: `components/landing-page.tsx`)
- Person → Privacy information: reads (evidence: `app/privacy/page.tsx`)
- Auth client → Auth API route: sends auth requests
- Auth API route → Auth service setup: delegates (evidence: `app/api/auth/[...all]/route.ts`)
- Auth service setup → Database client: uses pool (evidence: `lib/auth.ts`)
- Auth service setup → Environment config: reads settings (evidence: `lib/auth.ts`)
- Access checks → Auth service setup: checks session (evidence: `lib/authz.ts`)
- Access checks → Database client: queries access (evidence: `lib/authz.ts`)
- OTP send endpoint → Database client: stores code (evidence: `app/api/otp/send/route.ts`)
- OTP send endpoint → Email delivery: sends code (evidence: `app/api/otp/send/route.ts`)
- OTP verify endpoint → Database client: checks code (evidence: `app/api/otp/verify/route.ts`)
- Record upload endpoint → Access checks: requires session (evidence: `app/api/records/upload/route.ts`)
- Record upload endpoint → Database client: writes metadata and audit (evidence: `app/api/records/upload/route.ts`)
- Record upload endpoint → Private blob storage: stores file (evidence: `app/api/records/upload/route.ts`)
- Record download endpoint → Access checks: requires session (evidence: `app/api/records/[id]/file/route.ts`)
- Record download endpoint → Database client: reads record and audits (evidence: `app/api/records/[id]/file/route.ts`)
- Record download endpoint → Private blob storage: fetches file (evidence: `app/api/records/[id]/file/route.ts`)
- Message send endpoint → Access checks: uses access checks (evidence: `app/api/messages/send/route.ts`)
- Message send endpoint → Environment config: reads settings (evidence: `app/api/messages/send/route.ts`)
- Database client → Data schema: registers schema (evidence: `lib/db/index.ts`)
- Database client → PostgreSQL database: connects (evidence: `lib/db/index.ts`)
- Auth service setup → PostgreSQL database: configures auth database (evidence: `lib/auth.ts`)
