How pedro1guevara/mern-real-estate works
Project Type and Purpose
• This is a MERN-stack full-stack web application for real-estate listings.
• Frontend: React.js (Vite), Tailwind CSS, Redux, React Router, i18n, Firebase SDK.
• Backend: Node.js with Express.js exposing RESTful routes for users and listings.
• Database: MongoDB (via Mongoose).
• External services: Firebase (client-side SDK), Google OAuth, Mapping/geocoding APIs.
File Structure
• Top-level “api/” directory – server code:
• index.js – Express app bootstrap
• controllers/ – business logic for auth, user, listing
• routes/ – mapping of REST endpoints
• models/ – Mongoose schemas (User, Listing)
• utils/ – error handling, JWT user verification
• Top-level “client/” directory – frontend code:
• src/pages/ – route-level React pages (Home, Profile, Listings, etc.)
• src/components/ – reusable UI pieces (Header, Map, OAuth, PrivateRoute, etc.)
• src/redux/ – Redux store and user slice
• src/i18n/ – internationalization setup
• src/firebase.js – Firebase configuration for client SDK
• Configuration: package.json, Vite/Tailwind, ESLint, PostCSS.
Key README Insights
• Implements full CRUD over Listings and Users.
• Authentication flows include email/password plus Google Sign-In.
• Responsive design, pagination, search & filter, image uploads.
• Defines REST API endpoints under /api/user/* and /api/listing/*.
Main Components & Relationships
a. Frontend (Client)
• Browser running React Single-Page App.
• Redux store managing global state (user session, listings).
• Firebase SDK for optional client-side services (e.g., image storage, auth helpers).
• External Map/Geocoding API for location picker and map display.
• OAuth component → Google Identity Platform.
b. Backend (Server)
• Express.js REST API
• Controllers (auth, user, listing)
• Mongoose models → MongoDB Atlas/Instance
• Middleware (error handler, JWT verifier)
c. Database
• MongoDB (collections: users, listings)
d. External Services
• Google OAuth / Identity Platform
• (Optional) Firebase Storage or other Firebase services
• Mapping/Geocoding API
Data Flows:
[Browser]<–HTTP(S)–>[React SPA]–(dispatch)–>[Redux]
[React SPA]–HTTP(S)→[Express API]–Mongoose→[MongoDB]→results
[React SPA]–SDK calls→[Firebase Services]
[React SPA]–REST/OAuth→[Google Identity]
[React SPA]–REST→[Mapping API]
Architectural Patterns & Design Principles
• Clear separation of concerns: UI vs. API vs. data layer.
• RESTful design for server endpoints.
• MVC-style server organization (routes → controllers → models).
• Client-side state management (Redux) for predictable UI state.
• Middleware chain in Express for auth and error handling.
• Internationalization (i18n) wrapper around React.
Essential Details to Capture
• All REST endpoints under /api/user and /api/listing.
• Middlewares: verifyUser, error handler.
• i18n wrapper around root component.
• Firebase initialization used by client.
• Mapping/LocationPicker integration.