# solena8/analyse_des_ventes architecture

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

- Interactive diagram: https://gitdiagram.com/solena8/analyse_des_ventes
- Repository: https://github.com/solena8/analyse_des_ventes

## Overview

##### Project Type and Purpose
- The Sales Analysis System is a full-stack data processing application designed for sales data ingestion, analysis, and visualization.
- The README clearly outlines two main services: a Script Execution Service (Python) and a Database Service (SQLite).

##### Analyzing the File Structure
- Top-level directories such as “data”, “docs”, “dataviz”, “scripts”, and “models” indicate distinct roles:
- “data”: Contains the raw CSV files to be analyzed.
- “dataviz”: Stores visualization outputs (PNG files).
- “scripts”: Contains core Python modules for data import, analysis, visualization, and database connection.
- “models”: Implements the database models defining both persistent data (products, stores, sales) and analysis result tables (employee sales ratios, monthly product sales, product sales by store).
- Configuration files like Dockerfile, docker-compose.yml, and requirements.txt reveal containerized deployment and dependency management practices.

##### Key Components to be Highlighted
a. Script Execution Service (Python):
- Data Import Module (using scripts/data_import.py)
- Data Analysis Module (using scripts/data_analysis.py)
- Data Visualization Module (using scripts/data_visualization.py)
- Database Connection / Setup Module (using scripts/database.py)
- Underlying Docker setup defined by Dockerfile (indicating Python 3.12 on a slim Debian image)
b. Database Service (SQLite):
- Persistent storage for import and analysis results
- Utilizes the keinos/sqlite3 container image
- Includes multiple tables as defined by the models (Products, Stores, Sales, and various analysis tables)

##### Relationships & Interactions
- CSV data from the “data” directory is imported by the Data Import Module.
- Processed data is then stored into the SQLite database through the Database Connection Module.
- The Data Analysis Module reads from the database, performs computations, and writes analysis results back.
- The Data Visualization Module pulls insights (analysis data) from the database to create visualizations, which are stored in the “dataviz” directory.
- The Docker Compose file orchestrates these services as separate containers while ensuring they can communicate.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Clear distinction between import, analysis, and visualization functions.
- Two-Service Architecture: Encapsulation of the business logic in one container and the persistence layer as a separate service.
- Modular Design: The “scripts” and “models” directories reflect a modular codebase that allows adding new functionalities or analyses easily (as described in the README under “Adding New Analyses”).

##### Final Touches
- Component is clearly labeled with its role (e.g., “Data Import Module”).
- Integration points like Docker Compose which binds these services together.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Data and Artifacts
    CSV["CSV Data (data/)"]:::external
    VizOutput["Visualization Output (dataviz/)"]:::external
    Docs["Documentation (docs/)"]:::external
    Container["Containerization Setup\n(Dockerfile, docker-compose.yml)"]:::container
    DockerCompose["Docker Compose\n(Orchestrator)"]:::container

    %% Script Execution Service
    subgraph "Script Execution Service (Python)"
        direction TB
        DIP["Data Import Module"]:::module
        DAN["Data Analysis Module"]:::module
        DVZ["Data Visualization Module"]:::module
        DBC["Database Connection/Setup Module"]:::module
        NotePython["Python 3.12 on Debian Slim"]:::external
    end

    %% Database Service
    subgraph "Database Service (SQLite)"
        direction TB
        DB["SQLite Database"]:::db
        subgraph "Database Tables"
            direction TB
            Prod["Products Table"]
            Stor["Stores Table"]
            Sale["Sales Table"]
            ESales["Employee Sales Ratios"]
            MProd["Monthly Product Sales"]
            PSale["Product Sales By Store"]
        end
    end

    %% Relationships
    CSV -->|"import"| DIP
    DIP -->|"writes to"| DBC
    DBC -->|"stores data"| DB

    DB -->|"read/write"| DAN
    DAN -->|"updates"| DB

    DB -->|"provides data"| DVZ
    DVZ -->|"exports visuals"| VizOutput
    
    Docs ---|"references"| NotePython

    %% Docker Compose orchestrates the services
    Container --> DockerCompose
    DockerCompose -->|"orchestrates"| DIP
    DockerCompose -->|"orchestrates"| DBC
    DockerCompose -->|"orchestrates"| DAN
    DockerCompose -->|"orchestrates"| DVZ
    DockerCompose -->|"orchestrates"| DB

    %% Relationships within Database Tables
    DB --- Prod
    DB --- Stor
    DB --- Sale
    DB --- ESales
    DB --- MProd
    DB --- PSale

    %% Click Events
    click DIP "https://github.com/solena8/analyse_des_ventes/blob/main/scripts/data_import.py"
    click DAN "https://github.com/solena8/analyse_des_ventes/blob/main/scripts/data_analysis.py"
    click DVZ "https://github.com/solena8/analyse_des_ventes/blob/main/scripts/data_visualization.py"
    click DBC "https://github.com/solena8/analyse_des_ventes/blob/main/scripts/database.py"
    click Prod "https://github.com/solena8/analyse_des_ventes/blob/main/models/products.py"
    click Stor "https://github.com/solena8/analyse_des_ventes/blob/main/models/stores.py"
    click Sale "https://github.com/solena8/analyse_des_ventes/blob/main/models/sales.py"
    click ESales "https://github.com/solena8/analyse_des_ventes/blob/main/models/employee_sales_ratios.py"
    click MProd "https://github.com/solena8/analyse_des_ventes/blob/main/models/monthly_product_sales.py"
    click PSale "https://github.com/solena8/analyse_des_ventes/blob/main/models/product_sales_by_store.py"
    click Docs "https://github.com/solena8/analyse_des_ventes/tree/main/docs/"
    click CSV "https://github.com/solena8/analyse_des_ventes/tree/main/data/"
    click VizOutput "https://github.com/solena8/analyse_des_ventes/tree/main/dataviz/"
    click Container "https://github.com/solena8/analyse_des_ventes/tree/main/Dockerfile"
    click DockerCompose "https://github.com/solena8/analyse_des_ventes/blob/main/docker-compose.yml"

    %% Styles
    classDef service fill:#F9E79F,stroke:#997300,stroke-width:2px;
    classDef module fill:#AED6F1,stroke:#2471A3,stroke-width:2px;
    classDef db fill:#A9DFBF,stroke:#229954,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef container fill:#D7BDE2,stroke:#8E44AD,stroke-width:2px;
```
