A powerful, lightweight web-based platform for deploying machine learning models with auto-generated Gradio interfaces, secured by JWT authentication and isolated with Docker containers.
ModelForge abstracts away the complexity of ML deployment. Simply upload your model and a configuration file, and the platform handles:
- Auto-UI Generation: Creates a full Gradio interface based on your model's task (Classification/Regression).
- Secure Isolation: Runs each model in a separate Docker container with strict resource limits.
- Persistent Management: Tracks all deployments in a SQLite database.
- Access Control: JWT-based authentication ensures only authorized users can deploy or manage models.
webtech-project/
├── backend/
│ ├── main.py # FastAPI orchestrator
│ ├── auth.py # JWT + bcrypt security
│ ├── config_validator.py # Pydantic schema validation
│ ├── app_generator.py # Dynamic Gradio code generation
│ ├── docker_manager.py # Docker SDK lifecycle management
│ └── database.py # SQLite persistence layer
├── frontend/
│ ├── src/ # React source (App.jsx, main.jsx)
│ ├── tailwind.config.js # UI Design System
│ └── vite.config.js # Fast build configuration
├── tests/ # Sample models and test scripts
└── v3_modelforge.md # Full project report
- Python 3.10+
- Node.js 18+
- Docker Desktop or Docker Engine installed and running
# It is recommended to use the virtualenv provided in the parent directory
source ../venv/bin/activate
cd backend
# Install dependencies if not already done
pip install -r ../requirements.txt
# Start the API server
python main.pyThe API will be available at http://localhost:8000
cd frontend
npm install
npm run devAccess the dashboard at http://localhost:5173
ModelForge uses a stateless JWT authentication system:
- Register/Login: Users create an account or sign in through the dashboard.
- Token Storage: A JWT token is stored in
localStorage. - Protected Actions: Deploying, stopping, or cleaning up containers requires the token to be sent in the
Authorizationheader. - Security: Passwords are never stored in plaintext (secured with
bcrypt).
Each model requires a config.json to define its interface:
{
"framework": "sklearn | pytorch | onnx",
"task": "classification | regression",
"input": {
"type": "numeric | text | image",
"features": 4 // Required for numeric
},
"output": {
"type": "label | number | text"
}
}We provide pre-trained sample models in the tests/ directory.
Quick Test via cURL (Requires Auth Token):
# 1. Login to get token
# 2. Deploy sample classifier
curl -X POST http://localhost:8000/deploy-model \
-H "Authorization: Bearer <YOUR_TOKEN>" \
-F "model_file=@tests/test_classifier.pkl" \
-F "config_file=@tests/test_classifier_config.json"- Container Isolation: Each model runs in its own sandbox.
- Resource Limits: 512MB RAM and 0.5 CPU core maximum per container.
- Non-Root Guard: Containers execute as an unprivileged
appuser. - JWT Protection: destructive API endpoints are gated behind token validation.
- Input Sanitization: Strict Pydantic validation on all uploaded configurations.
main.py: The central FastAPI hub.auth.py: Manages registration, login, and token verification.app_generator.py: The logic engine that "writes" Python code for the model UI.docker_manager.py: Builds images from templates and manages container state.database.py: SQLite adapter for deployment and user data.
For deeper details, refer to:
Developed for the Web Technologies and Applications (IT254) course.