# tahacimen13/psikoapp architecture

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

- Interactive diagram: https://gitdiagram.com/tahacimen13/psikoapp
- Repository: https://github.com/tahacimen13/psikoapp

## Overview

This is a local-first clinical practice app for psychologists. A therapist enters the app, reviews a dashboard, and works across patient records, appointments, sessions, and follow-up care; clinical tools add anamnesis, diagnoses, risk tracking, and assessments. The app also provides a professional library and AI-assisted chat/session workflows. SQLite-backed context serves as the shared persistence layer, while authentication and local file storage support privacy and library use. Relationships reflect the sampled source and SOURCE INDEX; unsampled screens are represented only where their paths are in the tree.

Main entry points: [`contexts/database-context.tsx`](https://github.com/tahacimen13/psikoapp/blob/master/contexts/database-context.tsx) (Clinical Data Context), [`app/(tabs)/library.tsx`](https://github.com/tahacimen13/psikoapp/blob/master/app/(tabs)/library.tsx) (Professional Library), [`app/_layout.tsx`](https://github.com/tahacimen13/psikoapp/blob/master/app/_layout.tsx) (App Shell), [`app/(tabs)/index.tsx`](https://github.com/tahacimen13/psikoapp/blob/master/app/(tabs)/index.tsx) (Practice Dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["Practice Workspace"]
  node_dashboard["Practice Dashboard<br/>[index.tsx]"]
  node_patient_list["Patient Directory<br/>[patients.tsx]"]
end

subgraph group_care["Patient Care"]
  node_patient_record["Patient Record<br/>[&#91;id&#93;.tsx]"]
  node_session["Session Notes<br/>[&#91;sessionId&#93;.tsx]"]
  node_session_new["New Session<br/>[new.tsx]"]
  node_treatment["Treatment Plan<br/>[treatment.tsx]"]
  node_homework["Homework<br/>[homework.tsx]"]
  node_progress["Progress Tracking<br/>[progress.tsx]"]
end

subgraph group_clinical["Clinical Tools"]
  node_anamnesis["Anamnesis Forms<br/>[&#91;formId&#93;.tsx]"]
  node_anamnesis_model["Anamnesis Model<br/>[anamnesis.ts]"]
  node_consent["Consent Records<br/>[consent.tsx]"]
  node_diagnoses["Diagnoses<br/>[diagnoses.tsx]"]
  node_dsm["DSM-5 Reference<br/>[dsm5.ts]"]
  node_risk["Risk Tracking<br/>[risk.tsx]"]
  node_risk_badge["Risk Indicator<br/>[RiskBadge.tsx]"]
  node_assessments["Assessments<br/>[assessments.tsx]"]
  node_scales["Scale Library<br/>[scales.ts]"]
  node_scale_pdf["Assessment PDF<br/>[scalePdf.ts]"]
  node_ai_chat["AI Chat<br/>[ai-chat.tsx]"]
  node_ai_service["AI Assistant Service<br/>[claude.ts]"]
end

subgraph group_resources["Schedule And Library"]
  node_schedule["Appointment Schedule<br/>[schedule.tsx]"]
  node_appointment_form["Appointment Form"]
  node_notifications["Appointment Notifications<br/>[notifications.ts]"]
  node_library["Professional Library<br/>[library.tsx]"]
  node_book_detail["Book Reader<br/>[&#91;bookId&#93;.tsx]"]
  node_book_storage["Local Book Files<br/>[storage.ts]"]
end

subgraph group_platform["App Platform"]
  node_app_shell["App Shell<br/>[_layout.tsx]"]
  node_auth["PIN Authentication<br/>[auth-context.tsx]"]
  node_lock_screen["Lock Screen<br/>[LockScreen.tsx]"]
  node_data_context["Clinical Data Context"]
  node_sqlite[("Local SQLite Store<br/>[database.ts]")]
  node_icon["Icon Component<br/>[Icon.tsx]"]
end

node_therapist(("Therapist"))
node_ai_provider{{"AI Provider"}}

node_therapist -->|"opens"| node_dashboard
node_dashboard -->|"navigates"| node_patient_list
node_dashboard -->|"navigates"| node_schedule
node_dashboard -->|"loads data"| node_data_context
node_patient_list -->|"reads patients"| node_data_context
node_patient_record -->|"reads record"| node_data_context
node_session -->|"stores notes"| node_data_context
node_session -->|"requests assistance"| node_ai_service
node_session_new -->|"creates session"| node_data_context
node_treatment -->|"manages plan"| node_data_context
node_homework -->|"manages assignments"| node_data_context
node_progress -->|"reads progress"| node_data_context
node_anamnesis -->|"uses model"| node_anamnesis_model
node_anamnesis -->|"saves responses"| node_data_context
node_data_context -->|"uses form types"| node_anamnesis_model
node_consent -->|"records consent"| node_data_context
node_diagnoses -->|"uses reference"| node_dsm
node_diagnoses -->|"stores diagnoses"| node_data_context
node_risk -->|"manages risk flags"| node_data_context
node_risk -->|"renders status"| node_risk_badge
node_assessments -->|"uses scales"| node_scales
node_assessments -->|"stores results"| node_data_context
node_scale_pdf -->|"formats scales"| node_scales
node_schedule -->|"opens form"| node_appointment_form
node_schedule -->|"manages appointments"| node_data_context
node_schedule -->|"schedules alerts"| node_notifications
node_library -->|"manages catalog"| node_data_context
node_library -->|"stores book files"| node_book_storage
node_library -->|"browses scales"| node_scales
node_library -->|"browses reference"| node_dsm
node_book_detail -->|"reads book data"| node_data_context
node_ai_chat -->|"sends prompts"| node_ai_service
node_ai_chat -->|"loads conversations"| node_data_context
node_ai_service -.->|"calls provider"| node_ai_provider
node_app_shell -->|"provides auth"| node_auth
node_app_shell -->|"provides data"| node_data_context
node_app_shell -->|"shows lock"| node_lock_screen
node_lock_screen -->|"checks PIN"| node_auth
node_lock_screen -->|"can wipe data"| node_sqlite
node_data_context -->|"queries store"| node_sqlite
node_app_shell -->|"initializes store"| node_sqlite

click node_dashboard "https://github.com/tahacimen13/psikoapp/blob/master/app/(tabs)/index.tsx"
click node_patient_list "https://github.com/tahacimen13/psikoapp/blob/master/app/(tabs)/patients.tsx"
click node_patient_record "https://github.com/tahacimen13/psikoapp/blob/master/app/patient/%5Bid%5D.tsx"
click node_session "https://github.com/tahacimen13/psikoapp/blob/master/app/patient/%5Bid%5D/session/%5BsessionId%5D.tsx"
click node_session_new "https://github.com/tahacimen13/psikoapp/blob/master/app/patient/%5Bid%5D/session/new.tsx"
click node_treatment "https://github.com/tahacimen13/psikoapp/blob/master/app/patient/%5Bid%5D/treatment.tsx"
click node_homework "https://github.com/tahacimen13/psikoapp/blob/master/app/patient/%5Bid%5D/homework.tsx"
click node_progress "https://github.com/tahacimen13/psikoapp/blob/master/app/patient/%5Bid%5D/progress.tsx"
click node_anamnesis "https://github.com/tahacimen13/psikoapp/blob/master/app/anamnesis/%5BformId%5D.tsx"
click node_anamnesis_model "https://github.com/tahacimen13/psikoapp/blob/master/lib/anamnesis.ts"
click node_consent "https://github.com/tahacimen13/psikoapp/blob/master/app/patient/%5Bid%5D/consent.tsx"
click node_diagnoses "https://github.com/tahacimen13/psikoapp/blob/master/app/patient/%5Bid%5D/diagnoses.tsx"
click node_dsm "https://github.com/tahacimen13/psikoapp/blob/master/lib/dsm5.ts"
click node_risk "https://github.com/tahacimen13/psikoapp/blob/master/app/patient/%5Bid%5D/risk.tsx"
click node_risk_badge "https://github.com/tahacimen13/psikoapp/blob/master/components/RiskBadge.tsx"
click node_assessments "https://github.com/tahacimen13/psikoapp/blob/master/app/patient/%5Bid%5D/assessments.tsx"
click node_scales "https://github.com/tahacimen13/psikoapp/blob/master/lib/scales.ts"
click node_scale_pdf "https://github.com/tahacimen13/psikoapp/blob/master/lib/scalePdf.ts"
click node_schedule "https://github.com/tahacimen13/psikoapp/blob/master/app/(tabs)/schedule.tsx"
click node_appointment_form "https://github.com/tahacimen13/psikoapp/blob/master/components/AppointmentFormModal.tsx"
click node_notifications "https://github.com/tahacimen13/psikoapp/blob/master/lib/notifications.ts"
click node_library "https://github.com/tahacimen13/psikoapp/blob/master/app/(tabs)/library.tsx"
click node_book_detail "https://github.com/tahacimen13/psikoapp/blob/master/app/library/%5BbookId%5D.tsx"
click node_book_storage "https://github.com/tahacimen13/psikoapp/blob/master/lib/storage.ts"
click node_ai_chat "https://github.com/tahacimen13/psikoapp/blob/master/app/(tabs)/ai-chat.tsx"
click node_ai_service "https://github.com/tahacimen13/psikoapp/blob/master/lib/claude.ts"
click node_app_shell "https://github.com/tahacimen13/psikoapp/blob/master/app/_layout.tsx"
click node_auth "https://github.com/tahacimen13/psikoapp/blob/master/contexts/auth-context.tsx"
click node_lock_screen "https://github.com/tahacimen13/psikoapp/blob/master/components/LockScreen.tsx"
click node_data_context "https://github.com/tahacimen13/psikoapp/blob/master/contexts/database-context.tsx"
click node_sqlite "https://github.com/tahacimen13/psikoapp/blob/master/lib/database.ts"
click node_icon "https://github.com/tahacimen13/psikoapp/blob/master/components/ui/Icon.tsx"

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_dashboard,node_patient_list toneBlue
class node_patient_record,node_session,node_session_new,node_treatment,node_homework,node_progress toneAmber
class node_anamnesis,node_anamnesis_model,node_consent,node_diagnoses,node_dsm,node_risk,node_risk_badge,node_assessments,node_scales,node_scale_pdf,node_ai_chat,node_ai_service,node_therapist toneMint
class node_schedule,node_appointment_form,node_notifications,node_library,node_book_detail,node_book_storage toneRose
class node_app_shell,node_auth,node_lock_screen,node_data_context,node_sqlite,node_icon,node_ai_provider toneIndigo
```

## Components

### Practice Workspace

- [Practice Dashboard](https://github.com/tahacimen13/psikoapp/blob/master/app/(tabs)/index.tsx): `app/(tabs)/index.tsx`
- [Patient Directory](https://github.com/tahacimen13/psikoapp/blob/master/app/(tabs)/patients.tsx): `app/(tabs)/patients.tsx`

### Patient Care

- [Patient Record](https://github.com/tahacimen13/psikoapp/blob/master/app/patient/%5Bid%5D.tsx): `app/patient/[id].tsx`
- [Session Notes](https://github.com/tahacimen13/psikoapp/blob/master/app/patient/%5Bid%5D/session/%5BsessionId%5D.tsx): `app/patient/[id]/session/[sessionId].tsx`
- [New Session](https://github.com/tahacimen13/psikoapp/blob/master/app/patient/%5Bid%5D/session/new.tsx): `app/patient/[id]/session/new.tsx`
- [Treatment Plan](https://github.com/tahacimen13/psikoapp/blob/master/app/patient/%5Bid%5D/treatment.tsx): `app/patient/[id]/treatment.tsx`
- [Homework](https://github.com/tahacimen13/psikoapp/blob/master/app/patient/%5Bid%5D/homework.tsx): `app/patient/[id]/homework.tsx`
- [Progress Tracking](https://github.com/tahacimen13/psikoapp/blob/master/app/patient/%5Bid%5D/progress.tsx): `app/patient/[id]/progress.tsx`

### Clinical Tools

- [Anamnesis Forms](https://github.com/tahacimen13/psikoapp/blob/master/app/anamnesis/%5BformId%5D.tsx): `app/anamnesis/[formId].tsx`
- [Anamnesis Model](https://github.com/tahacimen13/psikoapp/blob/master/lib/anamnesis.ts): `lib/anamnesis.ts`
- [Consent Records](https://github.com/tahacimen13/psikoapp/blob/master/app/patient/%5Bid%5D/consent.tsx): `app/patient/[id]/consent.tsx`
- [Diagnoses](https://github.com/tahacimen13/psikoapp/blob/master/app/patient/%5Bid%5D/diagnoses.tsx): `app/patient/[id]/diagnoses.tsx`
- [DSM-5 Reference](https://github.com/tahacimen13/psikoapp/blob/master/lib/dsm5.ts): `lib/dsm5.ts`
- [Risk Tracking](https://github.com/tahacimen13/psikoapp/blob/master/app/patient/%5Bid%5D/risk.tsx): `app/patient/[id]/risk.tsx`
- [Risk Indicator](https://github.com/tahacimen13/psikoapp/blob/master/components/RiskBadge.tsx): `components/RiskBadge.tsx`
- [Assessments](https://github.com/tahacimen13/psikoapp/blob/master/app/patient/%5Bid%5D/assessments.tsx): `app/patient/[id]/assessments.tsx`
- [Scale Library](https://github.com/tahacimen13/psikoapp/blob/master/lib/scales.ts): `lib/scales.ts`
- [Assessment PDF](https://github.com/tahacimen13/psikoapp/blob/master/lib/scalePdf.ts): `lib/scalePdf.ts`
- [AI Chat](https://github.com/tahacimen13/psikoapp/blob/master/app/(tabs)/ai-chat.tsx): `app/(tabs)/ai-chat.tsx`
- [AI Assistant Service](https://github.com/tahacimen13/psikoapp/blob/master/lib/claude.ts): `lib/claude.ts`

### Schedule And Library

- [Appointment Schedule](https://github.com/tahacimen13/psikoapp/blob/master/app/(tabs)/schedule.tsx): `app/(tabs)/schedule.tsx`
- [Appointment Form](https://github.com/tahacimen13/psikoapp/blob/master/components/AppointmentFormModal.tsx): `components/AppointmentFormModal.tsx`
- [Appointment Notifications](https://github.com/tahacimen13/psikoapp/blob/master/lib/notifications.ts): `lib/notifications.ts`
- [Professional Library](https://github.com/tahacimen13/psikoapp/blob/master/app/(tabs)/library.tsx): `app/(tabs)/library.tsx`
- [Book Reader](https://github.com/tahacimen13/psikoapp/blob/master/app/library/%5BbookId%5D.tsx): `app/library/[bookId].tsx`
- [Local Book Files](https://github.com/tahacimen13/psikoapp/blob/master/lib/storage.ts): `lib/storage.ts`

### App Platform

- [App Shell](https://github.com/tahacimen13/psikoapp/blob/master/app/_layout.tsx): `app/_layout.tsx`
- [PIN Authentication](https://github.com/tahacimen13/psikoapp/blob/master/contexts/auth-context.tsx): `contexts/auth-context.tsx`
- [Lock Screen](https://github.com/tahacimen13/psikoapp/blob/master/components/LockScreen.tsx): `components/LockScreen.tsx`
- [Clinical Data Context](https://github.com/tahacimen13/psikoapp/blob/master/contexts/database-context.tsx): `contexts/database-context.tsx`
- [Local SQLite Store](https://github.com/tahacimen13/psikoapp/blob/master/lib/database.ts): `lib/database.ts`
- [Icon Component](https://github.com/tahacimen13/psikoapp/blob/master/components/ui/Icon.tsx): `components/ui/Icon.tsx`

### Other components

- **Therapist**
- **AI Provider**

## Connections

- Therapist → Practice Dashboard: opens
- Practice Dashboard → Patient Directory: navigates (evidence: `app/(tabs)/index.tsx`)
- Practice Dashboard → Appointment Schedule: navigates (evidence: `app/(tabs)/index.tsx`)
- Practice Dashboard → Clinical Data Context: loads data (evidence: `app/(tabs)/index.tsx`)
- Patient Directory → Clinical Data Context: reads patients (evidence: `app/(tabs)/patients.tsx`)
- Patient Record → Clinical Data Context: reads record (evidence: `app/patient/[id].tsx`)
- Session Notes → Clinical Data Context: stores notes (evidence: `app/patient/[id]/session/[sessionId].tsx`)
- Session Notes → AI Assistant Service: requests assistance (evidence: `app/patient/[id]/session/[sessionId].tsx`)
- New Session → Clinical Data Context: creates session (evidence: `app/patient/[id]/session/new.tsx`)
- Treatment Plan → Clinical Data Context: manages plan (evidence: `contexts/database-context.tsx`)
- Homework → Clinical Data Context: manages assignments (evidence: `contexts/database-context.tsx`)
- Progress Tracking → Clinical Data Context: reads progress (evidence: `contexts/database-context.tsx`)
- Anamnesis Forms → Anamnesis Model: uses model (evidence: `app/anamnesis/[formId].tsx`)
- Anamnesis Forms → Clinical Data Context: saves responses (evidence: `app/anamnesis/[formId].tsx`)
- Clinical Data Context → Anamnesis Model: uses form types (evidence: `contexts/database-context.tsx`)
- Consent Records → Clinical Data Context: records consent (evidence: `contexts/database-context.tsx`)
- Diagnoses → DSM-5 Reference: uses reference (evidence: `app/patient/[id]/diagnoses.tsx`)
- Diagnoses → Clinical Data Context: stores diagnoses (evidence: `app/patient/[id]/diagnoses.tsx`)
- Risk Tracking → Clinical Data Context: manages risk flags (evidence: `app/patient/[id]/risk.tsx`)
- Risk Tracking → Risk Indicator: renders status (evidence: `app/patient/[id]/risk.tsx`)
- Assessments → Scale Library: uses scales (evidence: `app/patient/[id]/assessments.tsx`)
- Assessments → Clinical Data Context: stores results (evidence: `app/patient/[id]/assessments.tsx`)
- Assessment PDF → Scale Library: formats scales (evidence: `lib/scalePdf.ts`)
- Appointment Schedule → Appointment Form: opens form (evidence: `app/(tabs)/schedule.tsx`)
- Appointment Schedule → Clinical Data Context: manages appointments (evidence: `app/(tabs)/schedule.tsx`)
- Appointment Schedule → Appointment Notifications: schedules alerts (evidence: `app/(tabs)/schedule.tsx`)
- Professional Library → Clinical Data Context: manages catalog (evidence: `app/(tabs)/library.tsx`)
- Professional Library → Local Book Files: stores book files (evidence: `app/(tabs)/library.tsx`)
- Professional Library → Scale Library: browses scales (evidence: `app/(tabs)/library.tsx`)
- Professional Library → DSM-5 Reference: browses reference (evidence: `app/(tabs)/library.tsx`)
- Book Reader → Clinical Data Context: reads book data (evidence: `app/library/[bookId].tsx`)
- AI Chat → AI Assistant Service: sends prompts (evidence: `app/(tabs)/ai-chat.tsx`)
- AI Chat → Clinical Data Context: loads conversations (evidence: `app/(tabs)/ai-chat.tsx`)
- AI Assistant Service → AI Provider: calls provider
- App Shell → PIN Authentication: provides auth (evidence: `app/_layout.tsx`)
- App Shell → Clinical Data Context: provides data (evidence: `app/_layout.tsx`)
- App Shell → Lock Screen: shows lock (evidence: `app/_layout.tsx`)
- Lock Screen → PIN Authentication: checks PIN (evidence: `components/LockScreen.tsx`)
- Lock Screen → Local SQLite Store: can wipe data (evidence: `components/LockScreen.tsx`)
- Clinical Data Context → Local SQLite Store: queries store (evidence: `contexts/database-context.tsx`)
- App Shell → Local SQLite Store: initializes store (evidence: `app/_layout.tsx`)
