How khotkeys/chi-food works
Project type and purpose
• This is a static, single‐page frontend application (“Chi-Food Frontend”) delivered as plain HTML/CSS/JS.
File structure
• Top level:
• README.md – project description and setup instructions.
• index.html – entry point.
• images/ – static image assets.
• src/app.js – all front-end logic (map, filters, modals, form).
• src/index.css – styling (responsive layout, animations).
• No build tool: everything is served statically and dependencies are pulled via CDN.
Key external dependencies (from README)
• Leaflet.js + OpenStreetMap (map tiles & geodata)
• Google Fonts (Montserrat)
Main components
a. Static Hosting Layer
– index.html, src/app.js, src/index.css, images/*. Served from a web server or CDN (e.g., Netlify, S3).
b. Frontend UI Components (in app.js + index.css)
– Map Module: Leaflet initialization + OSM tile requests
– Pantry Listing Module: data rendering, filter panel (dietary/cultural/health)
– Donation Scheduling Module: form with date/time pickers
– User Profile Modal: dietary restrictions form + store/retrieve user prefs (localStorage or API)
c. External Services
– CDN Hosts: Leaflet CSS/JS, Flaticon assets, Google Fonts
– OpenStreetMap Tile Server: map tile requests
– (Optional) Backend API Endpoints:
• GET /pantries – pantry geo-data & metadata
• POST /donations – scheduling submissions
• GET/PUT /user-profile – load/save dietary prefs
d. Browser Environment
– JavaScript runtime executes app.js, manipulates DOM, handles user events, issues HTTP requests
Relationships & data flows
• User loads index.html from Static Hosting → Browser loads CSS & JS from Hosting and CDNs
• app.js initializes Leaflet → Browser issues tile/map data requests to OSM
• app.js fetches pantry data from Backend API → Renders markers & listings
• User applies filter → JS applies client-side filtering or refetch with query params
• User opens “Donate” or “Profile” modal → JS posts form data to Backend API
• Backend API responds → JS updates UI with confirmation or refreshed data
Architectural patterns & design principles
• Separation of concerns:
• Static assets (HTML/CSS/JS) separate from dynamic data (API).
• Modules in app.js: map, listings, forms are loosely coupled.
• Client-centric rendering: all UI logic lives in the browser.
• CDN offloading: reduces hosting load, speeds up asset delivery.
• Progressive enhancement: works with JS enabled; no build step simplifies deployment.
• (Optional) Note: “No build step – all deps via CDN” call-out