How pv2k3/ecomweb works
Main Components
A. Frontend Layer:
• Client-Side Views (EJS Templates)
• Static Assets (CSS, Images)
• Client-Side Scripts
B. Backend Layer:
• Express Server
• Authentication Middleware
• Controllers
• Services
• Routes
C. Database Layer:
• MongoDB Database
• Mongoose Models
Component Relationships and Structure
[Client Layer] → [Application Layer] → [Data Layer]
Detail each layer as follows:
A. Client Layer (Top):
• Main Views (home, store, admin, account)
• Partials (navbar, footer, etc.)
• CSS Files
• Images
B. Application Layer (Middle):
• Surrounding components:
1. Routes Module:
• Admin Routes
• Buy Routes
• Image Routes
• Static Routes
2. Controllers Module:
• Main Controllers
• Helper Functions
3. Middleware:
• Authentication
• Authorization
4. Services:
• Auth Service
C. Data Layer (Bottom):
• MongoDB Database containing models:
• USER Model
• STOCK Model
• IMAGES Model
Flow Indicators
• HTTP Request flow from Client → Server
• Authentication flow through Middleware
• Data flow between Controllers and Database
• Response flow back to Client
Technical Stack Indicators
• Node.js/Express
• MongoDB/Mongoose
• EJS Template Engine
• JWT Authentication
• Cookie Parser
• Multer (for image handling)
Additional Notes
• Clear separation between admin and user functionalities
• Where password encryption happens
• Routes that require authentication
• Image upload/storage flow