How imsudip/comparego works
Main Components
a. Presentation Layer (Frontend)
• Web Browser / Client
• Static assets (static/)
• Templates (templates/index.html, search.html, details.html)
b. Application Layer (Backend)
• Flask Web Server (main.py)
• Route Handlers:
• Price Comparison Endpoint (scrape.py invoked by main.py)
• Sentiment Analysis Endpoint (predict.py invoked by main.py)
c. Service Modules
• Scraper Service (scrape.py)
• Sentiment Service (predict.py + tfidf.pkl + logreg_model.pkl)
d. Data Layer
• Pre-trained Models: tfidf.pkl, logreg_model.pkl
• Datasets & Temp Files: AmazonReview.csv, amazon_reviews.csv, a.json, data.json
e. External Dependencies
• E-commerce Websites (Requests + BeautifulSoup)
• Python Libraries (Flask, sklearn, requests, bs4, pandas, etc.)
Relationships & Data Flows
• User → HTTP Request → Flask Routes
• For Price Comparison:
Flask Route → Scraper Service → External Websites → Raw HTML → Parsed Prices → JSON Response → Frontend
• For Sentiment Analysis:
Flask Route → Sentiment Service → Load tfidf + SVM Model → Classify Review Text → Score/Label → JSON Response → Frontend
• Static/Template files served by Flask to render UI.
Architectural Patterns
• Monolithic Flask Application with clear separation of concerns (routes vs. service modules).
• Two distinct functional domains (price scraping vs. sentiment classification).
• File-based “data store” instead of a dedicated database—flat files and pickled models.
Detailed Elements
• Frontend:
• Browser
• HTTP GET / POST
• Templates + Static files
• Backend (Flask Monolith):
• Route: “/search” → Scraper Service → external e-commerce sites
• Route: “/predict” → Sentiment Service → tfidf.pkl + logreg_model.pkl
• Data:
• Filesystem (CSV, JSON)
• Model artifacts (pickle files)
• External:
• E-commerce websites (Amazon, etc.)