How jamil-rahman/capstone-fs works
Project Type and Purpose
• When-in-Roam is a full-stack roommate-finding web application.
• Frontend built with React (Vite) for SPA user interface and Firebase Authentication.
• Backend built with Node.js/Express exposing RESTful APIs, persisting data in MongoDB.
• Integrates with SendGrid for email, OpenAI for AI-driven city insights.
File Structure
• Top-level folders:
• backend/ – server code (app.js, config/, controllers/, models/, routes/, middleware/)
• frontend/ – client code (src/, public/, config and env files, Vite config)
• backend follows MVC:
• models/ define Mongoose schemas (User, Post, Trivia)
• controllers/ handle business logic (user, post, trivia, insights, email, dev)
• routes/ map HTTP endpoints to controllers
• middleware/ enforces auth (JWT/Firebase token validation)
• frontend is component-based:
• pages/ define route views (Home, Login, SignUp, Profile, Insights, PostManagement)
• components/ handle UI pieces (Navbar, Banner, Post cards, Modals, ProtectedRoute)
• services/ wrap axios calls to backend APIs
• context/AuthContext.jsx manages user session via Firebase SDK
• utils/ contain shared helpers (axios config, time formatting, auth utilities)
• Config files: .env for secrets, Procfile for Heroku, package.json for scripts.
Extract Architecture Insights from README
• User flow: signup/login via Firebase, create posts, browse posts, request AI insights, send emails.
• API calls: frontend → backend (Node/Express REST endpoints) → MongoDB; backend → SendGrid and OpenAI external APIs.
• All routes protected by authentication middleware.
a. Main Components
1. Frontend Client (React/Vite SPA)
2. Authentication Service (Firebase Auth)
3. API Layer (Express Server)
4. Data Store (MongoDB Atlas)
5. Email Service (SendGrid)
6. AI Service (OpenAI GPT-4)
7. Hosting/Deployment (Heroku or similar)
b. Relationships & Data Flows
• User interacts with React UI → invokes AuthContext for Firebase login.
• Upon login, React obtains Firebase JWT → attaches to axios requests.
• React services call Express endpoints (User, Post, Trivia, Insights, Email).
• Express middleware validates JWT (auth.js/auth-prod.js) → controllers execute.
• Controllers read/write via Mongoose to MongoDB.
• For email, controller calls SendGrid API.
• For city insights, controller calls OpenAI API.
• Responses flow back through Express → React → rendered UI.
c. Architectural Patterns
• MVC pattern on backend (Models, Controllers, Routes).
• Component-based architecture on frontend (presentational vs. container components).
• Service layer pattern for external API integration (sendgrid, openai).
• Context API for global state/auth.
d. Key Technologies & Frameworks
• React, Vite, Bootstrap, Firebase Auth, Axios (client)
• Node.js, Express, Mongoose, MongoDB (server)
• SendGrid SDK, OpenAI SDK (external integrations)
• Heroku (deployment), .env for configuration