# hp-fort/stock_magasin architecture

> Architecture diagram of the GitHub repository hp-fort/stock_magasin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hp-fort/stock_magasin
- Repository: https://github.com/hp-fort/stock_magasin

## Overview

##### Project type and purpose
- This is a small Python-based stock management tool ("stock_magasin") intended to run locally to track and update store inventory.
- It follows a simple layered approach: a presentation/entry script, a business-logic layer, and a data-access layer that persists to an embedded SQLite database.

##### File structure
- Top-level scripts:
- main.py – likely the application entry point / user interface (CLI or simple menu).
- gestion.py – contains core business logic (adding, removing, querying stock).
- Data directory:
- database_handler.py – encapsulates all database operations (opening connections, executing queries).
- stock.db – the SQLite database file that stores inventory tables.
- Metadata/config:
- __pycache__/ – compiled bytecode (omit).
- README.md – high-level description.

##### README for additional insights
- The README briefly states the system’s goal: “systeme pour gerer un stock de magasin.”
- A demonstration video link suggests a user-facing console or GUI.

a. Main components:
- User Interface (CLI/Menu in main.py)
- Business Logic Layer (gestion.py)
- Data Access Layer (Data/database_handler.py)
- SQLite Database (Data/stock.db)
b. Relationships and interactions:
- UI → calls functions in Business Logic → calls Data Access → executes SQL on SQLite file.
- Data Access returns query results or status codes back up to Business Logic → UI.
c. Architectural patterns/design principles:
- 3-tier separation (UI, Logic, Data).
- Single Responsibility: each module has one clear role.
- Encapsulation of database details in a separate handler.
d. Key technologies:
- Python 3.x
- SQLite (via sqlite3 in database_handler.py)

##### Diagramming recommendations
- Rectangles for modules (main.py, gestion.py, database_handler.py)
- main.py → gestion.py (calls)
- gestion.py → database_handler.py (data operations)
- database_handler.py → stock.db (SQL execution)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Actors
    User["User"]:::actor

    %% Presentation Layer
    subgraph "Presentation Layer"
        Main["main.py"]:::ui
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        Logic["gestion.py"]:::logic
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        DBHandler["database_handler.py"]:::dataaccess
    end

    %% Data Layer
    subgraph "Data Layer"
        StockDB[(stock.db)]:::db
    end

    %% Connections - Requests
    User -->|"starts application"| Main
    Main -->|"calls business logic"| Logic
    Logic -->|"performs data operation"| DBHandler
    DBHandler -->|"executes SQL"| StockDB

    %% Connections - Responses
    StockDB -->|"query result"| DBHandler
    DBHandler -->|"data/status"| Logic
    Logic -->|"result"| Main
    Main -->|"output to user"| User

    %% Click Events
    click Main "https://github.com/hp-fort/stock_magasin/blob/main/main.py"
    click Logic "https://github.com/hp-fort/stock_magasin/blob/main/gestion.py"
    click DBHandler "https://github.com/hp-fort/stock_magasin/blob/main/Data/database_handler.py"
    click StockDB "https://github.com/hp-fort/stock_magasin/blob/main/Data/stock.db"

    %% Styles
    classDef actor fill:#D5D8DC,stroke:#34495E,color:#34495E,stroke-width:2px
    classDef ui fill:#AED6F1,stroke:#1B4F72,color:#1B4F72,stroke-width:2px
    classDef logic fill:#A9DFBF,stroke:#145A32,color:#145A32,stroke-width:2px
    classDef dataaccess fill:#F9E79F,stroke:#7D6608,color:#7D6608,stroke-width:2px
    classDef db fill:#F5B7B1,stroke:#922B21,color:#922B21,stroke-width:2px,stroke-dasharray: 5 5
```
