How akash-selvaraj/pcb-defect-detection works
Project Type and Purpose
• This is a full-stack web application combining:
• A Next.js (React) frontend for UI/UX
• A Python-based backend (likely Flask or FastAPI) that loads a pre-trained PyTorch model (model_final.pth) and runs inference based on YAML configs
• Purpose: Serve a single-page/web-app interface that sends image/data to the backend, performs object-detection inference, and returns results to the user.
File-Structure Analysis
• Top-level files
• Configuration: .eslintrc.json, tsconfig.json, tailwind.config.ts, postcss.config.mjs
• Next.js config: next.config.ts
• Package manager: package.json, package-lock.json
• Frontend (Next.js)
• src/app/ – React components, layout.tsx (root layout), page.tsx (entry page), globals.css, custom fonts
• src/utils/api.ts – wrappers for HTTP calls to the backend
• public/ – static assets (e.g. front.pdf)
• Backend (Python)
• backend/app.py – main application (Flask/FastAPI) exposing inference endpoints
• backend/model/model_final.pth – serialized ML model
• backend/yaml/… – Detectron2 or SSD/FPN configuration files
• backend/requirements.txt & requirements_cpu.txt – Python dependencies
README Insights
• Standard Next.js scaffolding; no mention of DB or caching layer
• No built-in instructions for the backend—implies it runs as a separate service
Main Components & Relationships
a. Frontend Layer (Next.js)
– Runs in the browser (SSR or static)
– Hosts UI, routes, styling (Tailwind), and calls backend via src/utils/api.ts
b. API/Backend Service
– Python server (Flask/FastAPI)
– Endpoint(s) for image/data upload → model inference → JSON response
c. ML Model Storage
– Local disk or external volume holding model_final.pth
– YAML config files guiding model architecture and hyperparameters
d. External/Infrastructure (optional)
– Deployment: Vercel for Next.js, Docker/Kubernetes or EC2 for backend
– (Optional) Cloud storage or volume for model artifacts
Architectural Patterns & Principles
• Separation of Concerns: UI layer vs. inference service
• Microservice-style: Frontend and backend deployed independently
• Configuration-driven model loading (YAML + .pth)
• Utility layer (api.ts) abstracts HTTP calls and enforces type safety