Affordable Self-Learning Machine Vision Quality Inspection System for Small-Batch MSME Manufacturing
A full-stack prototype showcasing a real-time, few-shot machine vision quality control system built for the MSME sector. Designed as a final-year B.Tech CSE (AIML) project demonstrating Industry 4.0 & 5.0 principles.
PatternPivot is an operator-configurable quality inspection system that lets any shop-floor worker set up automated defect detection for a new product in under 15 minutes using just 8-10 smartphone photographs. This repo is a working end-to-end prototype: 3D-rendered marketing/architecture site, secure backend API, ML inference engine, live inspection dashboard, and active-learning feedback loop.
patternpivot/
├── backend/ FastAPI + PyTorch + SQLite; auth, ML, database
│ ├── app/ Application code (routes, ml, db, security)
│ ├── tests/ pytest suite
│ └── requirements.txt
├── frontend/ React + Vite + Three.js + Tailwind
│ ├── src/ Components, pages, hooks, API services
│ └── package.json
└── docs/ Architecture and API documentation
cd backend
python -m venv venv
# Windows: venv\Scripts\activate
# Linux/Mac: source venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reload --port 8000Backend runs at http://localhost:8000
API docs (Swagger): http://localhost:8000/docs
cd frontend
npm install
npm run devFrontend runs at http://localhost:5173
- Open
http://localhost:5173 - Register a new user
- Log in
- Create a new product, upload 8-10 "good" sample images
- Try the Live Inspection page - upload any image, see defect probability
+---------------------------------------------------+
| FRONTEND (React + Three.js) |
| Landing (3D) | Auth | Dashboard | Inspect |
+-----------------------+---------------------------+
| HTTPS + JWT
v
+---------------------------------------------------+
| BACKEND (FastAPI + PyTorch) |
| Auth | Products | ML Inference | Feedback |
+-----------------------+---------------------------+
|
+---------------+----------------+
| |
v v
+----------+ +-----------+
| SQLite | | PyTorch |
| metadata | | ViT / kNN |
+----------+ +-----------+
Full detail in docs/ARCHITECTURE.md.
- JWT-based authentication with 30-minute access tokens
- Bcrypt password hashing (cost factor 12)
- Pydantic input validation on every endpoint
- CORS whitelist (only configured origins allowed)
- Rate limiting (per-IP, per-endpoint)
- Secure HTTP headers (HSTS, X-Frame-Options, CSP)
- File upload size and type validation
- SQL injection prevention via SQLAlchemy ORM
- Encrypted local storage for uploaded images
- No secrets in code - all in
.env
| Layer | Tools |
|---|---|
| Frontend | React 18, Vite, React Router, Three.js + react-three-fiber, Tailwind CSS, Axios |
| Backend | FastAPI, Uvicorn, SQLAlchemy, Pydantic, python-jose, passlib |
| ML | PyTorch, torchvision, scikit-learn (for kNN), Pillow |
| Database | SQLite (dev) / PostgreSQL-ready (prod) |
| Auth | JWT (RS256/HS256), bcrypt |
| Deployment | Docker + docker-compose (included) |
- Demo mode: the ML backend uses a lightweight ResNet18 feature extractor by default. For production, swap to DINOv2 or PatchCore in
backend/app/ml/feature_extractor.py. - No real hardware needed: you can test end-to-end by uploading any image files as "camera" input.
- Database seeds: run
python -m app.seedfor demo data.
Key talking points and technical depth are documented in docs/DEFENSE_GUIDE.md.
MIT (for your project; adjust as needed).