# healer005/sentify architecture

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

- Interactive diagram: https://gitdiagram.com/healer005/sentify
- Repository: https://github.com/healer005/sentify

## Overview

##### Project type and purpose
- This is a Python-based full-stack “Sentify” sentiment analysis application.
- Core purpose: train and evaluate an LSTM neural network on the IMDB dataset, then optionally deploy a Flask web app for real-time review classification.

##### File structure
- Top-level scripts:
- data_loader.py – data ingest & preprocessing (dataset loading, tokenizing, padding)
- model.py – defines the Keras LSTM model architecture
- main.py – orchestrates training, evaluation, and saving the model to sentiment_model.h5
- app.py – Flask application, loads the saved model, exposes endpoints
- templates/ – HTML views for the Flask app (index.html, result.html)
- sentiment_model.h5 – serialized model artifact
- requirements.txt – Python dependencies

##### Pulling extra insights from the README
- Tech stack: Python, TensorFlow/Keras, Flask, Matplotlib
- Features: data preprocessing, model training/evaluation, optional web deployment, data visualization
- Future scope: transformer support, UI improvements

a. Main components to include
- Data Layer: IMDB dataset (local or TF-built-in)
- Preprocessing Module (data_loader.py)
- Model Training Module (model.py + main.py)
- Model Artifact Store (sentiment_model.h5)
- Service Layer: Flask API (app.py)
- Presentation Layer: HTML templates & browser UI
b. Relationships & data flow
1. Dataset → Preprocessing → Tokenized/Padded Data
2. Tokenized Data → Model Training → Trained Model file
3. Trained Model → Evaluation → Metrics/Plots
4. Optional: Training history → Visualization scripts → Charts
5. In deployment: Client Browser → HTTP → Flask API → Model → Prediction → Response → Render via templates
c. Architectural patterns & principles
- Layered modular structure: data, model, service, presentation
- Single monolithic codebase but logically separated by function
- Clear separation of concerns: data ingestion vs. training vs. serving vs. visualization
d. Key technologies & frameworks
- TensorFlow/Keras for model definition & training
- Flask for lightweight REST/API service
- Matplotlib for plotting
- Jinja2 templates for HTML rendering

##### Detail without overcomplicating
- Templates under “Presentation Layer.”
- Saved model artifact as the bridge between training and inference.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Offline Training Pipeline
    subgraph "Offline Training Pipeline"
        D["IMDB Dataset"]:::data
        Pre["Preprocessing Module"]:::data
        Main["Training Orchestrator (main.py)"]:::model
        ModelDef["LSTM Model Definition (model.py)"]:::model
        Art["Model Artifact Store (sentiment_model.h5)"]:::data
        Viz["Visualization Module (visualize.py)"]:::utility
    end

    %% Online Inference Pipeline
    subgraph "Online Inference Pipeline"
        Browser["Client Browser UI"]:::ui
        App["Flask API (app.py)"]:::service
        Art
        subgraph "Presentation Layer"
            Index["index.html"]:::ui
            Result["result.html"]:::ui
        end
    end

    %% Dependency Manifest
    Req["requirements.txt"]:::utility

    %% Connections - Offline
    D --> Pre
    Pre --> Main
    Main --> ModelDef
    ModelDef --> Main
    Main --> Art
    Main --> Viz

    %% Connections - Online
    Browser -->|"HTTP/JSON"| App
    App --> Art
    App -->|"Prediction"| Browser
    App --> Index
    App --> Result

    %% Connections - Utilities
    Req --> Pre
    Req --> Main
    Req --> Viz
    Req --> App

    %% Click Events
    click Pre "https://github.com/healer005/sentify/blob/master/data_loader.py"
    click ModelDef "https://github.com/healer005/sentify/blob/master/model.py"
    click Main "https://github.com/healer005/sentify/blob/master/main.py"
    click Art "https://github.com/healer005/sentify/blob/master/sentiment_model.h5"
    click Viz "https://github.com/healer005/sentify/blob/master/visualize.py"
    click App "https://github.com/healer005/sentify/blob/master/app.py"
    click Index "https://github.com/healer005/sentify/blob/master/templates/index.html"
    click Result "https://github.com/healer005/sentify/blob/master/templates/result.html"
    click Req "https://github.com/healer005/sentify/blob/master/requirements.txt"

    %% Styles
    classDef data fill:#AED6F1,stroke:#2980B9,color:#1B2631;
    classDef model fill:#A9DFBF,stroke:#27AE60,color:#1B2631;
    classDef service fill:#F5B041,stroke:#D68910,color:#1B2631;
    classDef ui fill:#D2B4DE,stroke:#8E44AD,color:#1B2631;
    classDef utility fill:#D5D8DC,stroke:#7B7D7D,color:#1B2631;
```
