How 99sparsh/dbs-project works
Project type and purpose
• This is a full-stack Node.js/Express web application called “Airport Management System.”
• It uses MySQL for persistent storage, Redis (dump.rdb) for session/cache, EJS templates for server-rendered views, and static assets under public/.
File structure
• app.js: main Express entry point
• config/: database (conn.js), authentication (passport.js), Redis setup (redis.js)
• routes/: Express route modules (auth, frontend, airlineadmin, airportadmin, system, etc.)
• schemas/: request/data validation schemas per route
• utils/: async helper (to.js), response formatting, input validation
• views/: EJS templates for each page (login, home, add-entity, schedule, etc.)
• public/: Bootstrap CSS/JS, custom CSS, fonts, client-side JS (add.js, booking.js, airline.js, crew.js, …)
• Airport.sql: schema definition for MySQL
Key architecture notes from README
• Requires Node.js + npm, MySQL, Redis
• Environment configured via .env (template in envexp)
• Run via nodemon
Main components
a. Client browser (User Interface)
• EJS-rendered views + static assets (HTML/CSS/JS in public/)
b. Web Server (Node.js/Express)
• app.js
• Route layer (routes/*.js)
• Validation layer (schemas/*.js + utils/validator.js)
• Business logic (utils/response.js, utils/to.js)
• Authentication (config/passport.js)
c. Data Stores
• MySQL (Airport.sql)
• Redis (session/cache store via config/redis.js)
d. External/Infrastructure
• .env configuration
• nodemon (dev tool)
Relationships and data flows
1. User → HTTP request (click “Add Booking”) → Express router
2. Router → validate input via schemas → call controller logic
3. Controller → interacts with MySQL (via config/conn.js using mysql driver/ORM)
4. Controller → possibly read/write session from Redis
5. Controller → builds response object (utils/response.js) → selects EJS view or JSON
6. Response → client browser: EJS HTML + static JS/CSS
7. Client side JS (public/js/*.js) → may call additional API endpoints (e.g., fetch crew list)
Architectural patterns & principles
• Layered architecture: Presentation (views + public) → Routing → Validation → Business logic → Data access
• Separation of concerns: config, routes, schemas, utils
• MVC‐style: Views (EJS), Controllers (routes + utils), Models (MySQL tables defined via Airport.sql + data access in schemas/config)
• Session management via Redis
• Modularization: each entity (airline, airport, booking, crew, pilot, security, staff) has its own route/schema pair
Elements
• Notes on critical config: .env variables for DB/Redis, Passport strategies