# johannpdaniel/erp architecture

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

- Interactive diagram: https://gitdiagram.com/johannpdaniel/erp
- Repository: https://github.com/johannpdaniel/erp

## Overview

This is a multi-tenant clinic-management SaaS with staff workflows, patient self-service, and platform administration. The principal user journey is staff sign-in, then managing clinical and operational work—patients, appointments, records, and payments—through authenticated screens and API routes backed by a shared database. Patient-facing portal and public signup/survey journeys are distinct branches. The tree shows broad capabilities, but most route-to-service wiring was not sampled; edges below are limited to relationships visible in the source index or excerpts.

Main entry points: [`app/api`](https://github.com/johannpdaniel/erp/tree/main/app/api) (HTTP API), [`app/(authenticated)/quality/page.tsx`](https://github.com/johannpdaniel/erp/blob/main/app/(authenticated)/quality/page.tsx) (Quality and surveys), [`app/login/page.tsx`](https://github.com/johannpdaniel/erp/blob/main/app/login/page.tsx) (Staff sign-in), [`lib/auth.ts`](https://github.com/johannpdaniel/erp/blob/main/lib/auth.ts) (Authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and portals"]
  node_login["Staff sign-in<br/>[page.tsx]"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_portal["Patient portal"]
  node_signup["Organization signup<br/>[page.tsx]"]
  node_survey["Patient surveys<br/>[survey-form.tsx]"]
end

subgraph group_clinic["Clinic operations"]
  node_patients["Patient records<br/>[page.tsx]"]
  node_appointments["Appointments<br/>[route.ts]"]
  node_medical["Medical records<br/>[route.ts]"]
  node_telemedicine["Telemedicine<br/>[route.ts]"]
  node_queue["Waiting queue<br/>[route.ts]"]
  node_inventory["Inventory<br/>[route.ts]"]
  node_quality["Quality and surveys<br/>[page.tsx]"]
end

subgraph group_business["Business operations"]
  node_finance["Financial operations<br/>[page.tsx]"]
  node_payments["Patient payments<br/>[route.ts]"]
  node_marketing["Campaigns<br/>[page.tsx]"]
  node_reports["Reports and analytics<br/>[route.ts]"]
end

subgraph group_platform["Platform services"]
  node_admin["Platform administration<br/>[page.tsx]"]
  node_api["HTTP API"]
  node_database[("Application database<br/>[db.ts]")]
  node_validations["Domain validation<br/>[validations.ts]"]
  node_httpclient["Browser API client<br/>[axios.ts]"]
end

node_staff(("Clinic staff"))

node_staff -->|"signs in"| node_login
node_login -->|"configures auth"| node_auth
node_staff -.->|"uses portal"| node_portal
node_staff -.->|"manages patients"| node_patients
node_staff -.->|"schedules visits"| node_appointments
node_staff -.->|"records care"| node_medical
node_staff -.->|"reviews finances"| node_finance
node_portal -.->|"uses endpoints"| node_api
node_signup -->|"imports client"| node_httpclient
node_quality -->|"imports client"| node_httpclient
node_quality -->|"uses survey form"| node_survey
node_api -.->|"accesses records"| node_database
node_api -.->|"validates input"| node_validations
node_auth -->|"queries users"| node_database

click node_login "https://github.com/johannpdaniel/erp/blob/main/app/login/page.tsx"
click node_auth "https://github.com/johannpdaniel/erp/blob/main/lib/auth.ts"
click node_portal "https://github.com/johannpdaniel/erp/blob/main/components/portal-dashboard.tsx"
click node_signup "https://github.com/johannpdaniel/erp/blob/main/app/signup/page.tsx"
click node_survey "https://github.com/johannpdaniel/erp/blob/main/components/survey-form.tsx"
click node_patients "https://github.com/johannpdaniel/erp/blob/main/app/(authenticated)/patients/page.tsx"
click node_appointments "https://github.com/johannpdaniel/erp/blob/main/app/api/appointments/route.ts"
click node_medical "https://github.com/johannpdaniel/erp/blob/main/app/api/medical-records/route.ts"
click node_telemedicine "https://github.com/johannpdaniel/erp/blob/main/app/api/telemedicine/appointments/route.ts"
click node_queue "https://github.com/johannpdaniel/erp/blob/main/app/api/waiting-queue/route.ts"
click node_inventory "https://github.com/johannpdaniel/erp/blob/main/app/api/inventory/route.ts"
click node_quality "https://github.com/johannpdaniel/erp/blob/main/app/(authenticated)/quality/page.tsx"
click node_finance "https://github.com/johannpdaniel/erp/blob/main/app/(authenticated)/financial/page.tsx"
click node_payments "https://github.com/johannpdaniel/erp/blob/main/app/api/patient-payments/route.ts"
click node_marketing "https://github.com/johannpdaniel/erp/blob/main/app/(authenticated)/marketing/page.tsx"
click node_reports "https://github.com/johannpdaniel/erp/blob/main/app/api/reports/advanced/route.ts"
click node_admin "https://github.com/johannpdaniel/erp/blob/main/app/(authenticated)/admin/page.tsx"
click node_api "https://github.com/johannpdaniel/erp/tree/main/app/api"
click node_database "https://github.com/johannpdaniel/erp/blob/main/lib/db.ts"
click node_validations "https://github.com/johannpdaniel/erp/blob/main/lib/validations.ts"
click node_httpclient "https://github.com/johannpdaniel/erp/blob/main/lib/axios.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_portal,node_signup,node_survey toneBlue
class node_patients,node_appointments,node_medical,node_telemedicine,node_queue,node_inventory,node_quality toneAmber
class node_finance,node_payments,node_marketing,node_reports toneMint
class node_admin,node_api,node_database,node_validations,node_httpclient toneRose
class node_staff toneIndigo
```

## Components

### Access and portals

- [Staff sign-in](https://github.com/johannpdaniel/erp/blob/main/app/login/page.tsx): `app/login/page.tsx`
- [Authentication](https://github.com/johannpdaniel/erp/blob/main/lib/auth.ts): `lib/auth.ts`
- [Patient portal](https://github.com/johannpdaniel/erp/blob/main/components/portal-dashboard.tsx): `components/portal-dashboard.tsx`
- [Organization signup](https://github.com/johannpdaniel/erp/blob/main/app/signup/page.tsx): `app/signup/page.tsx`
- [Patient surveys](https://github.com/johannpdaniel/erp/blob/main/components/survey-form.tsx): `components/survey-form.tsx`

### Clinic operations

- [Patient records](https://github.com/johannpdaniel/erp/blob/main/app/(authenticated)/patients/page.tsx): `app/(authenticated)/patients/page.tsx`
- [Appointments](https://github.com/johannpdaniel/erp/blob/main/app/api/appointments/route.ts): `app/api/appointments/route.ts`
- [Medical records](https://github.com/johannpdaniel/erp/blob/main/app/api/medical-records/route.ts): `app/api/medical-records/route.ts`
- [Telemedicine](https://github.com/johannpdaniel/erp/blob/main/app/api/telemedicine/appointments/route.ts): `app/api/telemedicine/appointments/route.ts`
- [Waiting queue](https://github.com/johannpdaniel/erp/blob/main/app/api/waiting-queue/route.ts): `app/api/waiting-queue/route.ts`
- [Inventory](https://github.com/johannpdaniel/erp/blob/main/app/api/inventory/route.ts): `app/api/inventory/route.ts`
- [Quality and surveys](https://github.com/johannpdaniel/erp/blob/main/app/(authenticated)/quality/page.tsx): `app/(authenticated)/quality/page.tsx`

### Business operations

- [Financial operations](https://github.com/johannpdaniel/erp/blob/main/app/(authenticated)/financial/page.tsx): `app/(authenticated)/financial/page.tsx`
- [Patient payments](https://github.com/johannpdaniel/erp/blob/main/app/api/patient-payments/route.ts): `app/api/patient-payments/route.ts`
- [Campaigns](https://github.com/johannpdaniel/erp/blob/main/app/(authenticated)/marketing/page.tsx): `app/(authenticated)/marketing/page.tsx`
- [Reports and analytics](https://github.com/johannpdaniel/erp/blob/main/app/api/reports/advanced/route.ts): `app/api/reports/advanced/route.ts`

### Platform services

- [Platform administration](https://github.com/johannpdaniel/erp/blob/main/app/(authenticated)/admin/page.tsx): `app/(authenticated)/admin/page.tsx`
- [HTTP API](https://github.com/johannpdaniel/erp/tree/main/app/api): `app/api`
- [Application database](https://github.com/johannpdaniel/erp/blob/main/lib/db.ts): `lib/db.ts`
- [Domain validation](https://github.com/johannpdaniel/erp/blob/main/lib/validations.ts): `lib/validations.ts`
- [Browser API client](https://github.com/johannpdaniel/erp/blob/main/lib/axios.ts): `lib/axios.ts`

### Other components

- **Clinic staff**

## Connections

- Clinic staff → Staff sign-in: signs in
- Staff sign-in → Authentication: configures auth (evidence: `app/login/page.tsx`)
- Clinic staff → Patient portal: uses portal
- Clinic staff → Patient records: manages patients
- Clinic staff → Appointments: schedules visits
- Clinic staff → Medical records: records care
- Clinic staff → Financial operations: reviews finances
- Patient portal → HTTP API: uses endpoints
- Organization signup → Browser API client: imports client (evidence: `app/signup/page.tsx`)
- Quality and surveys → Browser API client: imports client (evidence: `app/(authenticated)/quality/page.tsx`)
- Quality and surveys → Patient surveys: uses survey form (evidence: `app/(authenticated)/quality/page.tsx`)
- HTTP API → Application database: accesses records (evidence: `app/api/payment-gateway-config/route.ts`)
- HTTP API → Domain validation: validates input (evidence: `app/api/subscription/route.ts`)
- Authentication → Application database: queries users (evidence: `lib/auth.ts`)
