# ffreua/neurodoc architecture

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

- Interactive diagram: https://gitdiagram.com/ffreua/neurodoc
- Repository: https://github.com/ffreua/neurodoc
- Video tour (about a minute): https://gitdiagram.com/ffreua/neurodoc/video

## Overview

NeuroDoc is a multi-tenant medical-practice platform. A clinician or staff member uses it to manage patients, appointments and clinical encounters, then issues documents and handles billing; patients can also use a public portal to submit requests and exam reports. Major parallel capabilities include exam scheduling, TISS claims, controlled prescriptions through SNCR, AI-assisted work with mandatory physician review, and team messaging. The graph combines README-documented workflows with source-indexed modules; unsampled implementation details are represented at their supported paths, and edges are limited to documented or indexed relationships.

Main entry points: [`documents`](https://github.com/ffreua/neurodoc/tree/main/documents) (Medical documents), [`tenancy/models.py`](https://github.com/ffreua/neurodoc/blob/main/tenancy/models.py) (Tenant and accounts), [`patients/models.py`](https://github.com/ffreua/neurodoc/blob/main/patients/models.py) (Patient records), [`scheduling/models.py`](https://github.com/ffreua/neurodoc/blob/main/scheduling/models.py) (Appointments)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_practice["Practice operations"]
  node_exams["Exam scheduling"]
  node_appointments[("Appointments<br/>[models.py]")]
  node_practice_catalogs[("Medical catalogs<br/>[models.py]")]
end

subgraph group_clinical["Clinical records"]
  node_patient_records[("Patient records<br/>[models.py]")]
  node_encounters["Clinical encounters"]
end

subgraph group_documents["Documents and billing"]
  node_medical_documents["Medical documents"]
  node_document_storage[("Attachment storage<br/>[storage.py]")]
  node_sncr["SNCR prescriptions"]
  node_tiss["TISS billing"]
  node_finance["Practice finance"]
end

subgraph group_platform["Tenant platform"]
  node_tenant_accounts[("Tenant and accounts<br/>[models.py]")]
  node_access_control["Roles and permissions<br/>[permissions.py]"]
  node_plans["Plans and limits<br/>[plans.py]"]
  node_audit[("Audit trail<br/>[services.py]")]
  node_event_outbox["Event dispatcher<br/>[dispatcher.py]"]
  node_reporting["Reports and exports"]
  node_logging["Sensitive-data logging<br/>[logging.py]"]
end

subgraph group_collaboration["Communications and AI"]
  node_communications[("Patient communications<br/>[models.py]")]
  node_notifications["Notifications"]
  node_ai_assistant["AI assistant"]
  node_team_chat["Team chat<br/>[services.py]"]
end

node_clinician(("Clinician and staff"))
node_patient(("Patient"))
node_external_services{{"External services"}}

node_clinician -->|"signs in"| node_tenant_accounts
node_tenant_accounts -->|"scopes access"| node_access_control
node_patient -->|"registers with clinic"| node_patient_records
node_clinician -->|"manages schedule"| node_appointments
node_appointments -.->|"associates patient"| node_patient_records
node_clinician -->|"records care"| node_encounters
node_encounters -.->|"records in"| node_patient_records
node_clinician -->|"schedules exams"| node_exams
node_clinician -->|"uses catalogs"| node_practice_catalogs
node_clinician -->|"issues documents"| node_medical_documents
node_medical_documents -.->|"stores attachments"| node_document_storage
node_medical_documents -.->|"signs PAdES"| node_external_services
node_medical_documents -->|"issues controlled prescriptions"| node_sncr
node_sncr -->|"checks prescriptions"| node_external_services
node_clinician -->|"submits claims"| node_tiss
node_tiss -->|"validates ANS format"| node_external_services
node_clinician -->|"manages payments"| node_finance
node_appointments -->|"publishes schedule events"| node_event_outbox
node_event_outbox -->|"dispatches appointment events"| node_communications
node_communications -->|"sends email and SMS"| node_external_services
node_patient -->|"requests through portal"| node_medical_documents
node_patient -.->|"uploads exam reports"| node_document_storage
node_clinician -->|"requests assistance"| node_ai_assistant
node_ai_assistant -->|"calls configured provider"| node_external_services
node_ai_assistant -->|"returns for review"| node_clinician
node_clinician -->|"messages colleagues"| node_team_chat
node_clinician -->|"exports practice data"| node_reporting
node_tenant_accounts -->|"selects plan"| node_plans
node_plans -->|"limits capabilities"| node_access_control
node_tenant_accounts -->|"records acceptance"| node_audit
node_clinician -.->|"creates audit events"| node_audit
node_patient_records -.->|"protects diagnostic output"| node_logging

click node_patient_records "https://github.com/ffreua/neurodoc/blob/main/patients/models.py"
click node_encounters "https://github.com/ffreua/neurodoc/tree/main/clinical"
click node_exams "https://github.com/ffreua/neurodoc/tree/main/agenda_exames"
click node_appointments "https://github.com/ffreua/neurodoc/blob/main/scheduling/models.py"
click node_practice_catalogs "https://github.com/ffreua/neurodoc/blob/main/catalogs/models.py"
click node_medical_documents "https://github.com/ffreua/neurodoc/tree/main/documents"
click node_document_storage "https://github.com/ffreua/neurodoc/blob/main/documents/storage.py"
click node_sncr "https://github.com/ffreua/neurodoc/tree/main/sncr"
click node_tiss "https://github.com/ffreua/neurodoc/tree/main/tiss"
click node_finance "https://github.com/ffreua/neurodoc/tree/main/finance"
click node_tenant_accounts "https://github.com/ffreua/neurodoc/blob/main/tenancy/models.py"
click node_access_control "https://github.com/ffreua/neurodoc/blob/main/tenancy/permissions.py"
click node_plans "https://github.com/ffreua/neurodoc/blob/main/tenancy/plans.py"
click node_audit "https://github.com/ffreua/neurodoc/blob/main/audit/services.py"
click node_event_outbox "https://github.com/ffreua/neurodoc/blob/main/events/dispatcher.py"
click node_communications "https://github.com/ffreua/neurodoc/blob/main/communications/models.py"
click node_notifications "https://github.com/ffreua/neurodoc/tree/main/notifications"
click node_ai_assistant "https://github.com/ffreua/neurodoc/tree/main/ai"
click node_team_chat "https://github.com/ffreua/neurodoc/blob/main/teamchat/services.py"
click node_reporting "https://github.com/ffreua/neurodoc/tree/main/reporting"
click node_logging "https://github.com/ffreua/neurodoc/blob/main/base/logging.py"

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_exams,node_appointments,node_practice_catalogs toneBlue
class node_patient_records,node_encounters toneAmber
class node_medical_documents,node_document_storage,node_sncr,node_tiss,node_finance toneMint
class node_tenant_accounts,node_access_control,node_plans,node_audit,node_event_outbox,node_reporting,node_logging toneRose
class node_communications,node_notifications,node_ai_assistant,node_team_chat,node_clinician,node_patient,node_external_services toneIndigo
```

## Components

### Practice operations

- [Exam scheduling](https://github.com/ffreua/neurodoc/tree/main/agenda_exames): `agenda_exames`
- [Appointments](https://github.com/ffreua/neurodoc/blob/main/scheduling/models.py): `scheduling/models.py`
- [Medical catalogs](https://github.com/ffreua/neurodoc/blob/main/catalogs/models.py): `catalogs/models.py`

### Clinical records

- [Patient records](https://github.com/ffreua/neurodoc/blob/main/patients/models.py): `patients/models.py`
- [Clinical encounters](https://github.com/ffreua/neurodoc/tree/main/clinical): `clinical`

### Documents and billing

- [Medical documents](https://github.com/ffreua/neurodoc/tree/main/documents): `documents`
- [Attachment storage](https://github.com/ffreua/neurodoc/blob/main/documents/storage.py): `documents/storage.py`
- [SNCR prescriptions](https://github.com/ffreua/neurodoc/tree/main/sncr): `sncr`
- [TISS billing](https://github.com/ffreua/neurodoc/tree/main/tiss): `tiss`
- [Practice finance](https://github.com/ffreua/neurodoc/tree/main/finance): `finance`

### Tenant platform

- [Tenant and accounts](https://github.com/ffreua/neurodoc/blob/main/tenancy/models.py): `tenancy/models.py`
- [Roles and permissions](https://github.com/ffreua/neurodoc/blob/main/tenancy/permissions.py): `tenancy/permissions.py`
- [Plans and limits](https://github.com/ffreua/neurodoc/blob/main/tenancy/plans.py): `tenancy/plans.py`
- [Audit trail](https://github.com/ffreua/neurodoc/blob/main/audit/services.py): `audit/services.py`
- [Event dispatcher](https://github.com/ffreua/neurodoc/blob/main/events/dispatcher.py): `events/dispatcher.py`
- [Reports and exports](https://github.com/ffreua/neurodoc/tree/main/reporting): `reporting`
- [Sensitive-data logging](https://github.com/ffreua/neurodoc/blob/main/base/logging.py): `base/logging.py`

### Communications and AI

- [Patient communications](https://github.com/ffreua/neurodoc/blob/main/communications/models.py): `communications/models.py`
- [Notifications](https://github.com/ffreua/neurodoc/tree/main/notifications): `notifications`
- [AI assistant](https://github.com/ffreua/neurodoc/tree/main/ai): `ai`
- [Team chat](https://github.com/ffreua/neurodoc/blob/main/teamchat/services.py): `teamchat/services.py`

### Other components

- **Clinician and staff**
- **Patient**
- **External services**

## Connections

- Clinician and staff → Tenant and accounts: signs in
- Tenant and accounts → Roles and permissions: scopes access (evidence: `tenancy/permissions.py`)
- Patient → Patient records: registers with clinic
- Clinician and staff → Appointments: manages schedule
- Appointments → Patient records: associates patient
- Clinician and staff → Clinical encounters: records care
- Clinical encounters → Patient records: records in
- Clinician and staff → Exam scheduling: schedules exams
- Clinician and staff → Medical catalogs: uses catalogs
- Clinician and staff → Medical documents: issues documents
- Medical documents → Attachment storage: stores attachments (evidence: `documents/storage.py`)
- Medical documents → External services: signs PAdES
- Medical documents → SNCR prescriptions: issues controlled prescriptions
- SNCR prescriptions → External services: checks prescriptions
- Clinician and staff → TISS billing: submits claims
- TISS billing → External services: validates ANS format
- Clinician and staff → Practice finance: manages payments
- Appointments → Event dispatcher: publishes schedule events
- Event dispatcher → Patient communications: dispatches appointment events
- Patient communications → External services: sends email and SMS
- Patient → Medical documents: requests through portal
- Patient → Attachment storage: uploads exam reports
- Clinician and staff → AI assistant: requests assistance
- AI assistant → External services: calls configured provider
- AI assistant → Clinician and staff: returns for review
- Clinician and staff → Team chat: messages colleagues
- Clinician and staff → Reports and exports: exports practice data
- Tenant and accounts → Plans and limits: selects plan (evidence: `tenancy/models.py`)
- Plans and limits → Roles and permissions: limits capabilities (evidence: `tenancy/permissions.py`)
- Tenant and accounts → Audit trail: records acceptance (evidence: `tenancy/services.py`)
- Clinician and staff → Audit trail: creates audit events
- Patient records → Sensitive-data logging: protects diagnostic output
