Skip to content

aghaPathan/noon-e-commerce

Repository files navigation

Noon E-Commerce Intelligence Platform

Python 3.10+ TypeScript FastAPI React License

Real-time price intelligence, competitor tracking, and alerting for Noon.com β€” Saudi Arabia's leading e-commerce marketplace.

✨ Features

  • πŸ“Š Price Tracking β€” Monitor SKU prices with historical trends
  • πŸͺ Competitor Analysis β€” Compare seller pricing across the marketplace
  • πŸ”” Smart Alerts β€” Get notified on price drops, stock changes, and anomalies
  • πŸ“ˆ Analytics Dashboard β€” Interactive charts and data visualization
  • ⚑ Daily Scraping β€” Automated data collection via Airflow DAGs
  • πŸ”Œ REST API β€” Full-featured API with bearer token auth

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Airflow DAG   │────▢│  Noon Scraper   │────▢│   ClickHouse    β”‚
β”‚   (3 AM UTC)    β”‚     β”‚  (ScraperAPI)   β”‚     β”‚  (Price History)β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                         β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”              β”‚
β”‚   PostgreSQL    │◀───▢│    FastAPI      β”‚β—€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚ (Users/Products)β”‚     β”‚   :8096/api     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
                        β”‚  React + Vite   β”‚
                        β”‚     :3001       β”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Tech Stack

Backend

Component Technology
API Framework FastAPI 0.109
Primary DB PostgreSQL 16 (users, products, auth)
Analytics DB ClickHouse (price history, time-series)
Scraping ScraperAPI + BeautifulSoup4
Orchestration Apache Airflow
Validation Pydantic v2

Frontend

Component Technology
Framework React 18 + TypeScript
Build Tool Vite
Styling Tailwind CSS
UI Components Radix UI + shadcn/ui
Charts Chart.js
State Zustand + React Query
Testing Vitest + Testing Library

πŸ“ Project Structure

noon-e-commerce/
β”œβ”€β”€ api/                    # FastAPI backend
β”‚   β”œβ”€β”€ main.py            # API endpoints
β”‚   β”œβ”€β”€ models.py          # Pydantic schemas
β”‚   └── database.py        # ClickHouse client
β”œβ”€β”€ frontend-ts/           # React TypeScript frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/    # UI components (CompetitorTable, AlertFeed, etc.)
β”‚   β”‚   β”œβ”€β”€ hooks/         # Custom hooks (useAlertFeed, useProducts)
β”‚   β”‚   β”œβ”€β”€ services/      # API client
β”‚   β”‚   └── types/         # TypeScript definitions
β”‚   └── package.json
β”œβ”€β”€ docker/                # Docker configurations
β”œβ”€β”€ scripts/               # Utility scripts
β”œβ”€β”€ noon_scraper.py        # Core scraping module
β”œβ”€β”€ noon_dag.py            # Airflow DAG definition
β”œβ”€β”€ postgres_schema.sql    # DB schema
└── docs/                  # Documentation

πŸš€ Quick Start

Prerequisites

  • Python 3.10+
  • Node.js 18+
  • ClickHouse server
  • ScraperAPI account

1. Clone & Configure

git clone https://github.com/aghaPathan/noon-e-commerce.git
cd noon-e-commerce

# Configure environment
cp .env.example .env
# Edit .env with your credentials

2. Backend Setup

# Create virtual environment
python -m venv .venv
source .venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Run API server
cd api && uvicorn main:app --host 0.0.0.0 --port 8096

3. Frontend Setup

cd frontend-ts
npm install
npm run dev   # Starts on http://localhost:3001

4. Airflow DAG (Optional)

# Copy DAG to Airflow
cp noon_dag.py ~/airflow/dags/

# DAG runs daily at 3 AM UTC (6 AM KSA)

βš™οΈ Configuration

Variable Description Required
SCRAPERAPI_KEY ScraperAPI authentication key βœ…
CLICKHOUSE_HOST ClickHouse server hostname βœ…
CLICKHOUSE_PORT ClickHouse native port (default: 9000) βœ…
CLICKHOUSE_USER Database username βœ…
CLICKHOUSE_PASSWORD Database password βœ…
CLICKHOUSE_DB Database name (default: noon) βœ…
API_TOKEN Bearer token for API auth βœ…
API_PORT API server port ❌

πŸ“‘ API Endpoints

Method Endpoint Description
GET /api/products List all tracked products
GET /api/products/{sku} Get product details
GET /api/prices/{sku} Get price history
GET /api/prices/{sku}/competitors Get competitor prices
GET /api/alerts Get active alerts
POST /api/alerts/acknowledge/{id} Acknowledge an alert
GET /api/health Health check

All endpoints require Authorization: Bearer <API_TOKEN> header.


πŸ§ͺ Testing

# Backend tests
pytest --cov=api

# Frontend tests
cd frontend-ts
npm run test
npm run test:ui   # Interactive UI

πŸ“Š Scraping Schedule

Time (UTC) Time (KSA) Action
03:00 06:00 Daily price scrape

SKUs are configured in skus.txt (one per line).


πŸ“– Documentation


πŸ”’ Security

  • Credentials stored in .env (gitignored)
  • API protected with bearer token authentication
  • ClickHouse access restricted to localhost
  • No PII collected β€” only public product data

🀝 Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“œ License

MIT License β€” see LICENSE for details.


πŸ‘€ Author

Agha Awais β€” @aghaPathan


Built for the KSA market πŸ‡ΈπŸ‡¦


CI Status

All PRs are checked for:

  • βœ… Syntax (Python, JS, TS, YAML, JSON, Dockerfile, Shell)
  • βœ… Secrets (No hardcoded credentials)
  • βœ… Security (High-severity vulnerabilities)

About

Noon E-Commerce Intelligence Platform - Price tracking & competitor analysis

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors