# metanochava/back architecture

> Architecture diagram of the GitHub repository metanochava/back, 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/metanochava/back
- Repository: https://github.com/metanochava/back

## Overview

Mytech SaaS is a Django multi-tenant business platform with healthcare, HR, inventory, sales, and pharmacy modules. Users work through module APIs for domain workflows; services enforce business rules and persist changes in module models. The excerpts directly show recruitment actions, pharmacy dispensing, and exam/lab processing. Other substantial capabilities are represented from the source tree and index, but their runtime connections are left unasserted where source was not shown.

Main entry points: [`saude/services/exam_request_service.py`](https://github.com/metanochava/back/blob/main/saude/services/exam_request_service.py) (Exam and lab flow), [`farmacia/services.py`](https://github.com/metanochava/back/blob/main/farmacia/services.py) (Prescription dispensing), [`hr/views/application.py`](https://github.com/metanochava/back/blob/main/hr/views/application.py) (Recruitment actions), [`hr/services/recruitment_service.py`](https://github.com/metanochava/back/blob/main/hr/services/recruitment_service.py) (Recruitment service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_health["Healthcare"]
  node_clinical_api["Clinical APIs"]
  node_clinical_services["Clinical services"]
  node_exam_flow["Exam and lab flow"]
  node_consultation["Consultation service"]
  node_lab_results["Lab result service"]
  node_patient_records[("Patient records<br/>[paciente.py]")]
  node_exam_requests[("Exam requests")]
  node_exam_items[("Requested exam items")]
  node_exam_results[("Exam results")]
end

subgraph group_people["Human Resources"]
  node_hr_api["HR APIs"]
  node_recruitment_api["Recruitment actions<br/>[application.py]"]
  node_recruitment_service["Recruitment service"]
  node_application[("Applications<br/>[application.py]")]
  node_employee["Employee lifecycle"]
  node_hr_records[("HR records<br/>[employee.py]")]
end

subgraph group_commerce["Commerce and Stock"]
  node_sales_api["Sales APIs"]
  node_sales_records[("Sales records")]
  node_inventory_api["Inventory APIs"]
  node_inventory_service["Stock operations<br/>[services.py]"]
  node_inventory_records[("Stock and products")]
end

subgraph group_pharmacy["Pharmacy"]
  node_pharmacy_api["Pharmacy APIs"]
  node_pharmacy_service["Prescription dispensing<br/>[services.py]"]
  node_pharmacy_queue[("Pharmacy queue<br/>[filafarmacia.py]")]
  node_prescription_event["Prescription-created event"]
end

node_user(("Staff user"))
node_patient(("Patient"))

node_user -.->|"submits actions"| node_recruitment_api
node_recruitment_api -->|"delegates actions"| node_recruitment_service
node_recruitment_api -->|"loads application"| node_application
node_recruitment_service -.->|"updates workflow"| node_application
node_recruitment_service -.->|"creates employee"| node_hr_records
node_user -.->|"manages lifecycle"| node_employee
node_employee -.->|"updates employee"| node_hr_records
node_patient -.->|"requests care"| node_clinical_api
node_user -.->|"uses clinical APIs"| node_clinical_api
node_clinical_api -.->|"delegates workflows"| node_clinical_services
node_clinical_services -.->|"uses consultation logic"| node_consultation
node_exam_flow -->|"resolves patient"| node_patient_records
node_exam_flow -->|"loads requests"| node_exam_requests
node_exam_flow -->|"locks exam items"| node_exam_items
node_exam_flow -->|"validates results"| node_exam_results
node_exam_flow -->|"coordinates results"| node_lab_results
node_user -.->|"records sales"| node_sales_api
node_sales_api -.->|"persists sales"| node_sales_records
node_user -.->|"manages stock"| node_inventory_api
node_inventory_api -.->|"uses stock operations"| node_inventory_service
node_inventory_service -.->|"updates stock"| node_inventory_records
node_user -.->|"reviews prescriptions"| node_pharmacy_api
node_pharmacy_api -.->|"calls workflows"| node_pharmacy_service
node_pharmacy_service -.->|"updates queue"| node_pharmacy_queue
node_prescription_event -->|"enqueues prescription"| node_pharmacy_service
node_pharmacy_service -->|"commits stock movements"| node_inventory_service

click node_clinical_api "https://github.com/metanochava/back/tree/main/saude/views"
click node_clinical_services "https://github.com/metanochava/back/tree/main/saude/services"
click node_exam_flow "https://github.com/metanochava/back/blob/main/saude/services/exam_request_service.py"
click node_consultation "https://github.com/metanochava/back/blob/main/saude/services/consultation_service.py"
click node_lab_results "https://github.com/metanochava/back/blob/main/saude/services/lab_result_service.py"
click node_patient_records "https://github.com/metanochava/back/blob/main/saude/models/paciente.py"
click node_exam_requests "https://github.com/metanochava/back/blob/main/saude/models/pedidoexamemedico.py"
click node_exam_items "https://github.com/metanochava/back/blob/main/saude/models/itempedidoexamemedico.py"
click node_exam_results "https://github.com/metanochava/back/blob/main/saude/models/resultadoexamemedico.py"
click node_hr_api "https://github.com/metanochava/back/tree/main/hr/views"
click node_recruitment_api "https://github.com/metanochava/back/blob/main/hr/views/application.py"
click node_recruitment_service "https://github.com/metanochava/back/blob/main/hr/services/recruitment_service.py"
click node_application "https://github.com/metanochava/back/blob/main/hr/models/application.py"
click node_employee "https://github.com/metanochava/back/blob/main/hr/services/lifecycle_service.py"
click node_hr_records "https://github.com/metanochava/back/blob/main/hr/models/employee.py"
click node_sales_api "https://github.com/metanochava/back/tree/main/sales/views"
click node_sales_records "https://github.com/metanochava/back/tree/main/sales/models"
click node_inventory_api "https://github.com/metanochava/back/tree/main/inventory/views"
click node_inventory_service "https://github.com/metanochava/back/blob/main/inventory/services.py"
click node_inventory_records "https://github.com/metanochava/back/tree/main/inventory/models"
click node_pharmacy_api "https://github.com/metanochava/back/tree/main/farmacia/views"
click node_pharmacy_service "https://github.com/metanochava/back/blob/main/farmacia/services.py"
click node_pharmacy_queue "https://github.com/metanochava/back/blob/main/farmacia/models/filafarmacia.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_clinical_api,node_clinical_services,node_exam_flow,node_consultation,node_lab_results,node_patient_records,node_exam_requests,node_exam_items,node_exam_results,node_user toneBlue
class node_hr_api,node_recruitment_api,node_recruitment_service,node_application,node_employee,node_hr_records toneAmber
class node_sales_api,node_sales_records,node_inventory_api,node_inventory_service,node_inventory_records toneMint
class node_pharmacy_api,node_pharmacy_service,node_pharmacy_queue,node_prescription_event toneRose
class node_patient toneIndigo
```

## Components

### Healthcare

- [Clinical APIs](https://github.com/metanochava/back/tree/main/saude/views): `saude/views`
- [Clinical services](https://github.com/metanochava/back/tree/main/saude/services): `saude/services`
- [Exam and lab flow](https://github.com/metanochava/back/blob/main/saude/services/exam_request_service.py): `saude/services/exam_request_service.py`
- [Consultation service](https://github.com/metanochava/back/blob/main/saude/services/consultation_service.py): `saude/services/consultation_service.py`
- [Lab result service](https://github.com/metanochava/back/blob/main/saude/services/lab_result_service.py): `saude/services/lab_result_service.py`
- [Patient records](https://github.com/metanochava/back/blob/main/saude/models/paciente.py): `saude/models/paciente.py`
- [Exam requests](https://github.com/metanochava/back/blob/main/saude/models/pedidoexamemedico.py): `saude/models/pedidoexamemedico.py`
- [Requested exam items](https://github.com/metanochava/back/blob/main/saude/models/itempedidoexamemedico.py): `saude/models/itempedidoexamemedico.py`
- [Exam results](https://github.com/metanochava/back/blob/main/saude/models/resultadoexamemedico.py): `saude/models/resultadoexamemedico.py`

### Human Resources

- [HR APIs](https://github.com/metanochava/back/tree/main/hr/views): `hr/views`
- [Recruitment actions](https://github.com/metanochava/back/blob/main/hr/views/application.py): `hr/views/application.py`
- [Recruitment service](https://github.com/metanochava/back/blob/main/hr/services/recruitment_service.py): `hr/services/recruitment_service.py`
- [Applications](https://github.com/metanochava/back/blob/main/hr/models/application.py): `hr/models/application.py`
- [Employee lifecycle](https://github.com/metanochava/back/blob/main/hr/services/lifecycle_service.py): `hr/services/lifecycle_service.py`
- [HR records](https://github.com/metanochava/back/blob/main/hr/models/employee.py): `hr/models/employee.py`

### Commerce and Stock

- [Sales APIs](https://github.com/metanochava/back/tree/main/sales/views): `sales/views`
- [Sales records](https://github.com/metanochava/back/tree/main/sales/models): `sales/models`
- [Inventory APIs](https://github.com/metanochava/back/tree/main/inventory/views): `inventory/views`
- [Stock operations](https://github.com/metanochava/back/blob/main/inventory/services.py): `inventory/services.py`
- [Stock and products](https://github.com/metanochava/back/tree/main/inventory/models): `inventory/models`

### Pharmacy

- [Pharmacy APIs](https://github.com/metanochava/back/tree/main/farmacia/views): `farmacia/views`
- [Prescription dispensing](https://github.com/metanochava/back/blob/main/farmacia/services.py): `farmacia/services.py`
- [Pharmacy queue](https://github.com/metanochava/back/blob/main/farmacia/models/filafarmacia.py): `farmacia/models/filafarmacia.py`
- **Prescription-created event**

### Other components

- **Staff user**
- **Patient**

## Connections

- Staff user → Recruitment actions: submits actions
- Recruitment actions → Recruitment service: delegates actions (evidence: `hr/views/application.py`)
- Recruitment actions → Applications: loads application (evidence: `hr/views/application.py`)
- Recruitment service → Applications: updates workflow
- Recruitment service → HR records: creates employee
- Staff user → Employee lifecycle: manages lifecycle
- Employee lifecycle → HR records: updates employee (evidence: `hr/services/lifecycle_service.py`)
- Patient → Clinical APIs: requests care
- Staff user → Clinical APIs: uses clinical APIs
- Clinical APIs → Clinical services: delegates workflows
- Clinical services → Consultation service: uses consultation logic (evidence: `saude/services/exam_request_service.py`)
- Exam and lab flow → Patient records: resolves patient (evidence: `saude/services/exam_request_service.py`)
- Exam and lab flow → Exam requests: loads requests (evidence: `saude/services/exam_request_service.py`)
- Exam and lab flow → Requested exam items: locks exam items (evidence: `saude/services/exam_request_service.py`)
- Exam and lab flow → Exam results: validates results (evidence: `saude/services/exam_request_service.py`)
- Exam and lab flow → Lab result service: coordinates results (evidence: `saude/services/exam_request_service.py`)
- Staff user → Sales APIs: records sales
- Sales APIs → Sales records: persists sales
- Staff user → Inventory APIs: manages stock
- Inventory APIs → Stock operations: uses stock operations
- Stock operations → Stock and products: updates stock (evidence: `inventory/services.py`)
- Staff user → Pharmacy APIs: reviews prescriptions
- Pharmacy APIs → Prescription dispensing: calls workflows
- Prescription dispensing → Pharmacy queue: updates queue
- Prescription-created event → Prescription dispensing: enqueues prescription
- Prescription dispensing → Stock operations: commits stock movements (evidence: `farmacia/services.py`)
