# anirudh42/sentimentpredictionapp architecture

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

- Interactive diagram: https://gitdiagram.com/anirudh42/sentimentpredictionapp
- Repository: https://github.com/anirudh42/sentimentpredictionapp

## Overview

##### Project type and purpose
- This is a full-stack microservice style application whose primary purpose is to serve a pre-trained sentiment analysis model over HTTP.
- It uses Flask as the web framework, Docker to containerize the app, and AWS Elastic Beanstalk to host and run the container in production.
- The project provides a template for packaging any ML model into a REST API and deploying it to the cloud.

##### File structure
Top-level:
- .gitignore, README.md, Docker_Flask_AWS_App.pdf – documentation and ignore rules
- Dockerfile – instructions to build a container image
- requirements.txt – Python dependencies (Flask, scikit-learn, etc.)
- app.py – the Flask application with two endpoints (“/” and “/train_predict”)
Directories:
- data/ – sample CSV files used for training or testing
- ml_model/ – persisted artifacts: featurizer.pk (vectorizer) and sentiment_model.pk (trained classifier)

##### README for additional insights
- Confirms it’s a template for deploying ML models with Flask and Docker.
- Describes endpoints, step-by-step Docker build/run, and AWS Elastic Beanstalk commands.
- No separate front-end – clients simply hit HTTP endpoints.

##### Elements
- Clear labels for each component: Client, AWS EB, Docker Container, Flask App, Featurizer, Sentiment Model, Data.
– Client → Flask endpoint
– Flask → Featurizer → Model → Flask
– Dockerfile → Container build
– AWS EB → Docker Container
– Another for ML artifacts (Featurizer, Model)
– Another for infrastructure (AWS EB)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client
    Client["REST Client"]:::client

    %% Infrastructure
    subgraph "Infrastructure Layer"
        AWS_EB["AWS Elastic Beanstalk"]:::infra
    end

    %% Build Pipeline
    subgraph "Build Pipeline"
        DockerfileNode["Dockerfile"]:::docs
        Requirements["requirements.txt"]:::docs
        DockerfileNode -->|builds with| Requirements
        BuildImage["Build Image"]:::container
        Requirements -->|installs deps| BuildImage
        DockerfileNode -->|defines steps| BuildImage
        BuildImage -->|produces| Container["Docker Container"]:::container
    end

    AWS_EB -->|deploys| Container

    %% Runtime Container
    subgraph "Docker Container" 
        subgraph "Web Service" 
            FlaskApp["Flask Application"]:::runtime
        end
        subgraph "ML Module"
            Featurizer["Featurizer"]:::ml
            Model["Sentiment Model"]:::ml
        end
        subgraph "Data Store"
            DataDir["data/"]:::data
            TrainCSV["Train.csv"]:::data
            TestCSV["Test.csv"]:::data
        end
    end

    %% Runtime Flow
    Client -->|HTTP request| FlaskApp
    FlaskApp -->|load artifact| Featurizer
    Featurizer -->|features| Model
    Model -->|prediction| FlaskApp
    FlaskApp -->|HTTP response| Client

    %% Data Store relationships
    DataDir --> TrainCSV
    DataDir --> TestCSV
    FlaskApp -->|reads sample data| DataDir

    %% Documentation
    subgraph "Documentation"
        README["README.md"]:::docs
        Guide["Docker_Flask_AWS_App.pdf"]:::docs
    end

    %% Click Events
    click DockerfileNode "https://github.com/anirudh42/sentimentpredictionapp/tree/main/Dockerfile"
    click Requirements "https://github.com/anirudh42/sentimentpredictionapp/blob/main/requirements.txt"
    click Container "https://github.com/anirudh42/sentimentpredictionapp/tree/main/Dockerfile"
    click FlaskApp "https://github.com/anirudh42/sentimentpredictionapp/blob/main/app.py"
    click DataDir "https://github.com/anirudh42/sentimentpredictionapp/tree/main/data/"
    click TrainCSV "https://github.com/anirudh42/sentimentpredictionapp/blob/main/data/Train.csv"
    click TestCSV "https://github.com/anirudh42/sentimentpredictionapp/blob/main/data/Test.csv"
    click Featurizer "https://github.com/anirudh42/sentimentpredictionapp/blob/main/ml_model/featurizer.pk"
    click Model "https://github.com/anirudh42/sentimentpredictionapp/blob/main/ml_model/sentiment_model.pk"
    click README "https://github.com/anirudh42/sentimentpredictionapp/blob/main/README.md"
    click Guide "https://github.com/anirudh42/sentimentpredictionapp/blob/main/Docker_Flask_AWS_App.pdf"

    %% Styles
    classDef client fill:#f9f,stroke:#333,stroke-width:1px
    classDef infra fill:#ccf,stroke:#333,stroke-width:1px
    classDef container fill:#cfc,stroke:#333,stroke-width:1px
    classDef runtime fill:#fcf,stroke:#333,stroke-width:1px
    classDef ml fill:#ffc,stroke:#333,stroke-width:1px
    classDef data fill:#cff,stroke:#333,stroke-width:1px
    classDef docs fill:#eee,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
```
