How harshalal02/todo-app works
Project Type and Purpose
• This is a small full-stack, monolithic Todo application built on Node.js and Express.
• It follows a simple MVC-inspired pattern: Express routes in app.js act as controllers, views/ holds EJS templates for the presentation layer, and a MySQL database stores task data.
High-Level Component Breakdown
a. Client / Browser
• Renders HTML/CSS/JS in the user’s browser.
• Sends HTTP requests (GET for index, POST for adding tasks, POST/DELETE for removing tasks).
b. Web Server (Node.js + Express)
• app.js:
– Configures Express, middleware (bodyParser/static).
– Defines route handlers for “/” (render index.ejs with current tasks) and “/add” or “/delete” actions.
– Manages the MySQL connection (using a driver in app.js).
• Static content middleware serves public/styles.css.
c. View Engine (EJS Templates)
• views/index.ejs: loops through tasks array and renders them as HTML.
d. MySQL Database
• Table “todos” holds id, task, created_at.
• app.js performs CRUD operations via SQL queries.
Architectural Patterns & Design Principles
• MVC-like separation:
• Model: MySQL schema and queries.
• Controller: app.js route handlers.
• View: EJS templates.
• Single-process, single-repo monolith—no microservices.
• Static assets separated under public/ for caching and CDN suitability.