# patil-mandar/suggesting-best-courses-using-sentiment-analysis architecture

> Architecture diagram of the GitHub repository patil-mandar/suggesting-best-courses-using-sentiment-analysis, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/patil-mandar/suggesting-best-courses-using-sentiment-analysis
- Repository: https://github.com/patil-mandar/suggesting-best-courses-using-sentiment-analysis

## Overview

##### Project Type & Purpose
- Full-stack web application that takes a course URL, scrapes its user comments, runs sentiment analysis (CountVectorizer + Random Forest), computes a rating, and presents results via HTML templates.
- No persistent database; data flows in memory.

##### Main Components
a. User’s Web Browser (Front-end)
- HTML templates (in `/templates`)
- Static assets (CSS in `/static/css`)
- Form to enter course URL
b. Flask Application (Backend)
- Entry point: `app.py`
- Routes/controllers rendering templates and invoking logic
c. Web Scraper Module
- `webScraping.py` fetches comments from the course URL
d. ML Model Module
- `mlmodel.py` implements feature extraction (CountVectorizer) and Random Forest prediction
- `CountVectorizer.ipynb` was used for model development/training (offline)
e. External Services
- Target e-learning site (source of course comments)
- (Offline) Kaggle dataset used for initial model training

##### Relationships & Data Flow
1. User enters URL → Front-end form submits HTTP POST to a Flask route.
2. Flask route calls webScraping.py → Scrape comments via HTTP requests to external site.
3. Comments passed to mlmodel.py → Vectorized, classified into sentiment categories.
4. Backend aggregates sentiment scores → Computes an overall rating.
5. Flask renders an HTML report template → Embeds results for the user.

##### Architectural Patterns & Design Principles
- Monolithic MVC-style separation:
– View layer: Jinja2 templates + CSS
– Controller layer: Flask routes in `app.py`
– Model layer: ML logic in `mlmodel.py`
- Single responsibility per module: scraper, model, web server
- No external database—transient in-memory data flow

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Front-end Layer
    subgraph "Front-end Layer"
        direction TB
        Browser["User Browser"]:::frontend
        Templates["HTML Templates"]:::frontend
        CSS["CSS Styles"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        FlaskApp["Flask App (app.py)"]:::backend
        WebScraper["Web Scraper Module\n(webScraping.py)"]:::backend
        MLModule["ML Model Module\n(mlmodel.py)"]:::backend
    end

    %% External Services
    subgraph "External Services"
        direction TB
        ExternalSite["External Course Website"]:::external
    end

    %% Offline Training Pipeline
    subgraph "Offline Training" 
        direction TB
        Notebook["CountVectorizer Notebook\n(CountVectorizer.ipynb)"]:::offline
        KaggleDataset["Kaggle Dataset"]:::offline
    end

    %% Documentation
    Documentation["Project Documentation\n(README.md)"]:::doc

    %% Data Flows
    Browser -->|"POST URL"| FlaskApp
    FlaskApp -->|"HTTP scrape comments"| WebScraper
    WebScraper -->|"GET comments"| ExternalSite
    ExternalSite -->|"HTML/comments"| WebScraper
    WebScraper -->|"Comment list"| FlaskApp
    FlaskApp -->|"Sentiment scores"| MLModule
    MLModule -->|"Sentiment scores"| FlaskApp
    FlaskApp -->|"HTML response"| Browser
    FlaskApp -->|"renders templates"| Templates
    FlaskApp -->|"serves CSS"| CSS

    Notebook -->|"uses dataset"| KaggleDataset
    Notebook -->|"trained model export"| MLModule

    Documentation

    %% Click Events
    click Templates "https://github.com/patil-mandar/suggesting-best-courses-using-sentiment-analysis/tree/master/templates/"
    click CSS "https://github.com/patil-mandar/suggesting-best-courses-using-sentiment-analysis/blob/master/static/css/style.css"
    click FlaskApp "https://github.com/patil-mandar/suggesting-best-courses-using-sentiment-analysis/blob/master/app.py"
    click WebScraper "https://github.com/patil-mandar/suggesting-best-courses-using-sentiment-analysis/blob/master/webScraping.py"
    click MLModule "https://github.com/patil-mandar/suggesting-best-courses-using-sentiment-analysis/blob/master/mlmodel.py"
    click Notebook "https://github.com/patil-mandar/suggesting-best-courses-using-sentiment-analysis/blob/master/CountVectorizer.ipynb"
    click Documentation "https://github.com/patil-mandar/suggesting-best-courses-using-sentiment-analysis/blob/master/README.md"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#006064,color:#006064;
    classDef backend fill:#E8F5E9,stroke:#1B5E20,color:#1B5E20;
    classDef external fill:#FFF3E0,stroke:#E65100,color:#E65100;
    classDef offline fill:#F3E5F5,stroke:#4A148C,color:#4A148C;
    classDef doc fill:#ECEFF1,stroke:#37474F,color:#37474F;
```
