How bhargav007dobhal/post-flow-blog-website-updated- works
Project type and purpose
• This is a full-stack blog platform (“Post Flow Blog Website”) with a React front end, a Node.js/Express back end, MySQL for persistent storage, and local file uploads for images.
• Key features: user authentication (JWT), post creation/editing/deletion with image uploads, comments, upvotes, leaderboard, and user profiles.
File structure
• Top level: two main folders, backend/ and frontend/, plus documentation and reports in the root.
• backend/
• controllers – request handlers (auth, posts, users, features, metrics)
• middleware – JWT auth, rate limiting, security, caching, performance checks
• models – database connection (db.js, connection pool)
• routes – REST endpoints (/api/auth, /api/posts, /api/users, etc.)
• Uploads – local file storage for post images
• server.js & runMigration.js – main entry point and schema setup scripts
• frontend/
• src/components – reusable UI components (Navbar, UpvoteButton, BookmarkButton)
• src/pages – route-level views (Home, CreatePost, Login, Register, Profile, Leaderboard, PostDetail)
• src/context/AuthContext – global auth state with React Context & JWT management
• src/services/api.js – Axios instance pointing at the Express API
• Tailwind CSS for styling
• Configuration: .env files, package.json, PostCSS/tailwind config files.
Architectural patterns and design principles
• Layered MVC style in the backend: Routes → Controllers → Models → Database
• Middleware pipeline for cross-cutting concerns (auth, rate limiting, security)
• Component-based UI in the frontend with Context for global state
• RESTful API between front end and back end
• Local file storage (Uploads folder) for images, managed via middleware
Main components and their interactions
a. Client (Browser / React SPA)
• Hosted by npm start on port 3000
• Renders UI, holds auth state, dispatches HTTP calls via api.js
b. API Server (Express)
• Listens on port 5001
• Exposes /api/* endpoints for auth, posts, comments, likes, users, metrics
• Middlewares: JWT verification, rate limiter, security headers, input validation
c. Database (MySQL)
• Tables: users, posts, comments, likes
• Accessed via models/db.js using a connection pool
d. File Storage
• Local folder backend/Uploads/ for storing uploaded images
• served as static resources via Express
e. External Dependencies
• JWT library for token generation/validation
• Axios for HTTP in the front end
• Tailwind CSS for styling
Interaction flow example:
1. User logs in/registers → React calls /api/auth → server controller issues JWT → client stores it in Context
2. User creates a post with image → React form uses Axios multipart POST to /api/posts → Express uses security and file-upload middleware → controller saves metadata in MySQL and file on disk → response includes new post data
3. User upvotes a post → React sends POST to /api/posts/:id/upvote → server middleware checks JWT and rate limit → controller writes to likes table → client refreshes post/leaderboard