# mensiomar/application-de-gestion-de-stock architecture

> Architecture diagram of the GitHub repository mensiomar/application-de-gestion-de-stock, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mensiomar/application-de-gestion-de-stock
- Repository: https://github.com/mensiomar/application-de-gestion-de-stock

## Overview

##### Project type and purpose
- This is a standalone, monolithic C console application (“Stock-Manager”) designed to manage product inventory and keep an archive of daily and monthly stock movements.
- It provides a command‐line interface to add, view, modify, delete, and search products, and logs each operation into text files.

##### File structure
- principal.c: entry point, main loop, CLI menu, dispatches user commands.
- functions.c: implements the core operations (add, delete, modify, search, list, history).
- struct.h: defines the C structs representing a product record and a history record.
- stock.txt: persistent storage for current inventory records.
- historique.txt: persistent storage for chronological logs of stock movements.
- Other files are documentation and design sketches.

##### README for additional insights
- Project is decomposed into four logical parts: data storage, data structures, functions/procedures, and presentation (design of the interface).
- Emphasis on using file I/O (rename, remove) and simple text storage.

a. Main components
- Presentation Layer (CLI)
- Business Logic Layer (Functions/Procedures)
- Data Layer (File Storage)
- Data Model (C Structs)
b. Relationships & interactions
- User → CLI Menu (principal.c)
- CLI Menu → Business Logic Calls (functions.c)
- Business Logic → Data Model (load into memory, manipulate structs)
- Business Logic → File I/O (read/write/rename/remove stock.txt and historique.txt)
c. Architectural patterns & principles
- Layered/Modular: clear separation between presentation, logic, and persistence.
- Single executable, procedural modules.
- Stateless operations: each command loads data, processes, then writes back.
d. Key technologies
- C language, standard library for file I/O (fopen, fprintf, fscanf, rename, remove)
- Text files for persistent storage
- Simple build via gcc

##### Detail
- Module with its source file (e.g., Stock Operations Module [functions.c]).
- Edge cases (e.g., file rename/remove operations when deleting a record).
- Sequence: upon “delete product,” Business Logic reads stock.txt → removes entry → writes to temp file → renames temp → logs action to historique.txt.

## Diagram (Mermaid)

```mermaid
flowchart TD
    User("User"):::external
    subgraph "Presentation Layer"
        CLI["CLI Interface\n(principal.c)"]:::presentation
    end
    subgraph "Business Logic Layer"
        StockOps["Stock Operations Module\n(functions.c)"]:::logic
        HistOps["History Operations Module\n(functions.c)"]:::logic
    end
    subgraph "Data Model Layer"
        Model["Data Model (struct.h)"]:::model
    end
    subgraph "Data Storage Layer"
        StockFile["File Storage: stock.txt"]:::storage
        HistFile["File Storage: historique.txt"]:::storage
    end

    User -->|"interacts"| CLI
    CLI -->|"invokes add/modify/delete"| StockOps
    CLI -->|"invokes view/history"| HistOps
    StockOps -->|"uses structs"| Model
    HistOps -->|"uses structs"| Model
    StockOps -->|"load records / save record"| StockFile
    StockOps -->|"append log"| HistFile
    HistOps -->|"read logs"| HistFile

    click CLI "https://github.com/mensiomar/application-de-gestion-de-stock/blob/main/principal.c"
    click StockOps "https://github.com/mensiomar/application-de-gestion-de-stock/blob/main/functions.c"
    click HistOps "https://github.com/mensiomar/application-de-gestion-de-stock/blob/main/functions.c"
    click Model "https://github.com/mensiomar/application-de-gestion-de-stock/blob/main/struct.h"
    click StockFile "https://github.com/mensiomar/application-de-gestion-de-stock/blob/main/stock.txt"
    click HistFile "https://github.com/mensiomar/application-de-gestion-de-stock/blob/main/historique.txt"

    classDef presentation fill:#D0E8FF,stroke:#0366d6,stroke-width:1px;
    classDef logic fill:#E6F4EA,stroke:#22863A,stroke-width:1px;
    classDef model fill:#FFF5B1,stroke:#D4A72C,stroke-width:1px;
    classDef storage fill:#FBEFEF,stroke:#B31D28,stroke-width:1px;
    classDef external fill:#F0F0F0,stroke:#666666,stroke-width:1px,stroke-dasharray: 5 5;
```
