How tanmay-panday/blogs-website works
Project type and purpose
• This is a full-stack MERN (MongoDB, Express, React, Node.js) blog platform (“Blogs World”) with two user roles (Users and Admins). Users can perform CRUD on their own blogs; Admins manage all content and view analytics.
File structure
• Two top-level directories:
• frontend/ – React + Vite UI, organized into assets, components, pages, context, utils
• backend/ – Node.js + Express API, organized into config, controllers, middleware, models, routes
• Config files: package.json in each, ESLint, Tailwind, Vercel config in backend
Extract key architecture insights from the README
• Frontend communicates via Axios to REST API at /api/**
• Auth: JWT tokens, bcrypt; role-based middleware for protected routes
• File uploads: Multer → Cloudinary
• Data store: MongoDB via Mongoose
• Deployment: Vercel for both frontend and backend
Main components
a. Frontend (React App)
• UI components & pages (e.g., SignIn, BlogsPage, AdminDashboard)
• State & routing (React Router, BlogContext, ProtectedRoutes)
• REST client (Axios)
b. Backend (Express Server)
• Entry point (server.js)
• Routes layer (userRoutes, blogRoutes)
• Controllers (userController, blogController)
• Middleware (authUser, authAdmin, multer)
• Config (MongoDB connector, Cloudinary connector)
c. Database
• MongoDB (User and BlogPost collections via Mongoose ODM)
d. External service
• Cloudinary for image hosting
e. Deployment & environment
• Vercel (CI/CD)
• .env for secrets (JWT_SECRET, MONGODB_URI, Cloudinary creds)
Relationships and data flows
1. Browser → React App
2. React App sends HTTP requests (GET/POST/DELETE) to Express API
3. Express middleware verifies JWT, handles file uploads, passes to controllers
4. Controllers execute business logic, call Mongoose models
5. Models interact with MongoDB
6. File uploads: Multer → Cloudinary API → store image URL in MongoDB
7. API responses back to React UI
8. Role-based routes: ProtectedRoutes wrapper on the frontend; authUser/authAdmin on backend
Architectural patterns & principles
• MVC-like layering in the backend (Routes → Controllers → Models)
• Single-Page App on the frontend, with Context API for global state
• Separation of concerns: UI vs. API vs. data vs. external services
• Stateless API with JWT for authentication
• Service isolation: Cloudinary as dedicated file storage service