An AI-powered backend platform for predicting microbial protein yield from agri-food waste streams and generating LLM-assisted decision-support insights.
This project was designed as a production-oriented AI platform prototype focused on backend architecture, API engineering, cloud deployment, ML inference, and LLM integration.
Live Demo: https://waste2protein-backend.onrender.com
Millions of tonnes of nutrient-rich agri-food waste are generated globally every day. These waste streams may be upcycled into sustainable microbial protein through fermentation processes.
This platform enables users to:
- Predict microbial protein yield from waste-stream composition
- Generate AI-assisted decision-support insights
- Receive microbial candidate recommendations
- Identify limiting fermentation factors
- Generate R&D roadmap suggestions
- Estimate early-stage economic feasibility
- Trained Random Forest regression model
- Protein yield prediction
- Uncertainty estimation
- Structured prediction responses
Integrated Groq-hosted LLM for:
- Microbial candidate recommendations
- Limiting factor identification
- Fermentation recommendations
- R&D roadmap generation
- Scientific decision-support summaries
- Graceful fallback to rule-based responses if LLM unavailable
- Scenario-based protein yield revenue estimation
- Processing cost modelling
- Economic viability scoring
- Configurable pricing via environment variables
- FastAPI backend architecture
- Modular service-based design
- Pydantic request validation
- OpenAPI / Swagger documentation
- Dockerized deployment
- Public cloud deployment on Render
- GitHub Actions CI/CD pipeline — tests gate deployment
- Automated testing with Pytest
- PostgreSQL database integration
- Redis caching layer
- Structured logging across all services
- Real-time LLM cost tracking
- Health check endpoint with dependency reporting
- Environment-based configuration
- Graceful LLM fallback handling
Frontend / Client
↓
FastAPI Backend API
↓
Redis Cache Check
↓ HIT ↓ MISS
Return Cached Prediction Service (ML Model)
Response ↓
LLM Insight Service (Groq)
↓
Economics Service
↓
Cost Tracker
↓
PostgreSQL Database
↓
Store in Redis Cache
↓
Return Response
waste2protein-ai-copilot/
│
├── backend/
│ ├── app/
│ │ ├── main.py
│ │ ├── schemas.py
│ │ ├── routes/
│ │ │ ├── health.py
│ │ │ ├── predict.py
│ │ │ ├── history.py
│ │ │ └── insights.py
│ │ ├── services/
│ │ │ ├── prediction_service.py
│ │ │ ├── llm_service.py
│ │ │ ├── cost_tracker.py
│ │ │ ├── cache_service.py
│ │ │ ├── economics_service.py
│ │ │ └── dependencies.py
│ │ ├── model/
│ │ │ └── protein_model.pkl
│ │ ├── database.py
│ │ ├── logger.py
│ │ │
│ ├── tests/
│ │ ├── test_api.py
│ ├── Dockerfile
│ ├── requirements.txt
│ └── pytest.ini
│ │
├── ml/
│ ├── generate_synthetic_data.py
│ ├── train_model.py
│ └── sample_protein_data.csv
│
├── .github/
│ └── workflows/
│ └── backend-ci.yml
│
├── README.md
└── .gitignore
git clone https://github.com/Subasranaa/waste2protein-ai-copilot.git
cd waste2protein-ai-copilotMove into backend directory:
cd backendCreate virtual environment:
python3 -m venv venvActivate virtual environment:
source venv/bin/activatevenv\Scripts\activatepip install -r requirements.txtCreate a .env file inside the backend/ directory:
backend/.env
Add the following variables:
LLM_PROVIDER=groq
GROQ_API_KEY=your_groq_api_key
GROQ_MODEL=llama-3.3-70b-versatile
LOG_LEVEL=DEBUG
PROTEIN_PRICE_PER_KG_GBP=4.5
PROCESSING_COST_PER_KG_GBP=1.2
DATABASE_URL=your_postgresql_url
REDIS_URL=your_redis_url (optional locally)uvicorn app.main:app --reloadBackend will run at:
http://127.0.0.1:8000
Swagger API documentation:
http://127.0.0.1:8000/docs
Landing page:
http://127.0.0.1:8000
Open another terminal.
Activate virtual environment again:
cd backend
source venv/bin/activateRun tests:
pytestdocker build -t waste2protein-backend ./backenddocker run -p 8000:8000 --env-file backend/.env waste2protein-backendOpen:
http://127.0.0.1:8000/docs
GitHub Actions is configured to run backend tests automatically on every push to main, and deploys to Render only if all tests pass.
Workflow file: .github/workflows/backend-ci.yml
The pipeline:
- Checks out repository
- Sets up Python 3.11
- Installs dependencies
- Runs Pytest test suite
- If tests pass → triggers Render deployment automatically
- If tests fail → deployment is blocked
This is an early-stage prototype.
- The training dataset is synthetic.
- Protein yield predictions are for demonstration only.
- Economic estimates are scenario-based and simplified.
- Microbial recommendations require laboratory validation.
- This system should not be used as a substitute for experimental fermentation studies.
- Replace synthetic data with real experimental data
- Model monitoring and drift detection
- Authentication and rate limiting
- Stakeholder dashboard
- Bayesian optimisation
- Multiple LLM provider routing
- AWS ECS / Azure for production-scale hosting
- DVC integration for model versioning and reproducibility
- CloudWatch monitoring for production observability