How henrybhudson/pay-it-forward works
Project type and purpose
• Pay it Forward is a full-stack web application.
• Front end: static HTML/JS/CSS in the “client” folder, providing pages for index, login, registration, and chain interactions.
• Back end: Node.js + Express in the “server” folder exposing RESTful endpoints.
• Persistence: flat-file JSON database (users.json, chains.json, events.json).
File structure
• Top-level folders:
– client/ (static UI)
– client_old/ (previous version of UI)
– server/ (API server)
• server/ subfolders:
– routes/ (defines HTTP endpoints in userRoutes.js)
– controllers/ (request handlers in userController.js)
– database/ (JSON files as the data store)
• Core files: server/index.js (Express app entry point), package.json (dependencies).
README
• Purpose: enable users to start and extend “chains” of goodwill.
• Run instructions: server with “node index.js”; front end with Live Server.
• No external services—communication is purely between browser and the Express server.
a. Main components
• Browser / Client UI (index.html, login.html, register.html, script.js, login.js, register.js).
• API Server (Express application):
– HTTP listener (index.js)
– Routing layer (userRoutes.js)
– Controller layer (userController.js)
– Data access (reads/writes JSON in database/).
• Data store: JSON files as a lightweight database.
b. Relationships and interactions
• Browser → HTTP requests (GET/POST/PUT) → Express server routes
• Routes → Controller logic → read/write JSON files → controller returns JSON → Browser updates UI
c. Architectural patterns and design principles
• Layered MVC-style separation: routes (entry), controllers (business logic), database (persistence).
• RESTful API design for user authentication, chain creation, nomination.
• Flat-file database for simplicity—no external RDBMS.
d. Key technologies and libraries
• Node.js, Express.js for server
• Vanilla JavaScript, HTML, CSS for client
• JSON files as data store
Essential details
• Every JSON file you depend on in the database layer.
• Folder hierarchy in your sub-components (e.g., server/routes, server/controllers).