# kiran-91/sentimeter--sentiment-analysis-using-rnn-and-nlp architecture

> Architecture diagram of the GitHub repository kiran-91/sentimeter--sentiment-analysis-using-rnn-and-nlp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kiran-91/sentimeter--sentiment-analysis-using-rnn-and-nlp
- Repository: https://github.com/kiran-91/sentimeter--sentiment-analysis-using-rnn-and-nlp

## Overview

##### Project Type & Purpose
- This is a lightweight full-stack application combining a Streamlit front end with a simple RNN-based ML back end.
- Purpose: Accept movie-review text, preprocess it (tokenize/pad), run it through a pre-trained SimpleRNN model (SimpleRNN_imdb.h5) and display sentiment plus history.

##### File Structure
- Top level:
- app.py – Streamlit app (UI + orchestration)
- SimpleRNN_imdb.h5 – serialized Keras model
- prediction.ipynb & simpleRNN.ipynb – exploratory notebooks (model prototyping)
- requirements.txt, README.md, LICENSE – metadata/config
- No separate “frontend” or “backend” folders: both live in app.py.

##### Read README for Architecture Clues
- Streamlit provides the UI.
- NLP preprocessing uses nltk + Keras Tokenizer/Pad Sequences.
- The model is loaded from disk on startup.
- Review history is tracked in-memory (e.g., session_state) or optionally persisted.

##### Main Components & Interactions
a. Components:
1) User’s Browser/Client
2) Streamlit Server (app.py)
- UI Layer (text input, buttons, display panels)
- Controller Layer (handles clicks, triggers preprocessing & inference)
3) Preprocessing Module
- Tokenizer, padding logic, stop-word filtering (nltk)
4) Model Inference Module
- Keras loads SimpleRNN_imdb.h5
- Runs predict() to produce sentiment score
5) Review History Store
- Streamlit session_state or lightweight local CSV/JSON
6) External Libraries/Services
- nltk data, TensorFlow/Keras, Streamlit cloud (hosting)

b. Interactions/Data Flow:
- User enters text → Streamlit UI → Controller
- Controller calls Preprocessing → vectorized input
- Vector passed to Model Inference → sentiment probability
- Result returned to Controller → UI display
- Controller appends entry to Review History → history panel
- All flows logged on console or session_state

##### Architectural Patterns & Principles
- MVC-style separation within a single file:
- Model: SimpleRNN_imdb.h5 + Keras code
- View: Streamlit widgets
- Controller: app.py functions tying UI to model
- Stateless front end with ephemeral session storage for history.
- Single-process, synchronous request–response pattern.

##### Technologies & Libraries
- Frontend/UI: Streamlit
- NLP: NLTK (tokenization, stop-words)
- ML Framework: TensorFlow/Keras
- Data: IMDB dataset (training not in app)
- Hosting: Streamlit Cloud or local

## Diagram (Mermaid)

```mermaid
flowchart TB
    user["User's Browser/Client"]:::external

    subgraph "Streamlit App"
        direction TB
        UI["UI Layer\n(Streamlit Widgets)"]:::ui
        Controller["Controller Layer\n(app.py)"]:::controller
        Preprocessing["Preprocessing Module\n(tokenize/pad)"]:::processing
        Inference["Model Inference Module\n(loads SimpleRNN_imdb.h5)"]:::model
        History["Review History Store\n(session_state)"]:::store
    end

    subgraph "External Dependencies"
        direction TB
        NLTK["NLTK"]:::extlib
        TF["TensorFlow/Keras"]:::extlib
        StreamlitLib["Streamlit"]:::extlib
    end

    subgraph "Artifacts & Config"
        direction TB
        Notebook1["prediction.ipynb"]:::artifact
        Notebook2["simpleRNN.ipynb"]:::artifact
        Req["requirements.txt"]:::artifact
        Readme["README.md"]:::artifact
        License["LICENSE"]:::artifact
    end

    user -->|"enters review text"| UI
    UI -->|"submit event"| Controller
    Controller -->|"raw text"| Preprocessing
    Preprocessing -->|"token IDs"| Inference
    Inference -->|"probability score"| Controller
    Controller -->|"display result"| UI
    Controller -->|"append entry"| History

    NLTK --> Preprocessing
    TF --> Inference
    StreamlitLib --> UI
    StreamlitLib --> Controller

    classDef ui fill:#D6EAF8,stroke:#21618C,color:#1B4F72;
    classDef controller fill:#D5F5E3,stroke:#196F3D,color:#145A32;
    classDef processing fill:#FCF3CF,stroke:#B7950B,color:#7D6608;
    classDef model fill:#FADBD8,stroke:#C0392B,color:#78281F;
    classDef store fill:#FCF3CF,stroke:#B7950B,color:#7D6608;
    classDef external fill:#F2F3F4,stroke:#7B7D7D,color:#1C2833;
    classDef extlib fill:#F2F3F4,stroke:#7B7D7D,color:#1C2833;
    classDef artifact fill:#EBF5FB,stroke:#1F618D,color:#154360;

    click Controller "https://github.com/kiran-91/sentimeter--sentiment-analysis-using-rnn-and-nlp/blob/main/app.py"
    click Preprocessing "https://github.com/kiran-91/sentimeter--sentiment-analysis-using-rnn-and-nlp/blob/main/app.py"
    click Inference "https://github.com/kiran-91/sentimeter--sentiment-analysis-using-rnn-and-nlp/blob/main/app.py"
    click History "https://github.com/kiran-91/sentimeter--sentiment-analysis-using-rnn-and-nlp/blob/main/app.py"
    click Inference "https://github.com/kiran-91/sentimeter--sentiment-analysis-using-rnn-and-nlp/blob/main/SimpleRNN_imdb.h5"
    click Notebook1 "https://github.com/kiran-91/sentimeter--sentiment-analysis-using-rnn-and-nlp/blob/main/prediction.ipynb"
    click Notebook2 "https://github.com/kiran-91/sentimeter--sentiment-analysis-using-rnn-and-nlp/blob/main/simpleRNN.ipynb"
    click Req "https://github.com/kiran-91/sentimeter--sentiment-analysis-using-rnn-and-nlp/blob/main/requirements.txt"
    click Readme "https://github.com/kiran-91/sentimeter--sentiment-analysis-using-rnn-and-nlp/blob/main/README.md"
    click License "https://github.com/kiran-91/sentimeter--sentiment-analysis-using-rnn-and-nlp/tree/main/LICENSE"
```
