How rawanbakrali/egypt-through-the-ages works
Purpose and Runtime
This is a server-rendered Node.js/Express application for exploring historical eras and places, viewing and submitting events, tracking a user’s place status, and posting reviews. It renders EJS pages while exposing route-backed APIs consumed by browser JavaScript. The main bootstrap is app.js; dependencies and scripts are defined in package.json.
HTTP Entry and Request Pipeline
app.js mounts feature route modules, configures rendering/static assets, and centralizes application middleware. Routes divide public pages from domain operations:
• Page rendering: routes/pageRoutes.js, controllers/pageController.js
• Auth: routes/authRoutes.js, controllers/authController.js
• Domain APIs: routes/eventsRoutes.js, routes/placesRoutes.js, routes/reviewsRoutes.js
Authentication, validation, uploads, and error translation form request boundaries in middleware/auth.js, middleware/validators, middleware/upload.js, and middleware/errorHandlers.js.
Server-rendered UI and Client Behavior
EJS views are the page composition layer, with reusable partials for navigation, era/event displays, review input, and administrative rows. Core pages include views/home.ejs, views/era.ejs, views/events.ejs, views/event.ejs, views/profile.ejs, and views/admin.ejs. Browser modules invoke feature endpoints and update page state: public/js/events.js, public/js/reviews.js, public/js/place-status.js, public/js/profile.js, and public/js/map.js. Static styles and media are served from public/css and public/assets.
Identity, Access, and User State
Authentication is handled through authController and enforced by middleware/auth.js; client-side guards support protected UI flows in public/js/auth-guard.js. User persistence and user-place relationship state are represented separately:
• models/User.js
• models/UserPlaceStatus.js
• controllers/userPlaceStatusController.js
This separation supports per-user tracking of places independently from globally defined place records.
Historical Content Domain
The core content model centers on eras, places, events, and reviews. Persistent model definitions are in models/Event.js, models/Place.js, and models/Reviews.js; their API orchestration lives in controllers/eventsController.js, controllers/placesController.js, and controllers/reviewsController.js. Era-oriented presentation is driven by views/era.ejs and public/js/era.js, while events have both listing and detail views.
Administrative Submission and Media Flow
Event submission and administration are distinct workflow surfaces, indicated by views/partials/event-submission-modal.ejs, views/admin.ejs, and public/js/admin.js. Upload requests pass through routes/uploadRoutes.js, controllers/uploadController.js, and middleware/upload.js, isolating file handling from normal content mutation. Validation modules such as middleware/validators/eventsValidators.js guard incoming domain payloads before controller/model processing.
Data Initialization and External Boundaries
The repository includes static/source datasets under data, plus operational scripts migrate-data.js and seed-admin.js for initial migration and administrative account setup. The model layer is the database boundary; its exact database provider is not identifiable from the supplied tree. Mapping is browser-side (public/js/map.js); the README indicates map tiles are visually grayscaled using a CSS filter rather than a paid grayscale tile provider.
Main entry points: app.js Application bootstrap · home.ejs EJS pages and partials · migrate-data.js Migration and admin setup · userPlaceStatusController.js User place status
Components 18
Express server
- Application bootstrap · Configures rendering, static assets, middleware, and route mounts.
app.js - Feature routes · Page, auth, event, place, review, and upload endpoints.
- Request boundaries · Authentication, validation, uploads, and error translation.
middleware/auth.js
Rendered UI
- Page controller
controllers/pageController.js - EJS pages and partials · Composes home, era, event, profile, admin, and reusable UI.
views/home.ejs - Browser feature modules · Calls APIs and updates event, review, status, profile, era, and map UI.
public/js/events.js - Static assets
public/css
Content domain
- Content controllers · Orchestrates event, place, and review APIs.
controllers/eventsController.js - Historical content models · Persistent events, places, and reviews; database provider is unspecified.
models/Event.js
Identity and status
- Auth controller
controllers/authController.js - Client auth guard
public/js/auth-guard.js - User records
models/User.js - User place status · Stores each user's status independently of global places.
controllers/userPlaceStatusController.js - User-place state
models/UserPlaceStatus.js
Operations
- Media upload flow · Separates file handling from normal content mutation.
routes/uploadRoutes.js - Admin and event submission
views/admin.ejs - Source datasets
data - Migration and admin setup
migrate-data.js
Connections 25
- Application bootstrap → Feature routes: mounts
- Application bootstrap → Request boundaries: applies
- Application bootstrap → EJS pages and partials: renders
- Application bootstrap → Static assets: serves
- Feature routes → Page controller: page requests
- Feature routes → Auth controller: auth requests
- Feature routes → Content controllers: domain APIs
- Feature routes → User place status: status APIs
- Feature routes → Media upload flow: upload endpoint
- Request boundaries → Feature routes: guards requests
- Page controller → EJS pages and partials: selects pages
- EJS pages and partials → Browser feature modules: loads modules
- EJS pages and partials → Static assets: uses
- Browser feature modules → Feature routes: calls APIs
- Client auth guard → Auth controller: supports protected flows
- Auth controller → User records: reads and writes
- User place status → User-place state: reads and writes
- User place status → User records: identifies user
- Content controllers → Historical content models: reads and writes
- Media upload flow → Request boundaries: uses upload handling
- Admin and event submission → Browser feature modules: uses admin behavior
- Admin and event submission → Feature routes: submits content
- Migration and admin setup → Source datasets: imports
- Migration and admin setup → User records: seeds administrator
- Migration and admin setup → Historical content models: migrates content