# deepali-07/sentimental-analysis architecture

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

- Interactive diagram: https://gitdiagram.com/deepali-07/sentimental-analysis
- Repository: https://github.com/deepali-07/sentimental-analysis

## Overview

##### Project type and purpose
- This is a lightweight full-stack web application built with Flask for backend logic and a simple HTML/CSS frontend. Its primary purpose is to accept a user’s text input, run a sentiment analysis model (scikit-learn/TextBlob), and display the result in real time.

##### File structure
- Top-level files:
- app.py – Flask application entry point, defines routes and prediction logic
- train_model.py – standalone script for training or updating the ML model
- requirements.txt – lists Python dependencies (Flask, scikit-learn/TextBlob, etc.)
- Directories:
- templates/ – contains index.html (Flask view layer)
- static/ – holds style.css (UI styling assets)
- No database or external microservices; model and application run in the same process.

##### Key insights from README
- Technology stack clearly calls out Flask (backend), HTML/CSS/JS (frontend), scikit-learn/TextBlob (ML).
- Future enhancements mention CI/CD, multi-language support, etc.—these can be placeholders in the design for extensibility.

##### Components
a. Client Layer (Browser)
- Displays the Glassmorphism UI (index.html + style.css + optional JS for async requests)
- Sends HTTP POST with user text to Flask backend
b. Web Server / Application Layer (Flask app.py)
- Route handler (/predict) receives the request
- Controller logic calls the prediction module
- Serves static assets and templates
c. Machine Learning Module
- Pretrained model file (pickle or .pkl) loaded by app.py at start or on demand
- train_model.py (offline component for model training/retraining)
d. Deployment/Infrastructure
- Hosting platform (Render/Vercel/Azure) running the Flask container or service
- (Optional) GitHub Actions / CI pipeline for automated builds and deploys

##### Architectural patterns and design principles
- MVC-like separation:
- Model = sentiment analysis model file
- View = templates/index.html + static/style.css
- Controller = app.py route handlers
- Single-process, synchronous prediction in Flask (can later be refactored to async or microservice)
- Extensibility points:
- Swap or add ML models (TextBlob → transformer)
- Caching or a message queue if volume grows

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        direction TB
        Browser["Browser (Client)"]:::client
        IndexHTML["index.html"]:::client
        StyleCSS["style.css"]:::client
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        FlaskApp["Flask App (app.py)"]:::appComp
    end

    %% Machine Learning Module
    subgraph "Machine Learning Module"
        direction TB
        TrainScript["train_model.py"]:::appComp
        ModelArtifact["model.pkl"]:::data
    end

    %% Configuration
    subgraph "Configuration"
        direction TB
        Requirements["requirements.txt"]:::appComp
    end

    %% Deployment / Infrastructure
    subgraph "Deployment / Infrastructure"
        direction TB
        CICDPipeline["CI/CD Pipeline"]:::infra
        Hosting["Hosting Platform (Render/Vercel/Azure)"]:::infra
    end

    %% Connections
    Browser -->|"HTTP POST /predict with text payload"| FlaskApp
    FlaskApp -->|"call model.predict(text)"| ModelArtifact
    FlaskApp -->|"serve CSS/HTML"| IndexHTML
    FlaskApp -->|"serve CSS/HTML"| StyleCSS
    FlaskApp -->|"HTTP response with sentiment result"| Browser
    TrainScript -->|"writes new model artifact"| ModelArtifact
    CICDPipeline -->|"deploy updated app container"| Hosting

    %% Click Events
    click IndexHTML "https://github.com/deepali-07/sentimental-analysis/blob/main/templates/index.html"
    click StyleCSS "https://github.com/deepali-07/sentimental-analysis/blob/main/static/style.css"
    click FlaskApp "https://github.com/deepali-07/sentimental-analysis/blob/main/app.py"
    click TrainScript "https://github.com/deepali-07/sentimental-analysis/blob/main/train_model.py"
    click Requirements "https://github.com/deepali-07/sentimental-analysis/blob/main/requirements.txt"
    click IndexHTML "https://github.com/deepali-07/sentimental-analysis/tree/main/templates/"
    click StyleCSS "https://github.com/deepali-07/sentimental-analysis/tree/main/static/"

    %% Styles
    classDef appComp fill:#D0E8FF,stroke:#000
    classDef data fill:#DFFFD0,stroke:#000
    classDef infra fill:#FFEFD0,stroke:#000
    classDef client fill:#F0F0F0,stroke:#000
```
