# yous3ry/python_automated_dca architecture

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

- Interactive diagram: https://gitdiagram.com/yous3ry/python_automated_dca
- Repository: https://github.com/yous3ry/python_automated_dca

## Overview

This repository automates petroleum-well decline-curve analysis, from production-history acquisition through change detection, decline fitting, and forecasting. The principal workflow is the multiwell database run in `Compiled_Script.py`; `Python_DCA.py` also provides a sample-data, single-well analysis and plot. README documentation establishes the integrated database workflow and forecast export, while excerpts show the analysis steps and plotting. The R change-detection implementation is documented but not present in the supplied tree; connections not evidenced by excerpts or README are omitted.

Main entry points: [`Compiled_Script.py`](https://github.com/yous3ry/python_automated_dca/blob/main/Compiled_Script.py) (Multiwell runner), [`Python_DCA.py`](https://github.com/yous3ry/python_automated_dca/blob/main/Python_DCA.py) (Single-well analysis), [`Change_Detection.R`](https://github.com/yous3ry/python_automated_dca/blob/main/Change_Detection.R) (Change detection), [`DB_Connect.py`](https://github.com/yous3ry/python_automated_dca/blob/main/DB_Connect.py) (Database access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_acquisition["Data acquisition"]
  node_compiled["Multiwell runner<br/>[Compiled_Script.py]"]
  node_dbconnect["Database access<br/>[DB_Connect.py]"]
  node_samplecsv["Sample well data<br/>[Sample_Well.csv]"]
end

subgraph group_analysis["Well analysis"]
  node_singlewell["Single-well analysis<br/>[Python_DCA.py]"]
  node_changepoints["Change detection<br/>[Change_Detection.R]"]
  node_envcpt["EnvCpt"]
  node_stableperiod["Stable-period selection<br/>[Python_DCA.py]"]
  node_declinefit["Decline fitting<br/>[Python_DCA.py]"]
  node_rateforecast["Rate forecasting<br/>[Python_DCA.py]"]
end

subgraph group_outputs["Forecast outputs"]
  node_wellsummary["Well summaries<br/>[Compiled_Script.py]"]
  node_fieldforecast["Field forecast<br/>[Compiled_Script.py]"]
  node_plots["Forecast plots<br/>[Python_DCA.py]"]
end

node_operator(("Analyst"))
node_productiondb[("Production database")]

node_operator -->|"runs"| node_compiled
node_compiled -->|"reads well data"| node_dbconnect
node_dbconnect -->|"queries"| node_productiondb
node_operator -->|"runs"| node_singlewell
node_singlewell -->|"loads"| node_samplecsv
node_singlewell -->|"detects changes"| node_changepoints
node_changepoints -.->|"calls"| node_envcpt
node_singlewell -->|"selects period"| node_stableperiod
node_stableperiod -->|"provides history"| node_declinefit
node_declinefit -->|"provides parameters"| node_rateforecast
node_singlewell -->|"plots forecast"| node_plots
node_compiled -->|"summarizes wells"| node_wellsummary
node_compiled -->|"aggregates forecast"| node_fieldforecast
node_compiled -->|"detects changes"| node_changepoints
node_compiled -.->|"forecasts wells"| node_rateforecast

click node_compiled "https://github.com/yous3ry/python_automated_dca/blob/main/Compiled_Script.py"
click node_dbconnect "https://github.com/yous3ry/python_automated_dca/blob/main/DB_Connect.py"
click node_samplecsv "https://github.com/yous3ry/python_automated_dca/blob/main/Sample_Well.csv"
click node_singlewell "https://github.com/yous3ry/python_automated_dca/blob/main/Python_DCA.py"
click node_changepoints "https://github.com/yous3ry/python_automated_dca/blob/main/Change_Detection.R"
click node_stableperiod "https://github.com/yous3ry/python_automated_dca/blob/main/Python_DCA.py"
click node_declinefit "https://github.com/yous3ry/python_automated_dca/blob/main/Python_DCA.py"
click node_rateforecast "https://github.com/yous3ry/python_automated_dca/blob/main/Python_DCA.py"
click node_wellsummary "https://github.com/yous3ry/python_automated_dca/blob/main/Compiled_Script.py"
click node_fieldforecast "https://github.com/yous3ry/python_automated_dca/blob/main/Compiled_Script.py"
click node_plots "https://github.com/yous3ry/python_automated_dca/blob/main/Python_DCA.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_compiled,node_dbconnect,node_samplecsv toneBlue
class node_singlewell,node_changepoints,node_envcpt,node_stableperiod,node_declinefit,node_rateforecast,node_productiondb toneAmber
class node_wellsummary,node_fieldforecast,node_plots toneMint
class node_operator toneIndigo
```

## Components

### Data acquisition

- [Multiwell runner](https://github.com/yous3ry/python_automated_dca/blob/main/Compiled_Script.py): `Compiled_Script.py`
- [Database access](https://github.com/yous3ry/python_automated_dca/blob/main/DB_Connect.py): `DB_Connect.py`
- [Sample well data](https://github.com/yous3ry/python_automated_dca/blob/main/Sample_Well.csv): `Sample_Well.csv`

### Well analysis

- [Single-well analysis](https://github.com/yous3ry/python_automated_dca/blob/main/Python_DCA.py): `Python_DCA.py`
- [Change detection](https://github.com/yous3ry/python_automated_dca/blob/main/Change_Detection.R): `Change_Detection.R`
- **EnvCpt**
- [Stable-period selection](https://github.com/yous3ry/python_automated_dca/blob/main/Python_DCA.py): `Python_DCA.py`
- [Decline fitting](https://github.com/yous3ry/python_automated_dca/blob/main/Python_DCA.py): `Python_DCA.py`
- [Rate forecasting](https://github.com/yous3ry/python_automated_dca/blob/main/Python_DCA.py): `Python_DCA.py`

### Forecast outputs

- [Well summaries](https://github.com/yous3ry/python_automated_dca/blob/main/Compiled_Script.py): `Compiled_Script.py`
- [Field forecast](https://github.com/yous3ry/python_automated_dca/blob/main/Compiled_Script.py): `Compiled_Script.py`
- [Forecast plots](https://github.com/yous3ry/python_automated_dca/blob/main/Python_DCA.py): `Python_DCA.py`

### Other components

- **Analyst**
- **Production database**

## Connections

- Analyst → Multiwell runner: runs (evidence: `README.md`)
- Multiwell runner → Database access: reads well data (evidence: `README.md`)
- Database access → Production database: queries (evidence: `DB_Connect.py`)
- Analyst → Single-well analysis: runs (evidence: `README.md`)
- Single-well analysis → Sample well data: loads (evidence: `Python_DCA.py`)
- Single-well analysis → Change detection: detects changes (evidence: `README.md`)
- Change detection → EnvCpt: calls
- Single-well analysis → Stable-period selection: selects period (evidence: `Python_DCA.py`)
- Stable-period selection → Decline fitting: provides history (evidence: `Python_DCA.py`)
- Decline fitting → Rate forecasting: provides parameters (evidence: `Python_DCA.py`)
- Single-well analysis → Forecast plots: plots forecast (evidence: `Python_DCA.py`)
- Multiwell runner → Well summaries: summarizes wells (evidence: `Compiled_Script.py`)
- Multiwell runner → Field forecast: aggregates forecast (evidence: `Compiled_Script.py`)
- Multiwell runner → Change detection: detects changes (evidence: `README.md`)
- Multiwell runner → Rate forecasting: forecasts wells
