How smi0001/crudapp works
Project Type and Purpose
• This is a full-stack CRUD web application built on Node.js/Express with MongoDB as the data store. It uses EJS for server-side page rendering and serves CSS/JS assets from a static folder. It’s deployed on Heroku.
Main Architectural Components
a. Client Side
• Web Browser
• Static assets (HTML, CSS, JS, fonts, images) under /static
• EJS templates under /views
b. Server Side
• Node.js runtime
• Express application (defined in server.js)
• Configuration loader (config.js, _config.yml)
• Route handlers (CRUD endpoints)
• Template engine integration (EJS)
c. Database
• MongoDB instance (e.g., mLab addon on Heroku)
d. Platform/Infrastructure
• Heroku dyno
• GitHub (source code repository)
• Heroku CLI & build pipeline
Relationships and Data Flow
• The Browser initiates HTTP requests to the Express server (hosted on a Heroku dyno).
• Express routing logic in server.js directs each request to the appropriate controller:
• GET routes fetch data from MongoDB via Mongoose
• POST/PUT/DELETE routes modify data in MongoDB
• Controllers pass data to EJS templates, which render HTML.
• The server responds with HTML pages or JSON (if it exposes any API endpoints).
• Static middleware serves files under /static directly to the client.
• Configuration (e.g., database URI, port) is read from config.js and environment variables (Heroku’s PORT, MONGODB_URI).
Architectural Patterns & Design Principles
• MVC-style separation:
• Model: MongoDB collections accessed via Mongoose
• View: EJS templates
• Controller: Express route handlers in server.js
• Convention-over-configuration:
• Static assets in one folder
• Views in one folder
• Twelve-factor app practices for Heroku:
• Configuration in environment variables
• Procfile (optional) for process declaration
• Git-based deployments
Detailed Checklist
• [ ] Heroku Platform layer
• [ ] Express server component (server.js, config.js)
• [ ] Static assets folder (/static)
• [ ] View layer (/views)