# flyybnjj/sgr architecture

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

- Interactive diagram: https://gitdiagram.com/flyybnjj/sgr
- Repository: https://github.com/flyybnjj/sgr

## Overview

SGR is a Django municipal case-management system for La Serena. Its central workflow is staff sign-in and delegation-scoped access, finding or registering a resident, recording an attention or follow-up action, and tracking progress against goals; staff can then review reports and export them. Separate capabilities cover user/role administration, delegations and catalogs, account recovery and passkeys, and commitment letters. The graph combines README-described capabilities with relationships visible in excerpts or the source index; unsampled modules are represented by their exact paths, without assuming their internal wiring.

Main entry points: [`atenciones/views.py`](https://github.com/flyybnjj/sgr/blob/main/atenciones/views.py) (Attention workflow), [`atenciones/models.py`](https://github.com/flyybnjj/sgr/blob/main/atenciones/models.py) (Attention and action records), [`usuarios/views.py`](https://github.com/flyybnjj/sgr/blob/main/usuarios/views.py) (Account workflows), [`atenciones/forms.py`](https://github.com/flyybnjj/sgr/blob/main/atenciones/forms.py) (Attention forms)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity and Access"]
  node_access["Role access<br/>[access.py]"]
  node_accounts[("Users and roles<br/>[models.py]")]
  node_account_workflows["Account workflows<br/>[views.py]"]
  node_passkeys["Passkeys<br/>[passkeys.py]"]
end

subgraph group_operations["Resident Operations"]
  node_residents[("Resident registry<br/>[models.py]")]
  node_attention_workflow["Attention workflow<br/>[views.py]"]
  node_attention_records[("Attention and action records<br/>[models.py]")]
  node_attention_forms["Attention forms<br/>[forms.py]"]
  node_evidence["Action evidence<br/>[evidence.py]"]
  node_documents["Supporting documents<br/>[documents.py]"]
  node_letters["Commitment letters<br/>[views.py]"]
end

subgraph group_territory["Territorial Administration"]
  node_delegations[("Delegations and absences<br/>[models.py]")]
  node_organizations[("Community organizations<br/>[models.py]")]
end

subgraph group_insight["Goals and Reporting"]
  node_goal_rules["Goal calculations<br/>[goals.py]"]
  node_reports["Attention reports<br/>[reports.py]"]
  node_dashboard["Dashboard updates<br/>[updates.py]"]
end

subgraph group_shared["Shared Services"]
  node_validation["Input validation<br/>[validators.py]"]
  node_rut_search["Resident search<br/>[rut_search.py]"]
  node_excel["Excel export<br/>[excel_utils.py]"]
end

node_staff(("Municipal staff"))
node_database[("Relational database")]

node_staff -->|"signs in"| node_account_workflows
node_account_workflows -->|"checks permissions"| node_access
node_account_workflows -->|"manages accounts"| node_accounts
node_account_workflows -->|"uses passkeys"| node_passkeys
node_staff -->|"records attention"| node_attention_workflow
node_attention_workflow -->|"checks permissions"| node_access
node_attention_workflow -->|"searches residents"| node_residents
node_attention_workflow -->|"filters residents"| node_rut_search
node_attention_workflow -->|"builds forms"| node_attention_forms
node_attention_workflow -->|"records actions"| node_attention_records
node_attention_forms -->|"validates photos"| node_evidence
node_attention_forms -->|"validates documents"| node_documents
node_attention_forms -->|"selects organization"| node_organizations
node_attention_workflow -->|"scopes records"| node_delegations
node_attention_workflow -->|"uses goal logic"| node_goal_rules
node_attention_workflow -->|"exports actions"| node_reports
node_attention_workflow -->|"exports sheets"| node_excel
node_staff -->|"manages letters"| node_letters
node_letters -->|"uses attention data"| node_attention_records
node_staff -->|"reviews progress"| node_dashboard
node_dashboard -->|"checks permissions"| node_access
node_dashboard -.->|"reads updates"| node_database
node_attention_records -->|"stores records"| node_database
node_residents -->|"stores residents"| node_database
node_accounts -->|"stores accounts"| node_database
node_delegations -->|"stores territory"| node_database
node_organizations -->|"stores organizations"| node_database
node_attention_workflow -->|"validates input"| node_validation
node_accounts -->|"assigns delegation"| node_delegations
node_goal_rules -.->|"calculates from actions"| node_attention_records
node_reports -.->|"reports on actions"| node_attention_records

click node_access "https://github.com/flyybnjj/sgr/blob/main/config/access.py"
click node_accounts "https://github.com/flyybnjj/sgr/blob/main/usuarios/models.py"
click node_account_workflows "https://github.com/flyybnjj/sgr/blob/main/usuarios/views.py"
click node_passkeys "https://github.com/flyybnjj/sgr/blob/main/usuarios/passkeys.py"
click node_residents "https://github.com/flyybnjj/sgr/blob/main/vecinos/models.py"
click node_attention_workflow "https://github.com/flyybnjj/sgr/blob/main/atenciones/views.py"
click node_attention_records "https://github.com/flyybnjj/sgr/blob/main/atenciones/models.py"
click node_attention_forms "https://github.com/flyybnjj/sgr/blob/main/atenciones/forms.py"
click node_evidence "https://github.com/flyybnjj/sgr/blob/main/atenciones/evidence.py"
click node_documents "https://github.com/flyybnjj/sgr/blob/main/atenciones/documents.py"
click node_letters "https://github.com/flyybnjj/sgr/blob/main/cartas/views.py"
click node_delegations "https://github.com/flyybnjj/sgr/blob/main/territorial/models.py"
click node_organizations "https://github.com/flyybnjj/sgr/blob/main/organizaciones/models.py"
click node_goal_rules "https://github.com/flyybnjj/sgr/blob/main/atenciones/goals.py"
click node_reports "https://github.com/flyybnjj/sgr/blob/main/atenciones/reports.py"
click node_dashboard "https://github.com/flyybnjj/sgr/blob/main/dashboard/updates.py"
click node_validation "https://github.com/flyybnjj/sgr/blob/main/config/validators.py"
click node_rut_search "https://github.com/flyybnjj/sgr/blob/main/config/rut_search.py"
click node_excel "https://github.com/flyybnjj/sgr/blob/main/config/excel_utils.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_access,node_accounts,node_account_workflows,node_passkeys toneBlue
class node_residents,node_attention_workflow,node_attention_records,node_attention_forms,node_evidence,node_documents,node_letters,node_database toneAmber
class node_delegations,node_organizations toneMint
class node_goal_rules,node_reports,node_dashboard toneRose
class node_validation,node_rut_search,node_excel,node_staff toneIndigo
```

## Components

### Identity and Access

- [Role access](https://github.com/flyybnjj/sgr/blob/main/config/access.py): `config/access.py`
- [Users and roles](https://github.com/flyybnjj/sgr/blob/main/usuarios/models.py): `usuarios/models.py`
- [Account workflows](https://github.com/flyybnjj/sgr/blob/main/usuarios/views.py): `usuarios/views.py`
- [Passkeys](https://github.com/flyybnjj/sgr/blob/main/usuarios/passkeys.py): `usuarios/passkeys.py`

### Resident Operations

- [Resident registry](https://github.com/flyybnjj/sgr/blob/main/vecinos/models.py): `vecinos/models.py`
- [Attention workflow](https://github.com/flyybnjj/sgr/blob/main/atenciones/views.py): `atenciones/views.py`
- [Attention and action records](https://github.com/flyybnjj/sgr/blob/main/atenciones/models.py): `atenciones/models.py`
- [Attention forms](https://github.com/flyybnjj/sgr/blob/main/atenciones/forms.py): `atenciones/forms.py`
- [Action evidence](https://github.com/flyybnjj/sgr/blob/main/atenciones/evidence.py): `atenciones/evidence.py`
- [Supporting documents](https://github.com/flyybnjj/sgr/blob/main/atenciones/documents.py): `atenciones/documents.py`
- [Commitment letters](https://github.com/flyybnjj/sgr/blob/main/cartas/views.py): `cartas/views.py`

### Territorial Administration

- [Delegations and absences](https://github.com/flyybnjj/sgr/blob/main/territorial/models.py): `territorial/models.py`
- [Community organizations](https://github.com/flyybnjj/sgr/blob/main/organizaciones/models.py): `organizaciones/models.py`

### Goals and Reporting

- [Goal calculations](https://github.com/flyybnjj/sgr/blob/main/atenciones/goals.py): `atenciones/goals.py`
- [Attention reports](https://github.com/flyybnjj/sgr/blob/main/atenciones/reports.py): `atenciones/reports.py`
- [Dashboard updates](https://github.com/flyybnjj/sgr/blob/main/dashboard/updates.py): `dashboard/updates.py`

### Shared Services

- [Input validation](https://github.com/flyybnjj/sgr/blob/main/config/validators.py): `config/validators.py`
- [Resident search](https://github.com/flyybnjj/sgr/blob/main/config/rut_search.py): `config/rut_search.py`
- [Excel export](https://github.com/flyybnjj/sgr/blob/main/config/excel_utils.py): `config/excel_utils.py`

### Other components

- **Municipal staff**
- **Relational database**

## Connections

- Municipal staff → Account workflows: signs in (evidence: `README.md`)
- Account workflows → Role access: checks permissions (evidence: `usuarios/views.py`)
- Account workflows → Users and roles: manages accounts (evidence: `usuarios/views.py`)
- Account workflows → Passkeys: uses passkeys (evidence: `usuarios/views.py`)
- Municipal staff → Attention workflow: records attention (evidence: `README.md`)
- Attention workflow → Role access: checks permissions (evidence: `atenciones/views.py`)
- Attention workflow → Resident registry: searches residents (evidence: `atenciones/views.py`)
- Attention workflow → Resident search: filters residents (evidence: `atenciones/views.py`)
- Attention workflow → Attention forms: builds forms (evidence: `atenciones/views.py`)
- Attention workflow → Attention and action records: records actions (evidence: `atenciones/views.py`)
- Attention forms → Action evidence: validates photos (evidence: `atenciones/forms.py`)
- Attention forms → Supporting documents: validates documents (evidence: `atenciones/forms.py`)
- Attention forms → Community organizations: selects organization (evidence: `atenciones/forms.py`)
- Attention workflow → Delegations and absences: scopes records (evidence: `atenciones/views.py`)
- Attention workflow → Goal calculations: uses goal logic (evidence: `atenciones/views.py`)
- Attention workflow → Attention reports: exports actions (evidence: `atenciones/views.py`)
- Attention workflow → Excel export: exports sheets (evidence: `atenciones/views.py`)
- Municipal staff → Commitment letters: manages letters (evidence: `README.md`)
- Commitment letters → Attention and action records: uses attention data (evidence: `cartas/views.py`)
- Municipal staff → Dashboard updates: reviews progress (evidence: `README.md`)
- Dashboard updates → Role access: checks permissions (evidence: `dashboard/updates.py`)
- Dashboard updates → Relational database: reads updates (evidence: `dashboard/updates.py`)
- Attention and action records → Relational database: stores records (evidence: `atenciones/models.py`)
- Resident registry → Relational database: stores residents (evidence: `vecinos/models.py`)
- Users and roles → Relational database: stores accounts (evidence: `usuarios/models.py`)
- Delegations and absences → Relational database: stores territory (evidence: `territorial/models.py`)
- Community organizations → Relational database: stores organizations (evidence: `organizaciones/models.py`)
- Attention workflow → Input validation: validates input (evidence: `atenciones/views.py`)
- Users and roles → Delegations and absences: assigns delegation (evidence: `usuarios/models.py`)
- Goal calculations → Attention and action records: calculates from actions (evidence: `atenciones/models.py`)
- Attention reports → Attention and action records: reports on actions
