Session 1
Express, MVC & Sequelize
Session Summary
We set up a minimal Express app, separated concerns with MVC, configured env vars, and connected Sequelize to MySQL. We also discussed architecture vs design patterns and what an SPA means for an Express API.
- Express setup + basic routing
- MVC split: routes → controllers → models
- dotenv for configuration
- Sequelize + MySQL connection
- Architecture vs Design Patterns, SPA intro
Questions to think about
- Difference between architecture and a design pattern? Provide 2 examples of each.
- What is an SPA? SPA vs SSR/MPA — how would an Express API serve an SPA frontend?
- When would you prefer ORM (Sequelize) over raw SQL, and vice versa?
Concepts
Architecture vs Design Pattern
- Architecture: high-level system structure (layers/components & interactions).
- Design pattern: reusable code-level solution (e.g., Repository, Strategy, Adapter).
MVC (Model–View–Controller)
- Models = data & persistence logic (Sequelize models).
- Controllers = request/response orchestration.
- Routes = HTTP surface mapping to controllers.
SPA vs SSR/MPA (Express as API)
- SPA renders on the client; Express exposes JSON endpoints.
- SSR/MPA render on the server; trade-offs in SEO, performance, DX.
dotenv & configuration
- Keep secrets/config out of code via
.env. - Load into
process.envearly in app bootstrap.
Challenge — Build Users CRUD
Create a Users CRUD API using Express + Sequelize (MySQL). Include: model definition, migration or sync strategy, basic validation, and routes for list.
Loading gist…