How mugilan-codes/dev-book works
Project type and purpose
• This is a full-stack MERN (MongoDB, Express, React, Node) web application called “DevBook.”
• Purpose: a developer social network where users can register/login, create profiles (with education, experience, GitHub integration), make posts, comment, and view other profiles.
File structure
Top-level:
• client/ – React single-page app (SPA) with Redux for state management
• server.js, config/, models/, routes/, middleware/ – Node/Express REST API
• _resources/ – legacy/static HTML/CSS theme (optional)
• package.json, package-lock.json – root dependencies
Inside client/:
• public/ – static HTML shell (index.html, manifest.json)
• src/ – React code
– actions/, reducers/, store.js – Redux
– components/ – UI broken down by feature (auth, dashboard, posts, profiles, layout)
– utils/api.js – HTTP client wrapper
– utils/setAuthToken.js – attach JWT to requests
– App.js, index.js – entry points
Inside server:
• config/db.js – MongoDB connection
• middleware/auth.js – JWT verification
• models/ – Mongoose schemas (User, Profile, Post)
• routes/api/ – Express routers (auth, users, profile, posts)
Extract insights from the README
• Tech stack: MongoDB, ExpressJS, ReactJS, NodeJS
• Planned features (GitHub repos integration, logging)
Components
a. Frontend (React SPA)
– Redux store
– UI components grouped by feature (Auth, Dashboard, Profile, Posts)
– HTTP Client (utils/api.js)
b. Backend (Node/Express API)
– API Gateway (server.js → routes)
– Controllers (inside routes handlers)
– Authentication middleware (JWT in auth.js)
– Business logic interacting with Mongoose models
c. Database
– MongoDB cluster or instance
– Collections: users, profiles, posts
d. External Services
– GitHub REST API calls (ProfileGithub component → fetch repos)
– (Optional) any logging/analytics service
e. Static assets
– client/public
– _resources/html_css_theme (if used in fallback or theming)
Relationships and interactions
1. User interacts with React UI
2. React dispatches Redux actions → utils/api.js makes HTTP requests
3. Express routes receive requests → auth middleware validates JWT
4. Route handlers call Mongoose models → read/write MongoDB
5. Response flows back to React → Redux updates store → UI re-renders
6. ProfileGithub component triggers external GitHub API calls (server-side or client-side)
7. Errors pass through alert handling (Redux alerts)
Architectural patterns & design principles
• Layered architecture: UI → application (Redux) → API (Express) → persistence (MongoDB)
• MVC-style on the server: Routes = controllers, Models = Mongoose schemas
• Flux pattern on the client: Redux actions, reducers, store
• JWT-based stateless authentication
• Separation of concerns: components by feature, utils for shared logic