How adityakamble12/text-based-emotion-detector works
Project Type and Purpose
• This is a full-stack web application built with Flask (Python) that provides a UI for users to submit text and returns detected emotions by calling MeaningCloud’s Sentiment Analysis API.
• It is deployed on Vercel and uses static assets (HTML/CSS/JS) plus a small service layer (the emotion_detection module).
File Structure
• Top-level:
• app.py – Flask entry point, route definitions, orchestrates requests.
• emotion_detection/ – Python package encapsulating the core analysis logic (wrapper around MeaningCloud API).
• templates/ – Jinja HTML templates (only index.html).
• static/ – Frontend assets (CSS under /css, JS under /js, images under /img).
• requirements.txt, .env (not checked in), vercel.json – deployment/configuration.
• The structure follows a lightweight MVC pattern:
• Controller: Flask routes in app.py
• View: Jinja template + static files
• Model/Service: emotion_detection/emotion_detection.py
Extract Architectural Insights from the README
• Dependencies: Flask, pydash (utility), requests (HTTP calls), python-dotenv (config).
• The app reads an API_KEY from .env to authenticate with MeaningCloud.
• Hosted on Vercel, so deployment uses vercel.json.
Main Components & Interactions
1. Client Browser (UI)
2. Static Asset Server (Flask serves CSS/JS/images)
3. Flask App Server
• Route Handler(s) in app.py
• Service Layer in emotion_detection module
4. Configuration Store (.env via python-dotenv)
5. External Emotion Analysis API (MeaningCloud)
1. User types text → submits form in Browser
2. Browser → HTTP POST → Flask App Server
3. Flask Controller → calls Service Layer (emotion_detection.py)
4. Service Layer → HTTP request (via requests) → MeaningCloud API
5. MeaningCloud API → JSON response → Service Layer
6. Service Layer → processed result → Controller
7. Controller → injects data into index.html template or sends JSON → Browser
c. Architectural Patterns & Principles:
• MVC separation (Controller, View, Service/Model)
• Single-Responsibility: emotion_detection module purely wraps API logic
• Environment configuration decoupled via python-dotenv
• No persistent database—stateless HTTP + external API
d. Key Technologies & Frameworks:
• Flask (web server, templating)
• Jinja2 (HTML rendering)
• Static files: CSS, JavaScript (optional dynamic behavior in mywebscript.js)
• Python libraries: requests, pydash, python-dotenv
• External: MeaningCloud Sentiment Analysis API
• Deployment: Vercel (via vercel.json)