How krishnaacharyaa/wanderlust works
Project type and purpose
• Wanderlust is a full‑stack travel‑blog application built on the MERN stack (MongoDB, Express.js, React, Node.js) with TypeScript. Its goal is to let users browse and create travel posts, manage user authentication, and explore posts by category.
File structure
• Top‑level directories:
• backend/ – an Express‑based REST API in TypeScript
• frontend/ – a Vite‑powered React SPA in TypeScript
• Patterns and layers in backend:
• config/ – DB and Passport configuration
• models/ – Mongoose schemas (user, post)
• controllers/ – business logic for auth, posts, user
• services/ – auxiliary services (Redis cache)
• routes/ – API endpoints grouped by feature
• middlewares/ – authentication, error handling, validation
• utils/ – error/response wrappers, async handlers, constants
• Frontend structure follows component‑driven design:
• src/components/ – reusable UI pieces (cards, skeletons, modal, theme toggle)
• src/pages/ – route‑level page components (home, details, signin, signup, admin)
• src/hooks & src/helpers – custom hooks and Axios instance
• src/utils – UI‑related utilities (slug, theme)
• Deployment/config: Vercel configuration at both root and each package; GitHub Actions workflows for CI.
Key insights from the README
• Describes the MERN stack, learning focus, React mastery, key features (featured posts, topic categories).
Main components and interactions
a. Components
1. Client (React SPA)
2. API Server (Express/Node)
3. Database (MongoDB)
4. Cache (Redis)
5. External auth library (Passport.js with JWT/cookie)
6. Static asset store (if any) / Vercel hosting
7. Third‑party services (e.g., email provider, analytics) – optional
b. Relationships & data flow
• Client sends HTTPS requests (via Axios) to the API Server endpoints.
• API Server applies middleware (auth, validation), invokes controllers.
• Controllers query MongoDB directly or via a Redis cache layer for “posts” data (cache‑aside pattern).
• Passport middleware handles session or JWT validation on protected routes.
• API Server returns JSON responses to Client; client updates UI state.
• Frontend uses React Router for navigation, custom hooks for auth state, and theme utilities.
c. Architectural patterns & principles
• MVC‑inspired layering in the backend (models/controllers/services/routes).
• Cache‑aside strategy: services/cache‑posts.ts checks Redis before hitting the DB.
• Separation of concerns: UI components vs. page containers vs. API utilities.
• Env‑based configurations (.env.sample, tsconfig variants).
d. Technologies & frameworks
• Frontend: React, Vite, TypeScript, Tailwind CSS, Jest + React Testing Library
• Backend: Node.js, Express, TypeScript, Mongoose, Redis, Passport, Jest + supertest