How aswajithb/ecommerce-smart-pricing-engine works
What this project is (type + purpose)
This is a single-service Flask web application that serves:
• A web UI (HTML templates + static CSS/images) for sellers to input product details and manage an inventory view.
• A machine-learning inference pipeline (pre-trained Ridge Regression + preprocessors stored as *.joblib) to predict an optimal price.
• A dynamic pricing adjustment layer (seasonality/trends/brand premiums) on top of the base ML prediction.
• A real-time currency conversion feature (USD → INR) using a live exchange rate source (external API call implied by README).
Deployment artifacts (Procfile, DEPLOYMENT.md, and application.py) strongly indicate PaaS deployment (e.g., AWS Elastic Beanstalk / Heroku-style process entrypoint).
What the file tree tells you about architecture (map files → components)
Top-level items and what they represent:
Web application entrypoints
• app.py — primary Flask app; will contain routes, request handling, model loading, inference, rendering templates.
• application.py — commonly used by Elastic Beanstalk as WSGI entrypoint (application object). Often imports from app.py.
• Procfile — defines how the web server is launched in production (e.g., gunicorn application:application).
ML model + preprocessing artifacts (runtime inference dependencies)
• ridge_model.joblib — trained Ridge model.
• tv_description.joblib — TF-IDF vectorizer for description text.
• cv_name.joblib, cv_category.joblib — likely count/vectorizers for name/category.
• ohe_condition.joblib — one-hot encoder for item condition.
• lb_brand.joblib — label binarizer/encoder for brand.
Data / training artifacts (not part of runtime, but relevant to architecture)
• dataset/sample_train.tsv — sample data; suggests training was done locally/offline.
Runtime/dependencies/deployment
• requirements.txt — Python deps (Flask, sklearn, pandas, nltk, joblib, etc.).
• Two-stage pricing: base ML prediction → dynamic pricing adjustments.
• External call: live exchange-rate API for USD→INR conversion.
• Inventory dashboard: browsing/searching listings with automated suggestions.
Flask Web App (Python)
• Routes/Controllers (HTTP endpoints)
• Template rendering (Jinja templates)
• Static file serving (or via platform)
ML Inference Pipeline (within Flask process)
• Text preprocessing (TF-IDF / vectorizers)
• Categorical encoders (OHE / label binarizer)
• Feature concatenation
• Ridge regression inference
Dynamic Pricing Engine (business rules)
• seasonality factor
• brand premium
• market trend factor
Currency Conversion Module
• calls External Exchange Rate API
Deployment/Runtime Environment
• WSGI server (Gunicorn implied by Procfile)
• Hosting platform (AWS Elastic Beanstalk per live demo URL)
Offline Training Pipeline
• Notebook + dataset → trains model → exports *.joblib
• Artifact packaging into repo/deployable slug
Browser → Flask: HTTP POST /predict (or similar) sends product fields
• name, brand, category, condition, shipping, description
Flask → Inference Pipeline: transforms inputs using joblib artifacts
4. Inference Pipeline → Ridge Model: returns log(price) then exponentiate (expm1) to USD
Flask → Browser: returns rendered HTML with
• predicted USD + INR
• analytics data (distributions/positioning)
Browser → Flask: GET /inventory for inventory dashboard
9. Flask → Browser: returns inventory.html + suggested prices per item (computed similarly)
If app.py actually persists anything (unknown from tree), update accordingly.
Architectural patterns / principles to highlight
• Monolith with layered concerns: presentation (templates), application logic (routes), domain logic (dynamic pricing), ML inference (pipeline + model artifacts).
• Model-as-artifact: pre-trained transformers/models loaded at startup, used at request time.
• Separation of offline training vs online inference (even if training code is only a notebook).
Technologies to label
• Flask, Jinja2 templates
• scikit-learn Ridge Regression
• TF-IDF vectorizer, OneHotEncoder/LabelBinarizer (joblib)
• joblib for persistence
• External exchange-rate API (unnamed; label generically)
• AWS Elastic Beanstalk (or “PaaS Host”) + Gunicorn/WSGI
Labels
• Explicit names matching repo files:
• “Flask App (app.py / application.py WSGI)”
• “Model Artifacts (ridge_model.joblib, tv_description.joblib, …)”
• “Templates (templates/index.html, templates/inventory.html)”
• “product metadata JSON/form fields”
• “feature vectors (sparse matrix)”
• “predicted price (USD), adjusted price, converted price (INR)”
Don’t overthink it: maximize component separation (this project benefits from it)
• Preprocessing (text vs categorical) as separate subcomponents
• Base model vs dynamic adjustment
• USD prediction vs INR conversion
• UI vs inventory dashboard routes
• Offline training vs online inference