How achrefsola/stockoversight works
Project Type & Purpose
• Full-stack web application (MERN stack)
• Provides user authentication, product/order/supplier management, real-time stock updates, and billing.
High-Level Components
A. Client (React Single Page App)
– React Router (navigation)
– Context API (global state – e.g., authentication, manager context)
– Components (AddProduct, OrderList, Dashboard, Bill, etc.)
– Pages (Login, Register, Dashboard, Products, Orders, Suppliers, Settings)
– Static assets (CSS, images)
B. API Server (Node.js + Express)
– Routes (category, product, order, supplier, manager)
– Controllers (business logic per route)
– Models (Mongoose schemas for MongoDB)
– Config (Multer for file uploads)
– Middleware (JWT authentication, error handling)
C. Database
– MongoDB (collections: managers, categories, products, orders, suppliers)
D. Authentication
– JWT issuance and verification
– Role-based access control in routes
E. DevOps / Deployment
– Docker (containerize frontend & backend)
– Kubernetes (manifests/Helm charts for deployment)
– ArgoCD (GitOps continuous delivery)
– CI/CD pipeline (GitHub Actions or Jenkins for build/test/deploy)
Architectural Patterns & Principles
• MVC-ish structure on server (Routes → Controllers → Models)
• RESTful API between frontend and backend
• Single Page App on client side
• Separation of concerns: UI / API / Data layers
• Stateless server with JWT for session state
• Containerization & GitOps for scalable deployment
Relationships & Data Flow
1. User (Browser)
→ loads React app from Web Server (via NGINX or Node static serve)
→ interacts with UI components
2. React app
→ sends HTTP(S) requests to Express API (e.g., GET /api/products)
→ attaches JWT in Authorization header
3. Express server
→ authenticates JWT middleware
→ routes request to corresponding controller
→ controller uses Mongoose model to query MongoDB
→ responds with JSON data
4. React app
→ updates UI based on response (e.g., re-render product list)
5. File uploads (e.g., manager picture)
→ frontend posts multipart/form-data → Multer stores file → controller updates manager record
6. Billing / Reports
→ server generates PDF or static bill view → frontend displays / triggers print
Final Composition
• Top-left: Browser/React SPA (blue)
• Center: Express API (green)
– Collections: managers, categories, products, orders, suppliers
• Side: DevOps Layer (orange)
– CI/CD pipeline → Docker Registry → Kubernetes cluster → ArgoCD