How devit-tech/btl_tsr_dbds works
Project type and purpose
• This is a full-stack ML forecasting system (“BTL_TSR_DBDS”) that trains deep-learning (LSTM, Autoformer, DistilBERT) models on historical sales time-series and product metadata, exposes a Flask API for programmatic forecasting, and provides a Streamlit UI for interactive demo on a cloud server.
File structure
• Top-level directories:
• data/sales_history/ : raw CSV time-series per ASIN
• best_models/ : serialized PyTorch (.pt) model artifacts
• logs/ : TensorBoard training logs per ASIN
• src/ : source code
‣ model.py : defines the neural architectures
‣ inference.py : loads models, runs forecasting routine
‣ api.py : Flask REST API endpoints for prediction
‣ app.py : Streamlit front-end application
• Config/dependencies: requirements.txt, README.md
Extract architectural clues from the README
• Two serving paths: Flask API (backend micro-service) and Streamlit UI (frontend demo)
• Training pipeline is implied but code lives in model.py and inference.py
• Data flows from CSV → training → model store; inference loads model → returns forecast
Main components & their interactions
a. Data Layer
• CSV Sales History in data/sales_history
• Product metadata (title, price, rating) either bundled or fetched at runtime
b. Training Pipeline
• Reads CSVs, invokes model architectures (model.py), logs training to logs/, saves best .pt in best_models/
c. Model Storage
• Repository of versioned .pt artifacts in best_models/
d. Inference Module
• inference.py loads chosen .pt, pre-processes input, returns next-day prediction
e. API Service (Flask)
• Exposes REST endpoint (/predict) that invokes inference.py and returns JSON forecast
f. Frontend (Streamlit)
• Renders product list, historical charts (matplotlib), calls either inference.py directly or the Flask API to display forecasts
g. Hosting / Infrastructure
• Cloud server hosting both the Flask service and the Streamlit app
h. Logging/Monitoring
• TensorBoard logs in logs/ for training metrics
Important architectural patterns & design principles
• Separation of Concerns: distinct training, storage, inference, API, and UI layers
• Modular ML pipeline: model definitions (model.py) abstracted from inference logic (inference.py)
• Micro-service style: the Flask API can be independently deployed and scaled
• Artifact versioning: best_models folder holds per-ASIN best checkpoints
2. Inside Training Pipeline, list sub-steps: load CSV, preprocess, train model (model.py), log metrics to “logs/”, save to “best_models/”.
a. direct to Inference Module (via inference.py import)
b. HTTP call to Flask API
6. Surround API & UI with a “Cloud Server” boundary.
7. Client symbol (browser) pointing to Streamlit UI and/or API.
8. “TensorBoard” component connected to logs/ for monitoring.