# sam77g/tde_estrutura architecture

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

- Interactive diagram: https://gitdiagram.com/sam77g/tde_estrutura
- Repository: https://github.com/sam77g/tde_estrutura

## Overview

PharmaERP is an in-memory, terminal pharmacy manager. The main workflow begins at the CLI menu and branches into medicine management, prioritized replenishment, and movement history/undo. Shared lists, stack, and deque hold state; validation and ID generation support operations. README capabilities such as filtering/sorting, replenishment cancellation, and DEBUG are included where documented, but some exact call paths are not visible in the excerpts. No persistence or external service is shown.

Main entry points: [`tde/reposicao.py`](https://github.com/sam77g/tde_estrutura/blob/main/tde/reposicao.py) (Request management), [`tde/medicamentos.py`](https://github.com/sam77g/tde_estrutura/blob/main/tde/medicamentos.py) (Medicine CRUD), [`tde/main.py`](https://github.com/sam77g/tde_estrutura/blob/main/tde/main.py) (Main menu), [`tde/relatorios.py`](https://github.com/sam77g/tde_estrutura/blob/main/tde/relatorios.py) (History and undo)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["Terminal workflow"]
  node_main["Main menu<br/>[main.py]"]
  node_terminal["Terminal"]
end

subgraph group_meds["Medicine management"]
  node_medicine_menu["Medicine menu<br/>[medicamentos.py]"]
  node_medicine_crud["Medicine CRUD<br/>[medicamentos.py]"]
  node_medicine_queries["Search and sorting<br/>[medicamentos.py]"]
end

subgraph group_stock["Stock and history"]
  node_stock_ops["Stock movement support<br/>[estoque.py]"]
  node_ids["ID generation<br/>[estoque.py]"]
  node_history_menu["History menu<br/>[relatorios.py]"]
  node_history_ops["History and undo<br/>[relatorios.py]"]
end

subgraph group_repos["Replenishment"]
  node_repo_menu["Replenishment menu<br/>[reposicao.py]"]
  node_repo_ops["Request management<br/>[reposicao.py]"]
  node_priority["Criticality priority<br/>[reposicao.py]"]
end

subgraph group_core["Shared state and support"]
  node_validation["Input validation<br/>[validar.py]"]
  node_medicine_list[("Medicine list<br/>[estruturas.py]")]
  node_history_stack[("Movement history<br/>[estruturas.py]")]
  node_repo_queue["Request queue<br/>[estruturas.py]"]
  node_debug["Structure DEBUG<br/>[estruturas.py]"]
end

node_user(("Pharmacy operator"))

node_user -->|"chooses menu"| node_main
node_main -->|"reads choice"| node_validation
node_main -->|"opens"| node_medicine_menu
node_main -->|"opens"| node_repo_menu
node_main -->|"opens"| node_history_menu
node_medicine_menu -->|"dispatches"| node_medicine_crud
node_medicine_crud -->|"validates with"| node_validation
node_medicine_crud -->|"updates"| node_medicine_list
node_medicine_crud -->|"generates IDs"| node_ids
node_medicine_crud -->|"records entry"| node_history_ops
node_medicine_crud -->|"creates or cancels"| node_repo_ops
node_medicine_menu -->|"dispatches"| node_medicine_queries
node_medicine_menu -->|"prompts and displays"| node_terminal
node_repo_menu -->|"dispatches"| node_repo_ops
node_repo_ops -->|"checks quantity"| node_validation
node_repo_ops -->|"reads and updates"| node_repo_queue
node_repo_ops -->|"updates stock"| node_medicine_list
node_repo_ops -->|"inserts by criticality"| node_priority
node_repo_ops -->|"generates request IDs"| node_ids
node_history_menu -->|"dispatches"| node_history_ops
node_history_ops -->|"pushes and pops"| node_history_stack
node_history_ops -->|"reverses changes"| node_medicine_list
node_history_ops -->|"cancels or recreates"| node_repo_ops
node_history_menu -->|"displays history"| node_terminal
node_user -.->|"views structures"| node_debug

click node_main "https://github.com/sam77g/tde_estrutura/blob/main/tde/main.py"
click node_medicine_menu "https://github.com/sam77g/tde_estrutura/blob/main/tde/medicamentos.py"
click node_medicine_crud "https://github.com/sam77g/tde_estrutura/blob/main/tde/medicamentos.py"
click node_medicine_queries "https://github.com/sam77g/tde_estrutura/blob/main/tde/medicamentos.py"
click node_validation "https://github.com/sam77g/tde_estrutura/blob/main/tde/validar.py"
click node_medicine_list "https://github.com/sam77g/tde_estrutura/blob/main/tde/estruturas.py"
click node_stock_ops "https://github.com/sam77g/tde_estrutura/blob/main/tde/estoque.py"
click node_ids "https://github.com/sam77g/tde_estrutura/blob/main/tde/estoque.py"
click node_history_menu "https://github.com/sam77g/tde_estrutura/blob/main/tde/relatorios.py"
click node_history_ops "https://github.com/sam77g/tde_estrutura/blob/main/tde/relatorios.py"
click node_history_stack "https://github.com/sam77g/tde_estrutura/blob/main/tde/estruturas.py"
click node_repo_menu "https://github.com/sam77g/tde_estrutura/blob/main/tde/reposicao.py"
click node_repo_ops "https://github.com/sam77g/tde_estrutura/blob/main/tde/reposicao.py"
click node_priority "https://github.com/sam77g/tde_estrutura/blob/main/tde/reposicao.py"
click node_repo_queue "https://github.com/sam77g/tde_estrutura/blob/main/tde/estruturas.py"
click node_debug "https://github.com/sam77g/tde_estrutura/blob/main/tde/estruturas.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_main,node_terminal toneBlue
class node_medicine_menu,node_medicine_crud,node_medicine_queries toneAmber
class node_stock_ops,node_ids,node_history_menu,node_history_ops toneMint
class node_repo_menu,node_repo_ops,node_priority toneRose
class node_validation,node_medicine_list,node_history_stack,node_repo_queue,node_debug,node_user toneIndigo
```

## Components

### Terminal workflow

- [Main menu](https://github.com/sam77g/tde_estrutura/blob/main/tde/main.py): `tde/main.py`
- **Terminal**

### Medicine management

- [Medicine menu](https://github.com/sam77g/tde_estrutura/blob/main/tde/medicamentos.py): `tde/medicamentos.py`
- [Medicine CRUD](https://github.com/sam77g/tde_estrutura/blob/main/tde/medicamentos.py): `tde/medicamentos.py`
- [Search and sorting](https://github.com/sam77g/tde_estrutura/blob/main/tde/medicamentos.py): `tde/medicamentos.py`

### Stock and history

- [Stock movement support](https://github.com/sam77g/tde_estrutura/blob/main/tde/estoque.py): `tde/estoque.py`
- [ID generation](https://github.com/sam77g/tde_estrutura/blob/main/tde/estoque.py): `tde/estoque.py`
- [History menu](https://github.com/sam77g/tde_estrutura/blob/main/tde/relatorios.py): `tde/relatorios.py`
- [History and undo](https://github.com/sam77g/tde_estrutura/blob/main/tde/relatorios.py): `tde/relatorios.py`

### Replenishment

- [Replenishment menu](https://github.com/sam77g/tde_estrutura/blob/main/tde/reposicao.py): `tde/reposicao.py`
- [Request management](https://github.com/sam77g/tde_estrutura/blob/main/tde/reposicao.py): `tde/reposicao.py`
- [Criticality priority](https://github.com/sam77g/tde_estrutura/blob/main/tde/reposicao.py): `tde/reposicao.py`

### Shared state and support

- [Input validation](https://github.com/sam77g/tde_estrutura/blob/main/tde/validar.py): `tde/validar.py`
- [Medicine list](https://github.com/sam77g/tde_estrutura/blob/main/tde/estruturas.py): `tde/estruturas.py`
- [Movement history](https://github.com/sam77g/tde_estrutura/blob/main/tde/estruturas.py): `tde/estruturas.py`
- [Request queue](https://github.com/sam77g/tde_estrutura/blob/main/tde/estruturas.py): `tde/estruturas.py`
- [Structure DEBUG](https://github.com/sam77g/tde_estrutura/blob/main/tde/estruturas.py): `tde/estruturas.py`

### Other components

- **Pharmacy operator**

## Connections

- Pharmacy operator → Main menu: chooses menu (evidence: `tde/main.py`)
- Main menu → Input validation: reads choice (evidence: `tde/main.py`)
- Main menu → Medicine menu: opens (evidence: `tde/main.py`)
- Main menu → Replenishment menu: opens (evidence: `tde/main.py`)
- Main menu → History menu: opens (evidence: `tde/main.py`)
- Medicine menu → Medicine CRUD: dispatches (evidence: `tde/medicamentos.py`)
- Medicine CRUD → Input validation: validates with (evidence: `tde/medicamentos.py`)
- Medicine CRUD → Medicine list: updates (evidence: `tde/medicamentos.py`)
- Medicine CRUD → ID generation: generates IDs (evidence: `tde/medicamentos.py`)
- Medicine CRUD → History and undo: records entry (evidence: `tde/medicamentos.py`)
- Medicine CRUD → Request management: creates or cancels (evidence: `tde/medicamentos.py`)
- Medicine menu → Search and sorting: dispatches (evidence: `tde/medicamentos.py`)
- Medicine menu → Terminal: prompts and displays (evidence: `tde/medicamentos.py`)
- Replenishment menu → Request management: dispatches (evidence: `tde/reposicao.py`)
- Request management → Input validation: checks quantity (evidence: `tde/reposicao.py`)
- Request management → Request queue: reads and updates (evidence: `tde/reposicao.py`)
- Request management → Medicine list: updates stock (evidence: `tde/reposicao.py`)
- Request management → Criticality priority: inserts by criticality (evidence: `tde/reposicao.py`)
- Request management → ID generation: generates request IDs (evidence: `tde/reposicao.py`)
- History menu → History and undo: dispatches (evidence: `tde/relatorios.py`)
- History and undo → Movement history: pushes and pops (evidence: `tde/relatorios.py`)
- History and undo → Medicine list: reverses changes (evidence: `tde/relatorios.py`)
- History and undo → Request management: cancels or recreates (evidence: `tde/relatorios.py`)
- History menu → Terminal: displays history (evidence: `tde/relatorios.py`)
- Pharmacy operator → Structure DEBUG: views structures (evidence: `README.md`)
