How kian-drego/pantry_pal works
What you’re diagramming (project type + purpose)
PantryPal is a full-stack web application with:
• A static frontend (HTML pages + Tailwind + ES6 JS) served separately (opened via index.html / Live Server).
• A Node.js + Express REST API backend (Backend/server.js).
• A MongoDB database accessed through Mongoose models (Backend/models/*).
• JWT-based auth + bcrypt password hashing.
• Social/engagement capabilities: follow/unfollow, likes, saves, comments, profile updates, recipe CRUD, global feed/search, “points” gamification.
From the tree, the “real” architecture is:
Frontend (static, multi-page)
Directory: Frontend/
Pages (each implies UI modules + API calls):
• Loginpage.html
• create profile.html (profile creation/update UI)
• homepage.html (feed)
• create.html (recipe creation)
• edit-recipe.html (recipe editing)
• profilepage.html
• search.html
• leaderboard.html
• analytics.html
Also top-level index.html likely acts as an entry point / landing.
Backend (REST API)
Directory: Backend/
• server.js → Express app bootstrap, middleware, route mounting, DB connection.
• routes/auth.js → /api/auth endpoints (register/login/profile/follow logic).
• routes/recipes.js → /api/recipes endpoints (CRUD/feed/likes/saves/comments).
• models/User.js, models/Recipe.js → Mongoose schemas (core domain objects).
• .env → MONGO_URI, JWT_SECRET, PORT.
Database
• MongoDB (external service), used via Mongoose.
What the README confirms (API boundaries + responsibilities)
The README explicitly defines a RESTful split:
• /api/auth: registration, login, profile updates, follow logic
• /api/recipes: recipe creation, global feed, likes, saves, comments
*(Optional but helpful)* Token/Session boundary (JWT stored client-side)
• Browser → API: HTTPS REST (JSON)
• API → MongoDB: Mongoose queries (CRUD)
• API → Browser: JSON responses + JWT on login
• Browser → Browser storage: stores JWT (localStorage/sessionStorage/cookie—label what you actually do in code if known)
Frontend served statically (Live Server) and backend on PORT=5000.
• Express App (server.js)
• Middleware: JSON parser, CORS, auth middleware (if implemented), error handling (if implemented)
• Mount routes:
• Auth Router (routes/auth.js) at /api/auth
• Recipes Router (routes/recipes.js) at /api/recipes
• Domain Models (Mongoose)
• User Model (models/User.js)
• fields to call out conceptually: username/@handle, password hash, bio/photo, followers/following, points (if stored), saved recipes, etc.
• Recipe Model (models/Recipe.js)
• fields: creator reference, ingredients, steps, image url/data, likes, saves, comments, timestamps
• Auth Router → User Model → MongoDB
• Recipes Router → Recipe Model → MongoDB
• Recipes Router ↔ User Model (for points, saved recipes, author info, etc.)
• Auth Router ↔ Recipe Model (if profile pages pull recipe lists; only include if actually done)
Auth mechanisms:
• bcrypt used in Auth Router during registration/login (hash/compare)
• JWT issued by Auth Router, verified by middleware for protected endpoints
Follow/unfollow flow
• Browser (Profile/Search) → POST/DELETE /api/auth/follow/:userId (or similar)
• API updates User document(s): follower/following arrays + counters
• API returns updated stats (real-time updates in UI)
Recipe CRUD + gamification
• Create recipe: Browser → POST /api/recipes
• API writes Recipe + increments creator points (+10) in User
• Edit/Delete: Browser → PUT/DELETE /api/recipes/:id (protected)
• Feed: Browser → GET /api/recipes/feed (or GET /api/recipes)
Engagement: likes/saves/comments
• Like: Browser → POST /api/recipes/:id/like
• Save: Browser → POST /api/recipes/:id/save (could update User.savedRecipes and/or Recipe.saves)
• Comment: Browser → POST /api/recipes/:id/comments
Search (dual search)
• Browser → GET /api/recipes/search?q=...
• Browser → GET /api/auth/users/search?q=... (or similar)
• Global sync note: UI updates across pages/modals after mutations (this is frontend state management behavior)
• Login/JWT
• Create recipe (+10 points)
• Follow/unfollow + real-time stat refresh
These three together will be the “best and most accurate” representation of this repo’s architecture.