# joaoptoaldo/somdiabetes architecture

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

- Interactive diagram: https://gitdiagram.com/joaoptoaldo/somdiabetes
- Repository: https://github.com/joaoptoaldo/somdiabetes

## Overview

SOMDiabetes is a Django diabetes-monitoring application for clients and health professionals. Users register and access personal and clinical records, log meals and physical activity, and consult health-related data; staff manage reference catalogs and send notices. Reports can be generated from natural-language descriptions using an LLM to produce and run SQL. The graph retains the README’s major domain capabilities. Some subsystem details and URL routing were not sampled, so undocumented wiring is omitted; LLM-to-provider integration is shown as unverified.

Main entry points: [`projeto/appcliente/views.py`](https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/appcliente/views.py) (Client Portal), [`projeto/utils/decorators.py`](https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/utils/decorators.py) (Access Controls), [`projeto/aviso/views.py`](https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/aviso/views.py) (Notice Delivery), [`projeto/usuario/views.py`](https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/usuario/views.py) (Registration and Login)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Users and Access"]
  node_user[("User Accounts<br/>[models.py]")]
  node_user_views["Registration and Login<br/>[views.py]"]
  node_client_views["Client Portal<br/>[views.py]"]
  node_client_forms["Client Forms<br/>[forms.py]"]
end

subgraph group_monitoring["Health Monitoring"]
  node_clinical[("Clinical Records<br/>[models.py]")]
  node_clinical_views["Clinical Record Views<br/>[views.py]"]
  node_meal[("Meal Records<br/>[models.py]")]
  node_meal_views["Meal Logging<br/>[views.py]"]
  node_meal_recognition["Meal Recognition<br/>[jsRecognition.js]"]
  node_activity_record[("Activity Records<br/>[models.py]")]
  node_activity_views["Activity Logging<br/>[views.py]"]
end

subgraph group_catalog["Clinical Catalogs"]
  node_food[("Food Catalog<br/>[models.py]")]
  node_food_views["Food Management<br/>[views.py]"]
  node_exercise[("Exercise Catalog<br/>[models.py]")]
  node_exercise_views["Exercise Management<br/>[views.py]"]
  node_medicine[("Medication Catalog<br/>[models.py]")]
  node_medicine_views["Medication Management<br/>[views.py]"]
end

subgraph group_insights["Communication and Reports"]
  node_notice[("Notices<br/>[models.py]")]
  node_notice_views["Notice Delivery<br/>[views.py]"]
  node_report[("Report Records<br/>[models.py]")]
  node_report_views["Report Generation<br/>[views.py]"]
  node_llm["LLM and SQL<br/>[conecta_llm.py]"]
end

subgraph group_shared["Shared Services"]
  node_access["Access Controls<br/>[decorators.py]"]
end

node_gemini{{"Gemini API"}}
node_email{{"Email Service"}}
node_person(("System User"))

node_person -->|"registers or signs in"| node_user_views
node_user_views -->|"creates and activates"| node_user
node_user_views -->|"sends activation email"| node_email
node_person -.->|"uses client portal"| node_client_views
node_client_views -->|"manages records"| node_clinical
node_client_views -->|"manages meal logs"| node_meal
node_client_views -->|"manages activity logs"| node_activity_record
node_client_views -->|"reads account data"| node_user
node_client_views -->|"uses forms"| node_client_forms
node_clinical_views -->|"creates and queries"| node_clinical
node_meal_views -->|"creates and queries"| node_meal
node_activity_views -->|"creates and queries"| node_activity_record
node_food_views -->|"manages catalog"| node_food
node_exercise_views -->|"manages catalog"| node_exercise
node_medicine_views -->|"manages catalog"| node_medicine
node_clinical_views -->|"requires login"| node_access
node_activity_views -->|"requires login"| node_access
node_food_views -->|"requires login"| node_access
node_exercise_views -->|"requires login"| node_access
node_medicine_views -->|"requires login"| node_access
node_notice_views -->|"manages notices"| node_notice
node_notice_views -->|"selects recipients"| node_user
node_notice_views -->|"sends notice"| node_email
node_report_views -->|"saves report"| node_report
node_report_views -->|"generates and runs SQL"| node_llm
node_llm -.->|"requests generation"| node_gemini
node_meal_recognition -.->|"supports meal entry"| node_meal_views

click node_user "https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/usuario/models.py"
click node_user_views "https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/usuario/views.py"
click node_access "https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/utils/decorators.py"
click node_client_views "https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/appcliente/views.py"
click node_client_forms "https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/appcliente/forms.py"
click node_clinical "https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/dado_clinico/models.py"
click node_clinical_views "https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/dado_clinico/views.py"
click node_meal "https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/registro_refeicao/models.py"
click node_meal_views "https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/registro_refeicao/views.py"
click node_meal_recognition "https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/registro_refeicao/templates/registro_refeicao/jsRecognition.js"
click node_activity_record "https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/registro_atividade/models.py"
click node_activity_views "https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/registro_atividade/views.py"
click node_food "https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/alimento/models.py"
click node_food_views "https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/alimento/views.py"
click node_exercise "https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/exercicio/models.py"
click node_exercise_views "https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/exercicio/views.py"
click node_medicine "https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/medicamento/models.py"
click node_medicine_views "https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/medicamento/views.py"
click node_notice "https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/aviso/models.py"
click node_notice_views "https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/aviso/views.py"
click node_report "https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/relatorio/models.py"
click node_report_views "https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/relatorio/views.py"
click node_llm "https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/utils/conecta_llm.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_user,node_user_views,node_client_views,node_client_forms,node_person toneBlue
class node_clinical,node_clinical_views,node_meal,node_meal_views,node_meal_recognition,node_activity_record,node_activity_views toneAmber
class node_food,node_food_views,node_exercise,node_exercise_views,node_medicine,node_medicine_views,node_gemini toneMint
class node_notice,node_notice_views,node_report,node_report_views,node_llm toneRose
class node_access,node_email toneIndigo
```

## Components

### Users and Access

- [User Accounts](https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/usuario/models.py): `projeto/usuario/models.py`
- [Registration and Login](https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/usuario/views.py): `projeto/usuario/views.py`
- [Client Portal](https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/appcliente/views.py): `projeto/appcliente/views.py`
- [Client Forms](https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/appcliente/forms.py): `projeto/appcliente/forms.py`

### Health Monitoring

- [Clinical Records](https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/dado_clinico/models.py): `projeto/dado_clinico/models.py`
- [Clinical Record Views](https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/dado_clinico/views.py): `projeto/dado_clinico/views.py`
- [Meal Records](https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/registro_refeicao/models.py): `projeto/registro_refeicao/models.py`
- [Meal Logging](https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/registro_refeicao/views.py): `projeto/registro_refeicao/views.py`
- [Meal Recognition](https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/registro_refeicao/templates/registro_refeicao/jsRecognition.js): `projeto/registro_refeicao/templates/registro_refeicao/jsRecognition.js`
- [Activity Records](https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/registro_atividade/models.py): `projeto/registro_atividade/models.py`
- [Activity Logging](https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/registro_atividade/views.py): `projeto/registro_atividade/views.py`

### Clinical Catalogs

- [Food Catalog](https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/alimento/models.py): `projeto/alimento/models.py`
- [Food Management](https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/alimento/views.py): `projeto/alimento/views.py`
- [Exercise Catalog](https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/exercicio/models.py): `projeto/exercicio/models.py`
- [Exercise Management](https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/exercicio/views.py): `projeto/exercicio/views.py`
- [Medication Catalog](https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/medicamento/models.py): `projeto/medicamento/models.py`
- [Medication Management](https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/medicamento/views.py): `projeto/medicamento/views.py`

### Communication and Reports

- [Notices](https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/aviso/models.py): `projeto/aviso/models.py`
- [Notice Delivery](https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/aviso/views.py): `projeto/aviso/views.py`
- [Report Records](https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/relatorio/models.py): `projeto/relatorio/models.py`
- [Report Generation](https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/relatorio/views.py): `projeto/relatorio/views.py`
- [LLM and SQL](https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/utils/conecta_llm.py): `projeto/utils/conecta_llm.py`

### Shared Services

- [Access Controls](https://github.com/joaoptoaldo/somdiabetes/blob/main/projeto/utils/decorators.py): `projeto/utils/decorators.py`

### Other components

- **Gemini API**
- **Email Service**
- **System User**

## Connections

- System User → Registration and Login: registers or signs in
- Registration and Login → User Accounts: creates and activates (evidence: `projeto/usuario/views.py`)
- Registration and Login → Email Service: sends activation email (evidence: `projeto/usuario/views.py`)
- System User → Client Portal: uses client portal
- Client Portal → Clinical Records: manages records (evidence: `projeto/appcliente/views.py`)
- Client Portal → Meal Records: manages meal logs (evidence: `projeto/appcliente/views.py`)
- Client Portal → Activity Records: manages activity logs (evidence: `projeto/appcliente/views.py`)
- Client Portal → User Accounts: reads account data (evidence: `projeto/appcliente/views.py`)
- Client Portal → Client Forms: uses forms (evidence: `projeto/appcliente/views.py`)
- Clinical Record Views → Clinical Records: creates and queries (evidence: `projeto/dado_clinico/views.py`)
- Meal Logging → Meal Records: creates and queries (evidence: `projeto/registro_refeicao/views.py`)
- Activity Logging → Activity Records: creates and queries (evidence: `projeto/registro_atividade/views.py`)
- Food Management → Food Catalog: manages catalog (evidence: `projeto/alimento/views.py`)
- Exercise Management → Exercise Catalog: manages catalog (evidence: `projeto/exercicio/views.py`)
- Medication Management → Medication Catalog: manages catalog (evidence: `projeto/medicamento/views.py`)
- Clinical Record Views → Access Controls: requires login (evidence: `projeto/dado_clinico/views.py`)
- Activity Logging → Access Controls: requires login (evidence: `projeto/registro_atividade/views.py`)
- Food Management → Access Controls: requires login (evidence: `projeto/alimento/views.py`)
- Exercise Management → Access Controls: requires login (evidence: `projeto/exercicio/views.py`)
- Medication Management → Access Controls: requires login (evidence: `projeto/medicamento/views.py`)
- Notice Delivery → Notices: manages notices (evidence: `projeto/aviso/views.py`)
- Notice Delivery → User Accounts: selects recipients (evidence: `projeto/aviso/views.py`)
- Notice Delivery → Email Service: sends notice (evidence: `projeto/aviso/views.py`)
- Report Generation → Report Records: saves report (evidence: `projeto/relatorio/views.py`)
- Report Generation → LLM and SQL: generates and runs SQL (evidence: `projeto/relatorio/views.py`)
- LLM and SQL → Gemini API: requests generation
- Meal Recognition → Meal Logging: supports meal entry
