# ash04-creater/amazon-flipkart-price-comparison-engine architecture

> Architecture diagram of the GitHub repository ash04-creater/amazon-flipkart-price-comparison-engine, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ash04-creater/amazon-flipkart-price-comparison-engine
- Repository: https://github.com/ash04-creater/amazon-flipkart-price-comparison-engine

## Overview

##### Project type and purpose
- This is a small Python‐based command‐line utility (“engine”) whose purpose is to scrape product data and prices from top e-commerce sites (Flipkart and Amazon) and generate comparison spreadsheets. It is neither a multi-tier web app nor a microservice architecture—rather a simple CLI tool with two main modules for product‐spec comparison and price comparison.

##### File structure
- Top-level files only:
- README.md – project overview and usage
- product_comparator.py – module to compare product specifications on Flipkart
- price_comparator.py – module to compare product prices on Amazon and Flipkart
- images_used/ – screenshots for documentation
- No subdirectories, no database, no server or build scripts. All logic lives in those two Python scripts.

##### Key insights from the README
- product_comparator.py:
- Takes one or more Flipkart product URLs
- Scrapes specifications (e.g., screen size, RAM, CPU)
- Produces a tabular datasheet (e.g., CSV or Excel)
- price_comparator.py:
- Takes a product name
- Searches Amazon and Flipkart for top-5 matches
- Scrapes prices and product links
- Outputs a datasheet with price comparisons

##### Main components
a. User (CLI)
b. CLI “Controller” – dispatches to either:
- ProductComparator module
- PriceComparator module
c. Scraping & Parsing Layer:
- HTTP client (requests/urllib)
- HTML parser (BeautifulSoup or similar)
d. Data Aggregator:
- Extracts fields into structured form
- Merges multi-product or multi-site results
e. Output Generator:
- Writes out CSV/Excel (e.g., pandas or csv module)
f. External Services:
- Flipkart (for specs and/or prices)
- Amazon (for prices)

##### Relationships & data flow
1. User invokes script → CLI Controller
2. CLI Controller parses arguments → selects module
3. Module issues HTTP requests to external site(s)
4. Response → HTML parser → Data Aggregator
5. Aggregated data → Output Generator → Spreadsheet file
6. Final file path reported back to the user

##### Architectural patterns & design principles
- Clear separation of concerns:
- CLI argument parsing vs. scraping logic vs. output formatting
- Pipeline pattern:
- Input → Fetch → Parse → Aggregate → Write
- Dependency on external services is isolated in the scraping layer.

##### Technologies & libraries
- Python 3.x
- requests or urllib for HTTP
- BeautifulSoup (bs4) or lxml for HTML parsing
- csv or pandas for data‐sheet generation
- argparse or click for CLI

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User and Documentation
    User["User (CLI)"] 
    README["README.md"]:::external
    Images["images_used/"]:::external

    %% Core Modules
    subgraph "Core Modules"
        CLI_Controller["CLI Controller"]:::core
        ProdComp["ProductComparator Module"]:::core
        PriceComp["PriceComparator Module"]:::core
        HTTP_Client["HTTP Client"]:::core
        HTML_Parser["HTML Parser"]:::core
        Data_Aggregator["Data Aggregator"]:::core
        Output_Generator["Output Generator"]:::core
    end

    %% External Services
    subgraph "External Services"
        Flipkart["Flipkart"]:::external
        Amazon["Amazon"]:::external
    end

    %% Data Store
    Spreadsheet["Spreadsheet File"]:::datastore

    %% Flow
    User -->|"invoke"| CLI_Controller
    CLI_Controller -->|"spec URLs"| ProdComp
    CLI_Controller -->|"product name"| PriceComp

    ProdComp -->|"URLs"| HTTP_Client
    PriceComp -->|"URLs"| HTTP_Client

    HTTP_Client -->|"HTTP Request"| Flipkart
    PriceComp -->|"HTTP Request"| Amazon

    Flipkart -->|"HTML"| HTML_Parser
    Amazon -->|"HTML"| HTML_Parser

    HTML_Parser -->|"Structured Data"| Data_Aggregator
    Data_Aggregator -->|"Merged Data"| Output_Generator
    Output_Generator -->|"CSV/XLSX"| Spreadsheet
    Spreadsheet -->|"file path"| User

    %% Click Events
    click CLI_Controller "https://github.com/ash04-creater/amazon-flipkart-price-comparison-engine/blob/main/product_comparator.py"
    click ProdComp "https://github.com/ash04-creater/amazon-flipkart-price-comparison-engine/blob/main/product_comparator.py"
    click PriceComp "https://github.com/ash04-creater/amazon-flipkart-price-comparison-engine/blob/main/price_comparator.py"
    click HTTP_Client "https://github.com/ash04-creater/amazon-flipkart-price-comparison-engine/blob/main/product_comparator.py"
    click HTML_Parser "https://github.com/ash04-creater/amazon-flipkart-price-comparison-engine/blob/main/product_comparator.py"
    click Data_Aggregator "https://github.com/ash04-creater/amazon-flipkart-price-comparison-engine/blob/main/product_comparator.py"
    click Output_Generator "https://github.com/ash04-creater/amazon-flipkart-price-comparison-engine/blob/main/product_comparator.py"
    click README "https://github.com/ash04-creater/amazon-flipkart-price-comparison-engine/blob/main/README.md"
    click Images "https://github.com/ash04-creater/amazon-flipkart-price-comparison-engine/tree/main/images_used/"

    %% Styles
    classDef core fill:#c6f5c6,stroke:#333,stroke-width:1px
    classDef external fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef datastore fill:#ffe5b4,stroke:#333,stroke-width:1px
```
