How vanshwadhwa24/hourvest-1 works
Project Type and Purpose
• Hourvest is a full-stack web application: a time-bank marketplace where users trade “minits.”
• The frontend is a React SPA; the backend is a monolithic Node.js/Express API with MongoDB.
• Key flows: user authentication (Google OAuth + JWT), task proposals (create/send/accept), real-time chat per task, balance adjustments.
File Structure Analysis
• Top level: two folders frontend/ and backend/.
• Frontend: React components, CSS, a socket.js for chat.
• Backend: standard Express structure—routes/, controllers/, models/, middleware/, config/, plus Passport setup.
• Utils include token helpers and a Python script (standalone).
• No microservices—single API server handles auth, proposals, tasks, chat.
README Insights
• Tech stack calls out React, Node/Express, MongoDB/Mongoose, Passport.js for Google OAuth, JWT.
• Describes feature set: auth, proposals, task CRUD, chat, and a “time economy.”
Main Components
a. Client (Browser) – React SPA
b. API Gateway – Express server entry point (backend/server.js)
c. Auth Module
• Google OAuth (external) ↔ Passport.js
• JWT issuance & validation (authMiddleware.js)
d. Business Logic Layer
• Controllers: auth, user, task, proposal, chat
• Routes: REST endpoints (/auth, /tasks, /proposals, /chat, /users)
e. Real-Time Chat
• Socket.io (or WebSocket) server integration (frontend/src/chat/socket.js, backend chatController)
f. Data Layer
• MongoDB cluster
• Mongoose models: User, Task, Proposal, Conversation, Message
g. External Services
• Google OAuth
• MongoDB Atlas (if hosted)
h. Utility Services
• Token utilities (tokenUtils.js)
• Error handling middleware (errorHandler.js)
Relationships and Data Flow
1. User clicks “Login with Google” → Browser → Passport.js ↔ Google OAuth → JWT returned.
2. Browser stores JWT → sends “Authorization: Bearer <token>” on API calls.
3. Express middleware validates JWT → routes delegate to controllers → Mongoose performs DB queries/updates.
4. Chat: Browser connects to Socket endpoint → messages handled by chatController → persisted in MongoDB → broadcast back.
5. Proposals: Client posts proposal → API updates Proposal & Task models, adjusts user balances on acceptance.
Architectural Patterns & Design Principles
• Layered architecture: Presentation (React) → API layer (Express routes + middleware) → Service/Controller logic → Persistence (MongoDB).
• Separation of concerns:
• Auth logic isolated in middleware & controllers
• Business logic in controllers
• Data models in Mongoose schemas
• Stateless API with JWT—horizontal scaling potential.
• Real-time subsystem (WebSocket) coexisting alongside REST.