How arinjay-srivastava/notepad_project_web works
Project Type and Purpose
• NotePad is a full-stack web application for user-authenticated note management.
• Frontend: static HTML/CSS/JS in public/.
• Backend: Node.js with Express.js in the project root (index.js), routing logic under server/routes/, data models under server/models/.
• Persistence: MySQL database accessed via the MySQL2 driver and configured by dotenv.
Key Architectural Patterns
• MVC-like separation:
• Model layer in server/models/ (ORM-style objects for User and Note).
• Controller layer in server/routes/ (Express routers for user and note endpoints).
• View layer as static assets in public/.
• RESTful API: CRUD endpoints for notes and authentication.
• Soft-delete pattern for notes and user accounts (business rule).
• Client Browser
• Static UI pages: Login.html, Register.html, notes.html, index.html.
• Frontend JS modules: user.js, note.js, note.js (public/note.js), CSS styling.
• HTTP/API Layer
• Express.js server (index.js) listening on PORT.
• Middleware: body-parsing, session/auth (if used).
• Route Handlers
• /api/user router (register, login, soft-delete).
• /api/note router (create, read, update, soft-delete).
• Model/Data Access
• db_connect.js establishes connection pool to MySQL.
• user.js and note.js define methods for CRUD plus soft-delete logic.
• MySQL Database
• Tables: users, notes with one-to-many relationship (user_id foreign key).
• External Configuration
• .env for host, user, password, database name, port.
• Development Tools
• Nodemon for auto-restarts, dotenv for env loading, MySQL2 driver.
Relationships and Data Flow
• Browser → HTTP(S) requests → Express server
• Express middleware → route-specific controllers → model methods → MySQL queries
• Query results returned up chain → controller → JSON → browser → DOM updates
• Clear labels on each component (e.g., “Login Page”, “User Router”, “Note Model”).