How dang252/nmcnpm_quan_ly_so_tiet_kiem works
Project type and purpose
• This is a full-stack web application (“Đồ án … Quản lý Sổ Tiết Kiệm”) built on Node.js/Express for the back end, Handlebars for server‐side rendering of HTML, vanilla JS/CSS for the front end, and PostgreSQL as the relational database.
• It implements user registration/login (via Passport), CRUD operations on “sổ tiết kiệm” (passbooks), deposit/withdraw flows, user profile management, and balance‐change notifications.
High-level architectural components
a. Client (Web Browser)
• Static assets (HTML/CSS/JS in public/)
• Requests the Express server for dynamic pages (handled by Handlebars templates in views/)
b. Web Server (Node.js + Express – Server.js)
• Routing layer (routes/*.r.js)
• Controller layer (controllers/*.c.js)
• View rendering (views/ + layouts/ + partials/)
• Middleware & Configuration (config/*)
– cnStr.js: DB connection string
– connectDB.js: Sequelize/pg connection setup
– exphbsConfig.js: Handlebars engine setup
– passportConfig.js: Passport.js authentication strategies
c. Data Access Layer (models/*.m.js)
• Sequelize or pg-based models for User and Passbook
d. Database (PostgreSQL)
• Tables created via nmcnpm_postgre.sql
e. External/Internal Services
• Passport.js middleware for authentication
• (Future) Email/Notification service or reporting engine
• Use a three-tier depiction:
1. Presentation Tier (Client)
2. Application Tier (Express)
3. Data Tier (PostgreSQL)
• Components & Layout:
– Static resources (css/, js/, img/)
– Sends HTTP GET/POST to Server.js
– Configuration & Middleware
▶ config/connectDB.js → Database connection
▶ config/passportConfig.js → Auth flow
– Router Layer (routes/*.r.js)
– Controller Layer (controllers/*.c.js)
– View Engine (config/exphbsConfig.js + views/)
– Public folder → static assets
– user table
– passbook table
– Transaction history tables
Relationships & Data Flows
1. Browser → HTTP request → Express Router
2. Router dispatches to Controller
3. Controller invokes Model (via Sequelize or pg client)
4. Model queries PostgreSQL
5. Response streams back: JSON or Handlebars‐rendered HTML
6. Browser updates UI or navigates to new page
7. Authentication:
– Login request → passport.authenticate() in middleware → session cookie → subsequent requests include session
Architectural Patterns & Principles
• MVC (Model-View-Controller) separation
• Layered architecture (Presentation, Application, Data)
• Single Express instance as monolith server (future scope: microservices)
• Configuration segregation (config folder)
• RESTful routes for resource handling