Skip to content

neeldas0032/patternpivot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PatternPivot

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.


What This Is

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.


Repo Structure

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

Quick Start

Backend

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 8000

Backend runs at http://localhost:8000 API docs (Swagger): http://localhost:8000/docs

Frontend

cd frontend
npm install
npm run dev

Frontend runs at http://localhost:5173

First-time setup

  1. Open http://localhost:5173
  2. Register a new user
  3. Log in
  4. Create a new product, upload 8-10 "good" sample images
  5. Try the Live Inspection page - upload any image, see defect probability

Architecture

+---------------------------------------------------+
|              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.


Security Features

  • 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

Tech Stack

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)

Development Notes

  • 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.seed for demo data.

For Your Final Year Project Defense

Key talking points and technical depth are documented in docs/DEFENSE_GUIDE.md.

License

MIT (for your project; adjust as needed).

About

Affordable self-learning machine vision QC for MSMEs — 15-min retraining, 40× cost reduction, retrofit design. Full-stack: FastAPI + PyTorch + React + Three.js.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages