How paryagsahni1845/tweet-sentiment-analyzer works
Project Type and Purpose
• This is a full-stack, web-based NLP application called “Tweet Sentiment Analyzer.”
• It provides a user interface for submitting tweets (or topics), invokes a backend Flask service that performs TF-IDF vectorization + Logistic Regression classification, then returns sentiment (Positive/Negative) with confidence. It also supports batch/topic aggregation.
File Structure Analysis
• Top-level files:
• app.py – Flask application entrypoint (routing, request handling, model invocation)
• requirements.txt – Python dependencies
• analysis.ipynb – Data exploration/model training notebook (offline)
• README.md – Project overview
• Directory:
• templates/index.html – Frontend HTML template (user form + result display)
• No database, so model artifacts are likely loaded from disk or memory within app.py.
Key Architectural Components
a. Frontend Layer
• Browser clients
• index.html served by Flask (HTML/CSS, form input for tweet or topic)
b. Backend Layer (Flask API)
• HTTP Server (Flask)
• Request routing (/, /analyze) in app.py
• Input validation & sanitization
c. NLP Model Layer
• TF-IDF Vectorizer (from scikit-learn & NLTK preprocessor)
• Logistic Regression classifier
• Model and vectorizer loaded into memory at startup or on first request
d. Aggregation Layer
• Topic/keyword extraction logic (batch inputs)
• Computation of aggregated sentiment scores
e. Deployment Environment
• Hosted on Render (PaaS)
• Exposed HTTPS endpoint
Relationships and Data Flow
• Browser → HTTP POST to Flask endpoint with tweet/topic
• Flask handler → Preprocess text via NLTK → Vectorize using TF-IDF → Classify with Logistic Regression
• Model returns label + confidence → Flask packages JSON or renders template → Response to Browser
• For batch/topic, loop through input set → aggregate per-topic metrics → return summary
Architectural Patterns & Principles
• Layered architecture (Presentation → API → Business/Model logic)
• Separation of concerns (UI template vs. request handling vs. ML logic)
• Stateless HTTP API (no persistent session state)
• Single-process, in-memory model for low-volume workloads