How ahr-array/dbms_project works
Project Type and Purpose
• This is a full-stack, server-rendered web application built with Node.js/Express, EJS templates, and MySQL.
• Purpose: manage warehouse inventory, perform billing, and analyze stock/sales via dynamic pages and filters.
File Structure
• Top-level files:
• server.js – application entry point
• passport-config.js – authentication setup
• package.json – dependencies, scripts
• .env / process.env – credentials & secrets
• Procfile – Heroku deployment
• error.log – runtime logs
• Directories:
• public/ – static assets (CSS)
• views/ – EJS templates for each feature (stocks, bills, analysis, auth)
README Insights
• Tech stack: Node, Express, MySQL, JS, Bootstrap, Semantic-UI.
• Features: stock inventory, billing (PDF generation), sales/stock analysis, Passport authentication.
• Deployment: runs on localhost:5000, environment variables configure DB & admin credentials.
Main Components
a. Client Layer
• Browser (User Interface)
• Static Assets: CSS, JS (public/)
b. Web Server Layer
• Node.js + Express
• Middleware:
• Passport.js for authentication
• body-parser, static-file serving
• Route Handlers (defined in server.js; map URL → EJS view + DB operations)
• Template Engine: EJS (views/*.ejs)
c. Data Layer
• MySQL Database (warehousedb)
• Tables: stocks, orders, brands, categories, sizes, users, sales
d. External/Deployment
• Heroku (Procfile) or any PaaS
• Environment configuration (.env)
• PDF Generation (via EJS → PDF on billing view)
Relationships & Data Flow
1. User in browser issues HTTP(S) request (login, view stocks, bill creation).
2. Express middleware authenticates (Passport) or rejects.
3. Valid requests hit route handler → business logic (CRUD queries to MySQL).
4. Query results → EJS renders HTML → sent back to browser.
5. On “print bill,” server compiles bill.ejs into printable PDF.
6. Logs (error.log) capture runtime errors; environment variables supply DB credentials & secrets.
Architectural Patterns & Principles
• MVC-style separation:
• Model = MySQL tables + queries
• View = EJS templates
• Controller = Express route handlers
• Middleware pipeline for authentication & parsing
• Layered architecture: Presentation → Application → Data
• Configuration via 12-factor app (.env, Procfile)