# theimperialemperor/course-recommend-system architecture

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

- Interactive diagram: https://gitdiagram.com/theimperialemperor/course-recommend-system
- Repository: https://github.com/theimperialemperor/course-recommend-system

## Overview

##### Project type and purpose
- This is a small full-stack web application (“Course Recommendation System”) built with Flask for its backend and server-rendered HTML templates for its frontend.
- Purpose: let users view popular courses (by rating) and get keyword-based course recommendations using content-based filtering over preprocessed course data.

##### File structure
- Top-level files:
- app.py – Flask application and controllers
- course-recommend.py / .ipynb – data preprocessing and recommendation logic
- data.csv – raw course dataset
- *.pkl – precomputed data artifacts (pickled DataFrames)
- requirements.txt – Python dependencies
- templates/ – Jinja2 HTML templates (views)
- No external database: data persistence is via flat files (CSV + pickles)

##### README for additional insights
- Confirms Flask + pandas stack
- Shows two main features: “Popular Courses” pages and keyword lookup recommendations
- Indicates that data must be pre-prepared (df.pkl, popular_df*.pkl)

##### Main components & relationships
a. User Interface (Frontend)
- Browser — renders HTML from templates (index.html, recommend.html, etc.)
- Inputs: keyword searches, navigation requests
b. Web Server & Application Logic (Backend)
- Flask app (app.py) handles HTTP endpoints ("/", "/popular", "/recommend", etc.)
- Controllers load preprocessed pickles into pandas DataFrames on startup
- Recommendation module (in app.py calls functions from course-recommend.py)
c. Data Storage / Persistence
- Raw data: data.csv
- Precomputed artifacts: df.pkl, popular.pkl, popular_df*.pkl
d. Offline Data Processing Pipeline
- course-recommend.py / Jupyter notebooks
- Reads data.csv → applies cleaning, feature extraction → produces pickles
e. External Libraries & Runtime
- Flask for HTTP + routing
- pandas for data manipulation
- Jinja2 for template rendering

Interaction flow:
User → HTTP GET/POST → Flask routes → Data lookup & recommendation logic → render HTML → User

##### Architectural patterns & design principles
- MVC (Model-View-Controller):
Model = pandas DataFrames (loaded from pickles)
View = Jinja2 templates under /templates
Controller = Flask route handlers in app.py
- Preprocessing separation: offline data pipeline distinct from runtime application
- Single-process WSGI app (can be fronted by gunicorn or uWSGI in production)

- Browser → [HTTP request] → Flask App
- Flask App → [load] → Pickle DataStore
- Flask App → [invoke] → Recommendation Module
- Recommendation Module → [read/write] → pandas DataFrame
- Flask App → [render] → Templates → Browser
- Offline Pipeline → [produce] → Pickle DataStore

## Diagram (Mermaid)

```mermaid
flowchart TB
  %% Presentation Layer
  subgraph "Presentation Layer"
    Browser[/Browser/]:::frontend
    subgraph "Views (templates)"
      IndexT["index.html"]:::frontend
      IndexPopular["index_popular.html"]:::frontend
      Index3["index3.html"]:::frontend
      RecommendT["recommend.html"]:::frontend
      RecDesc["recommend_description.html"]:::frontend
      ErrorT["error.html"]:::frontend
    end
  end

  %% Application Layer
  subgraph "Application Layer"
    subgraph "Controllers & Logic"
      IndexRt["index() route"]:::backend
      PopularRt["popular() route"]:::backend
      RecommendRt["recommend() route"]:::backend
      DataLoader["Data Loader"]:::backend
      RecEngine["Recommendation Engine"]:::backend
    end
  end

  %% Data Layer
  subgraph "Data Layer"
    RawData[("data.csv")]:::data
    subgraph "Pickled Artifacts"
      DF[(df.pkl)]:::data
      PopularP[(popular.pkl)]:::data
      PopCourses[(popular_courses.pkl)]:::data
      PopDF1[(popular_df.pkl)]:::data
      PopDF2[(popular_df2.pkl)]:::data
      PopDF3[(popular_df3.pkl)]:::data
    end
  end

  %% Offline Pipeline
  Offline["Offline Pipeline"]:::data

  %% Documentation & Setup
  subgraph "Project Docs & Setup"
    README["README.md"]:::data
    Req["requirements.txt"]:::data
    CP1[".ipynb_checkpoints/course-recommend-checkpoint.ipynb"]:::data
    CP2[".ipynb_checkpoints/book-recommender-system-checkpoint.ipynb"]:::data
  end

  %% Connections
  Browser -->|"HTTP GET/POST"| IndexRt
  Browser -->|"HTTP GET/POST"| PopularRt
  Browser -->|"HTTP GET/POST"| RecommendRt
  IndexRt -->|renders| IndexT
  PopularRt -->|renders| IndexPopular
  PopularRt -->|renders| Index3
  RecommendRt -->|renders| RecommendT
  RecommendRt -->|renders| RecDesc
  IndexRt -->|handles errors| ErrorT
  PopularRt -->|uses| DataLoader
  IndexRt -->|uses| DataLoader
  RecommendRt -->|uses| RecEngine
  DataLoader -->|loads| DF
  DataLoader -->|loads| PopDF1
  DataLoader -->|loads| PopDF2
  DataLoader -->|loads| PopDF3
  DataLoader -->|loads| PopularP
  DataLoader -->|loads| PopCourses
  RecEngine -->|reads| DF
  RecEngine -->|reads| RawData
  Offline -->|produce| DF
  Offline -->|produce| PopDF1
  Offline -->|produce| PopDF2
  Offline -->|produce| PopDF3
  Offline -->|produce| PopularP
  Offline -->|produce| PopCourses
  README -.->|documents| Offline
  Req -.->|defines| DataLoader

  %% Click Events
  click IndexT "https://github.com/theimperialemperor/course-recommend-system/blob/master/templates/index.html"
  click IndexPopular "https://github.com/theimperialemperor/course-recommend-system/blob/master/templates/index_popular.html"
  click Index3 "https://github.com/theimperialemperor/course-recommend-system/blob/master/templates/index3.html"
  click RecommendT "https://github.com/theimperialemperor/course-recommend-system/blob/master/templates/recommend.html"
  click RecDesc "https://github.com/theimperialemperor/course-recommend-system/blob/master/templates/recommend_description.html"
  click ErrorT "https://github.com/theimperialemperor/course-recommend-system/blob/master/templates/error.html"
  click IndexRt "https://github.com/theimperialemperor/course-recommend-system/blob/master/app.py"
  click PopularRt "https://github.com/theimperialemperor/course-recommend-system/blob/master/app.py"
  click RecommendRt "https://github.com/theimperialemperor/course-recommend-system/blob/master/app.py"
  click DataLoader "https://github.com/theimperialemperor/course-recommend-system/blob/master/app.py"
  click RecEngine "https://github.com/theimperialemperor/course-recommend-system/blob/master/course-recommend.py"
  click Offline "https://github.com/theimperialemperor/course-recommend-system/blob/master/course-recommend.py"
  click README "https://github.com/theimperialemperor/course-recommend-system/blob/master/README.md"
  click Req "https://github.com/theimperialemperor/course-recommend-system/blob/master/requirements.txt"
  click RawData "https://github.com/theimperialemperor/course-recommend-system/blob/master/data.csv"
  click DF "https://github.com/theimperialemperor/course-recommend-system/blob/master/df.pkl"
  click PopularP "https://github.com/theimperialemperor/course-recommend-system/blob/master/popular.pkl"
  click PopCourses "https://github.com/theimperialemperor/course-recommend-system/blob/master/popular_courses.pkl"
  click PopDF1 "https://github.com/theimperialemperor/course-recommend-system/blob/master/popular_df.pkl"
  click PopDF2 "https://github.com/theimperialemperor/course-recommend-system/blob/master/popular_df2.pkl"
  click PopDF3 "https://github.com/theimperialemperor/course-recommend-system/blob/master/popular_df3.pkl"
  click CP1 "https://github.com/theimperialemperor/course-recommend-system/blob/master/.ipynb_checkpoints/course-recommend-checkpoint.ipynb"
  click CP2 "https://github.com/theimperialemperor/course-recommend-system/blob/master/.ipynb_checkpoints/book-recommender-system-checkpoint.ipynb"

  %% Styles
  classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
  classDef backend fill:#90EE90,stroke:#333,stroke-width:1px
  classDef data fill:#FFA500,stroke:#333,stroke-width:1px
```
