# diegofc17/sdg architecture

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

- Interactive diagram: https://gitdiagram.com/diegofc17/sdg
- Repository: https://github.com/diegofc17/sdg

## Overview

1. **Overall shape**
   - This is a **single Django monolith** organized into four domain apps under `apps/`: `core`, `accounts`, `documents`, and `audit`.
   - The project uses the standard Django runtime entry points: `manage.py`, `config/asgi.py`, `config/wsgi.py`, and global settings/routing in `config/`.

2. **Request routing**
   - Incoming HTTP requests flow through `config/urls.py` into each app’s `urls.py`.
   - Each app then dispatches to its own `views.py`, which renders HTML templates rather than exposing a JSON API.

3. **Presentation layer**
   - UI is server-rendered with Django templates in `templates/`.
   - Shared layout lives in `templates/base.html`; app-specific pages are split by feature area: home/dashboard, login/signup, documents, expedientes, and audit.
   - Static assets are simple front-end resources in `static/` (`css/app.css`, images).

4. **Core app**
   - `apps/core/` is the lightweight shell for landing pages and dashboard-style views.
   - It acts as the entry point for authenticated/unauthenticated navigation rather than containing domain logic.

5. **Accounts subsystem**
   - `apps/accounts/` owns user-facing account logic: forms, views, models, signals, and URL routes.
   - The presence of `templates/registration/login.html` and `signup.html` indicates Django authentication is extended with custom registration/login flows.
   - `signals.py` suggests post-save or profile-creation behavior tied to user accounts.

6. **Documents domain**
   - `apps/documents/` is the main business subsystem.
   - It contains models, forms, views, templates, and a rich migration history, indicating an evolving domain model.
   - The templates show user workflows for document creation, detail views, lists, and expediente management.

7. **Document lifecycle and metadata**
   - The migration names reveal the domain entities and their evolution: `Documento`, `Expediente`, `SerieDocumental`, `SubserieDocumental`, `TipoDocumental`, and later `TRD/TVD`-related structures.
   - Fields added over time include document classification, dates, status, support medium, asunto, and expediente linkage.
   - This suggests documents are cataloged and classified against an archival/records-management taxonomy.

8. **Audit subsystem**
   - `apps/audit/` handles audit logging or traceability views/forms/models.
   - There are dedicated templates and signals, implying events are captured automatically and then presented in an audit list UI.
   - `apps/audit/utils.py` likely supports formatting or aggregation of audit entries.

9. **Data flow between subsystems**
   - Typical flow is: user authenticates through `accounts`, navigates via `core`, creates or manages records in `documents`, and actions are recorded in `audit`.
   - Models and signals are the main integration mechanism between these apps, with the audit layer observing domain events rather than driving them.

10. **Persistence and schema management**
   - State is stored in Django models backed by a relational database, with schema evolution managed entirely through migrations.
   - The long sequence of `documents/migrations/` files shows the document schema is central and has been iteratively refined.

11. **Operational tooling**
   - `apps/documents/management/commands/import_trd.py` is an offline data-import/admin command used to load TRD reference data.
   - This indicates the application depends on controlled reference catalogs, not just user-entered data.

12. **Administrative surface**
   - Multiple `admin.py` files indicate the Django admin is used as a back-office management interface for the main models.
   - This is likely important for maintaining taxonomy/reference data and reviewing records without going through the end-user screens.

13. **Boundary summary**
   - The clearest architectural boundaries are:
     - **UI/rendering**: templates + views
     - **Identity**: accounts
     - **Records management**: documents
     - **Traceability**: audit
     - **Shared shell/routing**: core + config
   - There is no sign of a separate frontend, API gateway, or external service dependency in the repository structure.

14. **Likely runtime footprint**
   - The app runs as a standard Django site via `runserver` in development, and can be deployed through WSGI or ASGI.
   - `media/` is referenced in the README, so file uploads are part of the architecture even though the storage backend is not shown here.

Main entry points: [`config/urls.py`](https://github.com/diegofc17/sdg/blob/main/config/urls.py) (root urls), [`templates/base.html`](https://github.com/diegofc17/sdg/blob/main/templates/base.html) (base layout), [`apps/audit/views.py`](https://github.com/diegofc17/sdg/blob/main/apps/audit/views.py) (audit views), [`apps/audit/models.py`](https://github.com/diegofc17/sdg/blob/main/apps/audit/models.py) (audit)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_manage["manage.py<br/>Django entrypoint<br/>[manage.py]"]
  node_settings["settings<br/>Project config<br/>[settings.py]"]
  node_urls["root urls<br/>URL router<br/>[urls.py]"]
  node_asgi["ASGI<br/>Deployment entrypoint<br/>[asgi.py]"]
  node_wsgi["WSGI<br/>Deployment entrypoint<br/>[wsgi.py]"]
end

subgraph group_presentation["Presentation"]
  node_base_tpl["base layout<br/>Template shell<br/>[base.html]"]
  node_home_tpl["home pages<br/>Templates<br/>[home.html]"]
  node_auth_tpl["auth pages<br/>Templates<br/>[login.html]"]
  node_docs_tpl["doc pages<br/>Templates<br/>[list.html]"]
  node_audit_tpl["audit page<br/>Template<br/>[list.html]"]
end

subgraph group_domain["Domain apps"]
  node_core_views["core views<br/>Shell views<br/>[views.py]"]
  node_core_urls["core urls<br/>Route module<br/>[urls.py]"]
  node_accounts["accounts<br/>Identity app<br/>[models.py]"]
  node_accounts_views["auth views<br/>Auth UI<br/>[views.py]"]
  node_accounts_forms["account forms<br/>[forms.py]"]
  node_accounts_signals["account signals<br/>Hooks<br/>[signals.py]"]
  node_accounts_urls["account urls<br/>Route module<br/>[urls.py]"]
  node_documents[("documents<br/>Records app<br/>[models.py]")]
  node_documents_views["doc views<br/>Records UI<br/>[views.py]"]
  node_documents_forms["doc forms<br/>[forms.py]"]
  node_documents_urls["doc urls<br/>Route module<br/>[urls.py]"]
  node_audit[("audit<br/>Traceability app<br/>[models.py]")]
  node_audit_views["audit views<br/>Audit UI<br/>[views.py]"]
  node_audit_forms["audit forms<br/>[forms.py]"]
  node_audit_signals["audit signals<br/>Hooks<br/>[signals.py]"]
  node_audit_utils["audit utils<br/>Helpers<br/>[utils.py]"]
  node_audit_urls["audit urls<br/>Route module<br/>[urls.py]"]
end

subgraph group_dataops["Operations"]
  node_import_trd["import TRD<br/>Management command<br/>[import_trd.py]"]
  node_admin["admin<br/>Back office<br/>[admin.py]"]
end

node_manage -->|"loads"| node_settings
node_manage -->|"starts app"| node_urls
node_asgi -->|"uses"| node_settings
node_wsgi -->|"uses"| node_settings
node_urls -->|"includes"| node_core_urls
node_urls -->|"includes"| node_accounts_urls
node_urls -->|"includes"| node_documents_urls
node_urls -->|"includes"| node_audit_urls
node_core_urls -->|"dispatches"| node_core_views
node_core_views -->|"renders"| node_base_tpl
node_core_views -->|"renders"| node_home_tpl
node_accounts_urls -->|"dispatches"| node_accounts_views
node_accounts_views -->|"uses"| node_accounts_forms
node_accounts_views -->|"renders"| node_auth_tpl
node_accounts -->|"emits"| node_accounts_signals
node_accounts_signals -.->|"observes"| node_audit
node_documents_urls -->|"dispatches"| node_documents_views
node_documents_views -->|"uses"| node_documents_forms
node_documents_views -->|"renders"| node_docs_tpl
node_documents -->|"emits"| node_audit
node_audit_urls -->|"dispatches"| node_audit_views
node_audit_views -->|"uses"| node_audit_forms
node_audit_views -->|"uses"| node_audit_utils
node_audit_views -->|"renders"| node_audit_tpl
node_audit_signals -->|"writes"| node_audit
node_import_trd -.->|"imports into"| node_documents
node_admin -->|"manages"| node_documents
node_admin -->|"manages"| node_accounts
node_admin -->|"manages"| node_audit
node_base_tpl -.->|"extends"| node_auth_tpl
node_base_tpl -.->|"extends"| node_docs_tpl
node_base_tpl -.->|"extends"| node_audit_tpl

click node_manage "https://github.com/diegofc17/sdg/blob/main/manage.py"
click node_settings "https://github.com/diegofc17/sdg/blob/main/config/settings.py"
click node_urls "https://github.com/diegofc17/sdg/blob/main/config/urls.py"
click node_asgi "https://github.com/diegofc17/sdg/blob/main/config/asgi.py"
click node_wsgi "https://github.com/diegofc17/sdg/blob/main/config/wsgi.py"
click node_base_tpl "https://github.com/diegofc17/sdg/blob/main/templates/base.html"
click node_home_tpl "https://github.com/diegofc17/sdg/blob/main/templates/home.html"
click node_auth_tpl "https://github.com/diegofc17/sdg/blob/main/templates/registration/login.html"
click node_docs_tpl "https://github.com/diegofc17/sdg/blob/main/templates/documents/list.html"
click node_audit_tpl "https://github.com/diegofc17/sdg/blob/main/templates/audit/list.html"
click node_core_views "https://github.com/diegofc17/sdg/blob/main/apps/core/views.py"
click node_core_urls "https://github.com/diegofc17/sdg/blob/main/apps/core/urls.py"
click node_accounts "https://github.com/diegofc17/sdg/blob/main/apps/accounts/models.py"
click node_accounts_views "https://github.com/diegofc17/sdg/blob/main/apps/accounts/views.py"
click node_accounts_forms "https://github.com/diegofc17/sdg/blob/main/apps/accounts/forms.py"
click node_accounts_signals "https://github.com/diegofc17/sdg/blob/main/apps/accounts/signals.py"
click node_accounts_urls "https://github.com/diegofc17/sdg/blob/main/apps/accounts/urls.py"
click node_documents "https://github.com/diegofc17/sdg/blob/main/apps/documents/models.py"
click node_documents_views "https://github.com/diegofc17/sdg/blob/main/apps/documents/views.py"
click node_documents_forms "https://github.com/diegofc17/sdg/blob/main/apps/documents/forms.py"
click node_documents_urls "https://github.com/diegofc17/sdg/blob/main/apps/documents/urls.py"
click node_audit "https://github.com/diegofc17/sdg/blob/main/apps/audit/models.py"
click node_audit_views "https://github.com/diegofc17/sdg/blob/main/apps/audit/views.py"
click node_audit_forms "https://github.com/diegofc17/sdg/blob/main/apps/audit/forms.py"
click node_audit_signals "https://github.com/diegofc17/sdg/blob/main/apps/audit/signals.py"
click node_audit_utils "https://github.com/diegofc17/sdg/blob/main/apps/audit/utils.py"
click node_audit_urls "https://github.com/diegofc17/sdg/blob/main/apps/audit/urls.py"
click node_import_trd "https://github.com/diegofc17/sdg/blob/main/apps/documents/management/commands/import_trd.py"
click node_admin "https://github.com/diegofc17/sdg/blob/main/apps/documents/admin.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_manage,node_settings,node_urls,node_asgi,node_wsgi toneBlue
class node_base_tpl,node_home_tpl,node_auth_tpl,node_docs_tpl,node_audit_tpl toneAmber
class node_core_views,node_core_urls,node_accounts,node_accounts_views,node_accounts_forms,node_accounts_signals,node_accounts_urls,node_documents,node_documents_views,node_documents_forms,node_documents_urls,node_audit,node_audit_views,node_audit_forms,node_audit_signals,node_audit_utils,node_audit_urls toneMint
class node_import_trd,node_admin toneRose
```

## Components

### Runtime

Django entrypoints and project config

- [manage.py](https://github.com/diegofc17/sdg/blob/main/manage.py): Django entrypoint · Command-line entrypoint for development and admin tasks · `manage.py`
- [settings](https://github.com/diegofc17/sdg/blob/main/config/settings.py): Project config · Global Django settings · `config/settings.py`
- [root urls](https://github.com/diegofc17/sdg/blob/main/config/urls.py): URL router · Top-level request routing into app URLconfs · `config/urls.py`
- [ASGI](https://github.com/diegofc17/sdg/blob/main/config/asgi.py): Deployment entrypoint · ASGI application entrypoint · `config/asgi.py`
- [WSGI](https://github.com/diegofc17/sdg/blob/main/config/wsgi.py): Deployment entrypoint · WSGI application entrypoint · `config/wsgi.py`

### Presentation

Server-rendered pages and shared assets

- [base layout](https://github.com/diegofc17/sdg/blob/main/templates/base.html): Template shell · Shared HTML layout for server-rendered pages · `templates/base.html`
- [home pages](https://github.com/diegofc17/sdg/blob/main/templates/home.html): Templates · Landing and dashboard pages · `templates/home.html`
- [auth pages](https://github.com/diegofc17/sdg/blob/main/templates/registration/login.html): Templates · Login and signup screens · `templates/registration/login.html`
- [doc pages](https://github.com/diegofc17/sdg/blob/main/templates/documents/list.html): Templates · Document and expediente workflows · `templates/documents/list.html`
- [audit page](https://github.com/diegofc17/sdg/blob/main/templates/audit/list.html): Template · Audit log listing UI · `templates/audit/list.html`

### Domain apps

Core business apps and their responsibilities

- [core views](https://github.com/diegofc17/sdg/blob/main/apps/core/views.py): Shell views · Landing and dashboard navigation · `apps/core/views.py`
- [core urls](https://github.com/diegofc17/sdg/blob/main/apps/core/urls.py): Route module · Core app routes · `apps/core/urls.py`
- [accounts](https://github.com/diegofc17/sdg/blob/main/apps/accounts/models.py): Identity app · User accounts, registration, and profile behavior · `apps/accounts/models.py`
- [auth views](https://github.com/diegofc17/sdg/blob/main/apps/accounts/views.py): Auth UI · Custom login and signup flows · `apps/accounts/views.py`
- [account forms](https://github.com/diegofc17/sdg/blob/main/apps/accounts/forms.py): Forms · Registration and account input forms · `apps/accounts/forms.py`
- [account signals](https://github.com/diegofc17/sdg/blob/main/apps/accounts/signals.py): Hooks · Post-save and profile setup behavior · `apps/accounts/signals.py`
- [account urls](https://github.com/diegofc17/sdg/blob/main/apps/accounts/urls.py): Route module · Accounts routes · `apps/accounts/urls.py`
- [documents](https://github.com/diegofc17/sdg/blob/main/apps/documents/models.py): Records app · Document lifecycle, expediente management, and TRD/TVD taxonomy · `apps/documents/models.py`
- [doc views](https://github.com/diegofc17/sdg/blob/main/apps/documents/views.py): Records UI · Create, list, detail, and expediente views · `apps/documents/views.py`
- [doc forms](https://github.com/diegofc17/sdg/blob/main/apps/documents/forms.py): Forms · Document and expediente input forms · `apps/documents/forms.py`
- [doc urls](https://github.com/diegofc17/sdg/blob/main/apps/documents/urls.py): Route module · Documents routes · `apps/documents/urls.py`
- [audit](https://github.com/diegofc17/sdg/blob/main/apps/audit/models.py): Traceability app · Audit logging and review views · `apps/audit/models.py`
- [audit views](https://github.com/diegofc17/sdg/blob/main/apps/audit/views.py): Audit UI · Audit listing and related screens · `apps/audit/views.py`
- [audit forms](https://github.com/diegofc17/sdg/blob/main/apps/audit/forms.py): Forms · Audit query or filter forms · `apps/audit/forms.py`
- [audit signals](https://github.com/diegofc17/sdg/blob/main/apps/audit/signals.py): Hooks · Automatic event capture for traceability · `apps/audit/signals.py`
- [audit utils](https://github.com/diegofc17/sdg/blob/main/apps/audit/utils.py): Helpers · Audit formatting and aggregation helpers · `apps/audit/utils.py`
- [audit urls](https://github.com/diegofc17/sdg/blob/main/apps/audit/urls.py): Route module · Audit routes · `apps/audit/urls.py`

### Operations

Back-office and import workflows

- [import TRD](https://github.com/diegofc17/sdg/blob/main/apps/documents/management/commands/import_trd.py): Management command · Offline import for TRD reference data · `apps/documents/management/commands/import_trd.py`
- [admin](https://github.com/diegofc17/sdg/blob/main/apps/documents/admin.py): Back office · Django admin surfaces for maintaining domain data · `apps/documents/admin.py`

## Connections

- manage.py → settings: loads · Management commands use project settings
- manage.py → root urls: starts app · Django runtime bootstraps root routing
- ASGI → settings: uses · ASGI deployment loads settings
- WSGI → settings: uses · WSGI deployment loads settings
- root urls → core urls: includes · Root router includes core routes
- root urls → account urls: includes · Root router includes account routes
- root urls → doc urls: includes · Root router includes document routes
- root urls → audit urls: includes · Root router includes audit routes
- core urls → core views: dispatches · Core routes render landing and dashboard pages
- core views → base layout: renders · Shared shell for core pages
- core views → home pages: renders · Home and dashboard pages
- account urls → auth views: dispatches · Account routes map to auth views
- auth views → account forms: uses · Login/signup flows rely on forms
- auth views → auth pages: renders · Authentication pages
- accounts → account signals: emits · User model events trigger account hooks
- account signals → audit: observes · Account-related events can be traced
- doc urls → doc views: dispatches · Document routes map to record views
- doc views → doc forms: uses · Create and edit workflows rely on forms
- doc views → doc pages: renders · Document and expediente pages
- documents → audit: emits · Document actions are captured for traceability
- audit urls → audit views: dispatches · Audit routes map to review screens
- audit views → audit forms: uses · Filtering and query controls
- audit views → audit utils: uses · Formatting and aggregation support
- audit views → audit page: renders · Audit list screen
- audit signals → audit: writes · Signals persist trace entries
- import TRD → documents: imports into · Loads reference taxonomy data used by documents
- admin → documents: manages · Back-office maintenance for document models
- admin → accounts: manages · Back-office maintenance for account models
- admin → audit: manages · Back-office review of audit models
- base layout → auth pages: extends · Shared layout used by auth pages
- base layout → doc pages: extends · Shared layout used by document pages
- base layout → audit page: extends · Shared layout used by audit pages
