# ansh2709/emotion-classification architecture

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

- Interactive diagram: https://gitdiagram.com/ansh2709/emotion-classification
- Repository: https://github.com/ansh2709/emotion-classification

## Overview

##### Project type and purpose
- This is a full-stack machine-learning application for speech emotion recognition.
- It provides:
- Jupyter notebooks for training (DNN, XGBoost, RF)
- A CLI testing script (test_model.py)
- A Streamlit web application (app.py)
- Stored model artifacts and configuration under trained_models/

##### File structure
Top level:
- classification-files/
- complete ipynb(AdvancedDNN).ipynb
- complete_ipynb(Xgboost).ipynb
- app.py (Streamlit UI)
- test_model.py (CLI interface)
- requirements.txt
- trained models/ (emotion_model.h5, scaler, encoder, config, etc.)
- demo/ (demo_video.mp4)
- pretrained-concepts-ipynb/ (reference notebooks)
Key observations:
- Separation of concerns: training (notebooks), deployment (app.py, test_model.py), artifacts (trained models)
- No separate “backend” HTTP service—UI and CLI directly load artifacts and run inference
- Configuration files and pickled objects under trained models indicate a persistence layer

##### README for additional insights
- The README outlines a linear “Raw Audio → Preprocessing → Feature Extraction → Model Training → Deployment” flow.
- Technologies: Python 3.8+, TensorFlow 2.x, XGBoost, scikit-learn, Streamlit.
- Feature extraction: MFCC, Chroma, Spectral Centroid, etc.
- Two deployment targets: CLI and Streamlit web UI.

##### Detailed capture of essential architectural elements
- Don’t just group everything under “backend.” Split preprocessing vs feature extraction vs inference.
- That both Run paths (CLI and Web) share the same core pipeline modules.
- Call out external dependencies (TensorFlow, XGBoost, Streamlit) next to each component.
- Configuration files (config.pkl, scaler.pkl, encoder.pkl) as part of the persistence layer.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        CLI["CLI: test_model.py"]:::ui
        Web["Web UI: app.py"]:::ui
    end

    %% Application Logic
    subgraph "Application Logic"
        Preproc["Audio Preprocessing"]:::processing
        Feature["Feature Extraction"]:::processing
        Inference["Model Inference\n(DNN, XGBoost, RF)"]:::processing
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        Artifacts[(Model Artifacts Store)]:::storage
    end

    %% Training Notebooks
    subgraph "Training Notebooks"
        DNN_Notebook["AdvancedDNN Notebook"]:::notebooks
        XGB_Notebook["XGBoost Notebook"]:::notebooks
    end

    %% Dependencies
    Req["requirements.txt"]:::dependency

    %% Data Flow and Relationships
    CLI -->|uploads audio or provides path| Preproc
    Web -->|uploads audio file| Preproc
    Preproc -->|preprocessed audio| Feature
    Feature -->|extracted features| Inference
    Artifacts -->|load models & configs| Inference
    Inference -->|predictions| CLI
    Inference -->|predictions| Web

    DNN_Notebook -->|produces artifacts| Artifacts
    XGB_Notebook -->|produces artifacts| Artifacts
    Req -->|defines dependencies| CLI
    Req -->|defines dependencies| Web
    Req -->|defines dependencies| DNN_Notebook
    Req -->|defines dependencies| XGB_Notebook

    %% Click Events
    click CLI "https://github.com/ansh2709/emotion-classification/blob/main/classification-files/test_model.py"
    click Web "https://github.com/ansh2709/emotion-classification/blob/main/classification-files/app.py"
    click Artifacts "https://github.com/ansh2709/emotion-classification/tree/main/classification-files/trained models/"
    click DNN_Notebook "https://github.com/ansh2709/emotion-classification/blob/main/classification-files/complete ipynb(AdvancedDNN) (ipynb, python script for test, web app script).ipynb"
    click XGB_Notebook "https://github.com/ansh2709/emotion-classification/blob/main/classification-files/complete_ipynb(Xgboost) (ipynb, python script for test, web app script).ipynb"
    click Req "https://github.com/ansh2709/emotion-classification/blob/main/classification-files/requirements.txt"

    %% Styles
    classDef ui fill:#ffa500,stroke:#333,stroke-width:1px
    classDef processing fill:#add8e6,stroke:#333,stroke-width:1px
    classDef storage fill:#98fb98,stroke:#333,stroke-width:1px
    classDef notebooks fill:#ffd700,stroke:#333,stroke-width:1px
    classDef dependency fill:#d3d3d3,stroke:#333,stroke-width:1px
```
