How asaufi/plateforme-immobiliere works
Project type and purpose
• This is a full-stack, server-side-rendered (SSR) web application using the MVC pattern.
• Purpose: manage users and properties with authentication (Passport), routing (Express), views (EJS), and persistent storage (a database accessed via models).
File structure
• Entry point: bin/www.ts → creates HTTP server, loads app.ts
• App configuration: app.ts → sets up Express, view engine, static files, middleware, routes
• Config: config/passportConfig.ts → Passport strategies
• Middlewares: isAuthenticated, isAgent → authorization gates
• Routes: routes/*.ts → route definitions delegating to controllers (implicitly in route handlers)
• Models: models/User.ts, models/Property.ts → data schemas (likely Mongoose)
• Views: views/*.ejs → server-side templates
• Public assets: public/stylesheets/style.css
• Tests: tests/*.ts
Main components and their interactions
a. Client
• Browser requests pages and submits forms; receives HTML/CSS.
b. Express Server (app.ts + bin/www.ts)
• Serves static assets
• Applies middleware chain
• Dispatches to route handlers
c. Middleware Layer
• Logging, body parsing, session management, Passport authentication
• Authorization guards (isAuthenticated, isAgent)
d. Routing Layer
• routes/index.ts, users.ts, auth.ts
• Each route invokes controller logic (inline or delegated)
e. Controller/Handler Logic
• Interacts with models, prepares data, chooses view or redirect
f. Models/Data Access
• models/User.ts, Property.ts define schema and DB methods
g. Views
• EJS templates (index, login, register, properties, etc.) render HTML
h. Tests
Architectural patterns and principles
• MVC: clear separation between Controllers (routes/handlers), Models (data), Views (EJS)
• Middleware pipeline: pluggable request-processing stages (authentication, authorization)
• Single Monolith: all code runs in one Node.js process; no microservices
Final checklist
• All major components (Browser, Express App, Middleware, Routes, Controllers, Models, Database, Views)
• Clear labels indicating filenames or folder names (e.g., “routes/auth.ts”)