# rasulboboev111-dotcom/docuflowversion2 architecture

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

- Interactive diagram: https://gitdiagram.com/rasulboboev111-dotcom/docuflowversion2
- Repository: https://github.com/rasulboboev111-dotcom/docuflowversion2

## Overview

#### Purpose and Runtime

DocuFlow is a Django-based electronic document-management system for creating, editing, approving, signing, archiving, and verifying documents. It runs as a server-rendered web application with HTMX/Alpine-enhanced UI, PostgreSQL persistence, MinIO/S3 file storage, and OnlyOffice browser editing.

Primary Django entry points are `manage.py`, `config/settings.py`, `config/urls.py`, and deployment composition in `docker-compose.yml` / `Dockerfile`.

#### Application Routing and UI Boundary

The Django project routes requests into three domain apps: core administration and audit, document workflow, and reference registries. Server views render templates; HTMX partial templates support live filtering/table refreshes rather than a separate SPA API.

Key paths: `config/urls.py`, `core/urls.py`, `documents/urls.py`, `registry/urls.py`, `templates/base.html`.

#### Identity, Roles, and Audit

`core` owns users, role/permission evolution, administrative user management, dashboards, reporting, monitoring, and audit visibility. Role-based access is a control boundary for document actions and registry/audit access; signals likely record cross-cutting lifecycle events.

Key paths: `core/models.py`, `core/views.py`, `core/signals.py`, `templates/core/audit_list.html`.

#### Document Domain and Approval Workflow

`documents` is the system’s central domain. Its models define documents, templates/registries, version history, status, priority, sender, UUID, and content hash evolution. Views and forms handle create/edit/detail/list/archive flows, while services centralize document processing.

The intended control flow is a five-stage approval sequence: Равзанаи ягона → Муҳандис → Мудир → Муовин → Директор. Approval state gates progression and finalization.

Key paths: `documents/models.py`, `documents/views.py`, `documents/services.py`, `templates/documents/document_detail.html`.

#### File Storage, Integrity, and Archive

Document binaries are stored externally in MinIO via its S3-compatible interface, while PostgreSQL stores document metadata and workflow state. UUID and hash migrations indicate durable document identity and integrity verification. Archive presentation is a first-class lifecycle state, not merely deleted content.

Key paths: `documents/models.py`, `documents/migrations/0004_document_uuid.py`, `documents/migrations/0006_add_document_hash.py`, `templates/documents/archive_list.html`.

#### OnlyOffice Editing and Visual Signing

OnlyOffice integration is isolated in document-specific views and local editor configuration. Browser editing/preview flows bridge Django document records to an OnlyOffice Document Server. Signing produces role-specific visual marks: QR codes for the Director and stamps for other approvers; static OnlyOffice QR plugin assets support editor-side functionality.

Key paths: `documents/views_onlyoffice.py`, `config/onlyoffice_local.json`, `static/onlyoffice/plugins/qr_code/plugin.js`, `templates/documents/sign_document.html`.

#### Registry Subsystem

`registry` is a separate reference-data domain, currently centered on mobile-phone records and import/list/edit UI. It is permission-controlled independently enough to have dedicated migration changes and routes, and can support document-related lookup/registry workflows without coupling its models into document views.

Key paths: `registry/models.py`, `registry/views.py`, `registry/urls.py`, `templates/registry/phone_list.html`.

#### Infrastructure and Operations

Docker Compose coordinates the application and its required service dependencies, notably PostgreSQL, MinIO, and OnlyOffice. Django provides ASGI and WSGI entry points for production server selection. Seed commands provide initial users and documents for bootstrap environments.

Key paths: `docker-compose.yml`, `config/asgi.py`, `config/wsgi.py`, `core/management/commands/seed_users.py`, `documents/management/commands/seed_docs.py`.

Main entry points: [`documents/views.py`](https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/documents/views.py) (Document views and forms), [`config/urls.py`](https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/config/urls.py) (Project routing), [`core/views.py`](https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/core/views.py) (Core administration), [`registry/views.py`](https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/registry/views.py) (Reference registry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_django["Django application"]
  node_entry{{"Django entry points<br/>runtime<br/>[manage.py]"}}
  node_routing["Project routing<br/>[urls.py]"]
  node_ui["Server-rendered UI<br/>templates<br/>[base.html]"]
  node_core["Core administration<br/>Django app<br/>[views.py]"]
  node_identity["Roles and audit<br/>models and signals<br/>[models.py]"]
  node_registry["Reference registry<br/>Django app<br/>[views.py]"]
  node_seed_users["User bootstrap<br/>management command<br/>[seed_users.py]"]
end

subgraph group_documents["Document workflow"]
  node_document_views["Document views and forms<br/>Django app layer<br/>[views.py]"]
  node_document_models[("Document records<br/>domain models<br/>[models.py]")]
  node_workflow["Five-stage approval<br/>workflow service<br/>[services.py]"]
  node_archive["Archive lifecycle<br/>document UI<br/>[archive_list.html]"]
  node_signing["Visual signing<br/>signing UI<br/>[sign_document.html]"]
  node_onlyoffice_adapter["OnlyOffice integration<br/>editor views"]
  node_seed_docs["Document bootstrap<br/>management command<br/>[seed_docs.py]"]
end

subgraph group_integrations["External services"]
  node_postgres[("PostgreSQL<br/>metadata store<br/>[docker-compose.yml]")]
  node_minio[("MinIO / S3<br/>object storage<br/>[docker-compose.yml]")]
  node_onlyoffice["OnlyOffice Document Server<br/>browser editor<br/>[docker-compose.yml]"]
  node_compose{{"Container composition<br/>deployment<br/>[docker-compose.yml]"}}
end

node_entry -->|"starts"| node_routing
node_routing -->|"routes"| node_core
node_routing -->|"routes"| node_document_views
node_routing -->|"routes"| node_registry
node_core -->|"manages"| node_identity
node_identity -.->|"authorizes"| node_document_views
node_identity -.->|"authorizes"| node_registry
node_core -->|"renders"| node_ui
node_document_views -->|"renders"| node_ui
node_registry -->|"renders"| node_ui
node_document_views -->|"advances"| node_workflow
node_workflow -->|"updates state"| node_document_models
node_document_views -->|"reads and writes"| node_document_models
node_document_views -->|"presents"| node_archive
node_document_views -->|"initiates"| node_signing
node_signing -->|"finalizes approvals"| node_workflow
node_document_models -->|"persists metadata"| node_postgres
node_document_views -->|"stores binaries"| node_minio
node_document_views -->|"opens editor"| node_onlyoffice_adapter
node_onlyoffice_adapter -->|"integrates with"| node_onlyoffice
node_registry -->|"persists reference data"| node_postgres
node_compose -->|"runs"| node_postgres
node_compose -->|"runs"| node_minio
node_compose -->|"runs"| node_onlyoffice
node_seed_users -->|"initializes"| node_core
node_seed_docs -->|"initializes"| node_document_models

click node_entry "https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/manage.py"
click node_routing "https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/config/urls.py"
click node_ui "https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/templates/base.html"
click node_core "https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/core/views.py"
click node_identity "https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/core/models.py"
click node_registry "https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/registry/views.py"
click node_document_views "https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/documents/views.py"
click node_document_models "https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/documents/models.py"
click node_workflow "https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/documents/services.py"
click node_archive "https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/templates/documents/archive_list.html"
click node_signing "https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/templates/documents/sign_document.html"
click node_onlyoffice_adapter "https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/documents/views_onlyoffice.py"
click node_postgres "https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/docker-compose.yml"
click node_minio "https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/docker-compose.yml"
click node_onlyoffice "https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/docker-compose.yml"
click node_compose "https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/docker-compose.yml"
click node_seed_users "https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/core/management/commands/seed_users.py"
click node_seed_docs "https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/documents/management/commands/seed_docs.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_entry,node_routing,node_ui,node_core,node_identity,node_registry,node_seed_users toneBlue
class node_document_views,node_document_models,node_workflow,node_archive,node_signing,node_onlyoffice_adapter,node_seed_docs toneAmber
class node_postgres,node_minio,node_onlyoffice,node_compose toneMint
```

## Components

### Django application

- [Django entry points](https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/manage.py): runtime · Management and ASGI/WSGI application entry points. · `manage.py`
- [Project routing](https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/config/urls.py): routing · `config/urls.py`
- [Server-rendered UI](https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/templates/base.html): templates · HTMX partials augment Django-rendered pages. · `templates/base.html`
- [Core administration](https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/core/views.py): Django app · Owns users, roles, dashboards, reporting, and audit visibility. · `core/views.py`
- [Roles and audit](https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/core/models.py): models and signals · Role controls gate domain actions and lifecycle events are recorded. · `core/models.py`
- [Reference registry](https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/registry/views.py): Django app · Permission-controlled mobile-phone reference data and UI. · `registry/views.py`
- [User bootstrap](https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/core/management/commands/seed_users.py): management command · `core/management/commands/seed_users.py`

### Document workflow

- [Document views and forms](https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/documents/views.py): Django app layer · Handles create, edit, detail, list, and archive flows. · `documents/views.py`
- [Document records](https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/documents/models.py): domain models · Document metadata, versions, status, identity, and hash state. · `documents/models.py`
- [Five-stage approval](https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/documents/services.py): workflow service · Равзанаи ягона → Муҳандис → Мудир → Муовин → Директор. · `documents/services.py`
- [Archive lifecycle](https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/templates/documents/archive_list.html): document UI · Archived documents remain a first-class presentation state. · `templates/documents/archive_list.html`
- [Visual signing](https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/templates/documents/sign_document.html): signing UI · Director uses QR marks; other approvers use stamps. · `templates/documents/sign_document.html`
- [OnlyOffice integration](https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/documents/views_onlyoffice.py): editor views · Bridges document records to browser editing and preview. · `documents/views_onlyoffice.py`
- [Document bootstrap](https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/documents/management/commands/seed_docs.py): management command · `documents/management/commands/seed_docs.py`

### External services

- [PostgreSQL](https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/docker-compose.yml): metadata store · Persists document metadata, workflow state, users, and registries. · `docker-compose.yml`
- [MinIO / S3](https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/docker-compose.yml): object storage · Stores document binaries externally. · `docker-compose.yml`
- [OnlyOffice Document Server](https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/docker-compose.yml): browser editor · `docker-compose.yml`
- [Container composition](https://github.com/rasulboboev111-dotcom/docuflowversion2/blob/master/docker-compose.yml): deployment · Coordinates application and required dependencies. · `docker-compose.yml`

## Connections

- Django entry points → Project routing: starts
- Project routing → Core administration: routes
- Project routing → Document views and forms: routes
- Project routing → Reference registry: routes
- Core administration → Roles and audit: manages
- Roles and audit → Document views and forms: authorizes
- Roles and audit → Reference registry: authorizes
- Core administration → Server-rendered UI: renders
- Document views and forms → Server-rendered UI: renders
- Reference registry → Server-rendered UI: renders
- Document views and forms → Five-stage approval: advances
- Five-stage approval → Document records: updates state
- Document views and forms → Document records: reads and writes
- Document views and forms → Archive lifecycle: presents
- Document views and forms → Visual signing: initiates
- Visual signing → Five-stage approval: finalizes approvals
- Document records → PostgreSQL: persists metadata
- Document views and forms → MinIO / S3: stores binaries
- Document views and forms → OnlyOffice integration: opens editor
- OnlyOffice integration → OnlyOffice Document Server: integrates with
- Reference registry → PostgreSQL: persists reference data
- Container composition → PostgreSQL: runs
- Container composition → MinIO / S3: runs
- Container composition → OnlyOffice Document Server: runs
- User bootstrap → Core administration: initializes
- Document bootstrap → Document records: initializes
