How gautam23145032/streamoid_project works
Project Type and Purpose
• This is a full-stack, server-rendered web application (“Streamoid Product Catalog”) built with Node.js/Express for the backend, EJS/CSS for the frontend, and MongoDB for persistence.
• Primary use case: allow users to upload product CSV files, validate rows, store valid products in MongoDB, and search/filter the catalog in a clean UI.
File Structure
• Top-level:
• public/ → static CSS assets
• views/ → EJS templates (home.ejs)
• src/
– config/db.js → MongoDB connection
– controllers/viewController.js → handles upload, validation, search, render
– middleware/ → Multer upload config + global error handlers
– models/productModel.js → Mongoose schema + indexes
– routes/viewRoutes.js → defines Express routes
– utils/csvValidator.js → per-row validation logic
– app.js → Express app setup (middleware, view engine, static folders)
– server.js → application entry point
• .env → environment variables for DB URI and port
• uploads/ → temporary storage for CSV files
• Pattern: monolithic MVC-style architecture, single Express service.
README for Additional Insights
• Confirms the MVC separation: routes → controllers → models
• Details key tech: Multer for file upload, csv-parser for streaming CSV rows, Morgan for logging, dotenv for config.
• Describes error-handling flow (404 and global handlers).
a. Main Components
1. Client Browser (UI):
– EJS-rendered HTML + CSS → CSV upload form, filter/search form, product table
2. Express Server:
– Routes layer (viewRoutes.js)
– Middleware: Multer (upload.js), error handlers (errorMiddleware.js)
– Controllers (viewController.js)
– Utility (csvValidator.js)
3. File Storage:
– Local “uploads/” directory (temporary CSV storage)
4. Database:
5. External Libraries & Services:
– csv-parser, Mongoose, Morgan, dotenv
b. Relationships and Data Flow
• uploads/ → csv-parser → csvValidator → Controller → Mongoose insert → MongoDB
• Controller → delete CSV file → render results back to Browser
• Browser → GET /?filters → Controller builds MongoDB query → Browser receives filtered list
• Global errorMiddleware intercepts failures → returns JSON or error view
c. Architectural Patterns and Principles
• MVC: clear separation of concerns (Views, Controllers, Models)
• Single-process monolith: all modules run in one Node.js instance
• Streaming and backpressure: csv-parser processes row-by-row to avoid memory bloat
• Indexing in DB for query performance
d. Key Technologies & Frameworks
• Node.js + Express.js (server framework)
• EJS (view engine)
• Multer (multipart handling)
• csv-parser (stream CSV)
• Mongoose + MongoDB (ORM + database)
• Morgan (HTTP logging)
• dotenv (environment config)