# rauaan/kmg-crud-app architecture

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

- Interactive diagram: https://gitdiagram.com/rauaan/kmg-crud-app
- Repository: https://github.com/rauaan/kmg-crud-app

## Overview

This Flask application manages oil-company operations: users sign in, maintain company, employee, and well records, and create daily production reports. Report routes also import and export Excel workbooks; dashboards aggregate production and well data into KPI and chart views. SQLAlchemy models define the persisted domain, while route handlers own database operations and web responses. The graph covers the sampled route behavior and documented model capabilities; some route implementations and templates were not sampled, so their detailed links are omitted.

Main entry points: [`app/__init__.py`](https://github.com/rauaan/kmg-crud-app/blob/main/app/__init__.py) (App factory), [`app/models.py`](https://github.com/rauaan/kmg-crud-app/blob/main/app/models.py) (Domain models), [`app/routes/auth.py`](https://github.com/rauaan/kmg-crud-app/blob/main/app/routes/auth.py) (Authentication), [`app/routes/daily_productions.py`](https://github.com/rauaan/kmg-crud-app/blob/main/app/routes/daily_productions.py) (Production reports)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_factory["App factory<br/>[__init__.py]"]
  node_extensions["Flask extensions<br/>[extensions.py]"]
  node_auth["Authentication<br/>[auth.py]"]
  node_forms["Input forms<br/>[forms.py]"]
  node_templates["Page templates"]
end

subgraph group_domain["Domain records"]
  node_company_routes["Company management<br/>[companies.py]"]
  node_user_routes["Employee management<br/>[users.py]"]
  node_well_routes["Well management<br/>[wells.py]"]
  node_models["Domain models<br/>[models.py]"]
  node_database[("Relational database")]
end

subgraph group_production["Production workflow"]
  node_report_routes["Production reports"]
end

subgraph group_analytics["Analytics and setup"]
  node_dashboard["Production dashboard<br/>[dashboards.py]"]
  node_seed["Sample data command<br/>[seed.py]"]
end

node_operator(("Operator"))

node_operator -->|"signs in"| node_auth
node_operator -->|"manages companies"| node_company_routes
node_operator -->|"manages employees"| node_user_routes
node_operator -->|"manages wells"| node_well_routes
node_operator -->|"manages reports"| node_report_routes
node_operator -->|"views metrics"| node_dashboard
node_factory -->|"initializes"| node_extensions
node_factory -->|"registers routes"| node_auth
node_factory -->|"registers routes"| node_company_routes
node_factory -->|"registers routes"| node_user_routes
node_factory -->|"registers routes"| node_well_routes
node_factory -->|"registers routes"| node_report_routes
node_factory -->|"registers routes"| node_dashboard
node_factory -->|"registers command"| node_seed
node_auth -->|"validates input"| node_forms
node_auth -->|"queries accounts"| node_models
node_auth -->|"hashes passwords"| node_extensions
node_company_routes -->|"reads and writes"| node_models
node_user_routes -->|"reads and writes"| node_models
node_well_routes -->|"reads and writes"| node_models
node_report_routes -->|"validates reports"| node_forms
node_report_routes -->|"reads and writes"| node_models
node_report_routes -->|"renders pages"| node_templates
node_dashboard -->|"queries aggregates"| node_models
node_dashboard -->|"renders metrics"| node_templates
node_company_routes -->|"renders pages"| node_templates
node_user_routes -->|"renders pages"| node_templates
node_well_routes -->|"renders pages"| node_templates
node_models -->|"defines tables"| node_database
node_seed -->|"creates sample records"| node_models
node_seed -->|"commits records"| node_database

click node_factory "https://github.com/rauaan/kmg-crud-app/blob/main/app/__init__.py"
click node_extensions "https://github.com/rauaan/kmg-crud-app/blob/main/app/extensions.py"
click node_auth "https://github.com/rauaan/kmg-crud-app/blob/main/app/routes/auth.py"
click node_forms "https://github.com/rauaan/kmg-crud-app/blob/main/app/forms.py"
click node_company_routes "https://github.com/rauaan/kmg-crud-app/blob/main/app/routes/companies.py"
click node_user_routes "https://github.com/rauaan/kmg-crud-app/blob/main/app/routes/users.py"
click node_well_routes "https://github.com/rauaan/kmg-crud-app/blob/main/app/routes/wells.py"
click node_report_routes "https://github.com/rauaan/kmg-crud-app/blob/main/app/routes/daily_productions.py"
click node_models "https://github.com/rauaan/kmg-crud-app/blob/main/app/models.py"
click node_dashboard "https://github.com/rauaan/kmg-crud-app/blob/main/app/routes/dashboards.py"
click node_templates "https://github.com/rauaan/kmg-crud-app/tree/main/app/templates"
click node_seed "https://github.com/rauaan/kmg-crud-app/blob/main/app/seed.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_factory,node_extensions,node_auth,node_forms,node_templates toneBlue
class node_company_routes,node_user_routes,node_well_routes,node_models,node_database toneAmber
class node_report_routes toneMint
class node_dashboard,node_seed toneRose
class node_operator toneIndigo
```

## Components

### Web application

- [App factory](https://github.com/rauaan/kmg-crud-app/blob/main/app/__init__.py): `app/__init__.py`
- [Flask extensions](https://github.com/rauaan/kmg-crud-app/blob/main/app/extensions.py): `app/extensions.py`
- [Authentication](https://github.com/rauaan/kmg-crud-app/blob/main/app/routes/auth.py): `app/routes/auth.py`
- [Input forms](https://github.com/rauaan/kmg-crud-app/blob/main/app/forms.py): `app/forms.py`
- [Page templates](https://github.com/rauaan/kmg-crud-app/tree/main/app/templates): `app/templates`

### Domain records

- [Company management](https://github.com/rauaan/kmg-crud-app/blob/main/app/routes/companies.py): `app/routes/companies.py`
- [Employee management](https://github.com/rauaan/kmg-crud-app/blob/main/app/routes/users.py): `app/routes/users.py`
- [Well management](https://github.com/rauaan/kmg-crud-app/blob/main/app/routes/wells.py): `app/routes/wells.py`
- [Domain models](https://github.com/rauaan/kmg-crud-app/blob/main/app/models.py): `app/models.py`
- **Relational database**

### Production workflow

- [Production reports](https://github.com/rauaan/kmg-crud-app/blob/main/app/routes/daily_productions.py): `app/routes/daily_productions.py`

### Analytics and setup

- [Production dashboard](https://github.com/rauaan/kmg-crud-app/blob/main/app/routes/dashboards.py): `app/routes/dashboards.py`
- [Sample data command](https://github.com/rauaan/kmg-crud-app/blob/main/app/seed.py): `app/seed.py`

### Other components

- **Operator**

## Connections

- Operator → Authentication: signs in (evidence: `app/routes/auth.py`)
- Operator → Company management: manages companies (evidence: `app/routes/companies.py`)
- Operator → Employee management: manages employees (evidence: `app/routes/users.py`)
- Operator → Well management: manages wells (evidence: `app/routes/wells.py`)
- Operator → Production reports: manages reports (evidence: `app/routes/daily_productions.py`)
- Operator → Production dashboard: views metrics (evidence: `app/routes/dashboards.py`)
- App factory → Flask extensions: initializes (evidence: `app/__init__.py`)
- App factory → Authentication: registers routes (evidence: `app/__init__.py`)
- App factory → Company management: registers routes (evidence: `app/__init__.py`)
- App factory → Employee management: registers routes (evidence: `app/__init__.py`)
- App factory → Well management: registers routes (evidence: `app/__init__.py`)
- App factory → Production reports: registers routes (evidence: `app/__init__.py`)
- App factory → Production dashboard: registers routes (evidence: `app/__init__.py`)
- App factory → Sample data command: registers command (evidence: `app/__init__.py`)
- Authentication → Input forms: validates input (evidence: `app/routes/auth.py`)
- Authentication → Domain models: queries accounts (evidence: `app/routes/auth.py`)
- Authentication → Flask extensions: hashes passwords (evidence: `app/routes/auth.py`)
- Company management → Domain models: reads and writes (evidence: `app/routes/companies.py`)
- Employee management → Domain models: reads and writes (evidence: `app/routes/users.py`)
- Well management → Domain models: reads and writes (evidence: `app/routes/wells.py`)
- Production reports → Input forms: validates reports (evidence: `app/routes/daily_productions.py`)
- Production reports → Domain models: reads and writes (evidence: `app/routes/daily_productions.py`)
- Production reports → Page templates: renders pages (evidence: `app/routes/daily_productions.py`)
- Production dashboard → Domain models: queries aggregates (evidence: `app/routes/dashboards.py`)
- Production dashboard → Page templates: renders metrics (evidence: `app/routes/dashboards.py`)
- Company management → Page templates: renders pages (evidence: `app/routes/companies.py`)
- Employee management → Page templates: renders pages (evidence: `app/routes/users.py`)
- Well management → Page templates: renders pages (evidence: `app/routes/wells.py`)
- Domain models → Relational database: defines tables (evidence: `app/models.py`)
- Sample data command → Domain models: creates sample records (evidence: `app/seed.py`)
- Sample data command → Relational database: commits records (evidence: `app/seed.py`)
