How keshavadk/iris-flower-species-streamlit_fastapi works
Project type and purpose
• This is a simple full-stack machine-learning web application.
• The backend (FastAPI) serves an Iris predictor API and persists a trained model.
• The frontend (Streamlit) provides a UI with sliders and invokes the API to display predictions.
File structure
• Top-level:
• backend/ – contains app.py (FastAPI) and iris_model.joblib
• frontend/ – contains streamlit_app.py (Streamlit UI)
• requirements.txt – lists all Python dependencies
• Key patterns:
• Two-tier architecture (UI + API)
• Model persistence (joblib)
• One Python virtual environment
README for additional insights
• The README describes startup steps:
• Train or load model on first backend launch
• FastAPI exposes “/” (health) and “/predict” endpoints
• Streamlit frontend POSTs to /predict and renders results
a. Main components:
1. Client Browser (or local machine)
2. Streamlit Frontend
3. FastAPI Backend (app.py)
4. Model Trainer/Loader
5. Persisted Model File (iris_model.joblib)
6. Python Virtual Environment & Dependencies
b. Relationships and interactions:
• User interacts with Streamlit UI via browser.
• Streamlit sends HTTP POST requests to FastAPI /predict.
• FastAPI loads/trains the model (first run) via Model Trainer/Loader.
• Model Trainer/Loader reads/writes iris_model.joblib.
• FastAPI returns JSON response back to Streamlit, which displays results.
c. Architectural patterns/design principles:
• Separation of concerns: UI vs. API vs. ML logic
• Stateless API calls (each request uses the persisted model)
• Model persistence for faster subsequent predictions
d. Relevant technologies/frameworks:
• Python venv (isolated environment)
• FastAPI & Uvicorn (API server)
• scikit-learn & joblib (model training & serialization)
• Streamlit (frontend)
Detailed guidance
• Model Trainer/Loader
• iris_model.joblib storage
• At the bottom or corner, annotate the virtual environment & requirements.
• Notes on first-run training versus subsequent predictions.