How sathwikreddy15/nextpad works
Project type and purpose
• This is a full-stack web application (“Nextpad”) allowing writers to create, edit, soft-delete, and share literary works and allowing users to comment.
• Technology stack: React (Vite) frontend, Node.js/Express backend, MongoDB database, JWT-based auth, deployed on Vercel.
Main components
a. Frontend (React + Vite)
• Main.jsx / App.jsx
• Components folder: Landing, Home, Article, NewArticle, ModifyArticle, UserProfile, Login, Register, Navbar, Footer
• Context API providers: urlContext, userContext, myContext
• HTTP client: axiosWithToken
b. Backend (Node.js + Express)
• index.js (Express app entry point)
• APIs folder: user-api.js (CRUD for users/articles), verifyToken.js (JWT middleware), Util.js (utility functions)
c. Database
• MongoDB (hosted via MONGODB_URI from .env)
d. Deployment / External Services
• Vercel for hosting frontend and backend
• MongoDB Atlas (or equivalent)
• JWT issuer/validator
Relationships & interactions
• The user’s browser loads the React SPA from Vercel.
• React Context provides base API URL and user state.
• User actions (login, fetch articles, post comment) trigger axiosWithToken calls to the Express API.
• Express routes in index.js forward requests to specific API controllers in the APIs folder.
• verifyToken middleware protects private endpoints by validating the JWT from request headers.
• Controllers perform business logic and read/write data in MongoDB.
• Responses flow back through Express to the React client, which updates UI state via Context.
Architectural patterns & design principles
• Frontend: Component-based architecture with Context API for global state management.
• Backend: Modular route handlers (APIs folder) with middleware (verifyToken), following an MVC-like separation (controllers/utilities).
• Stateless, RESTful API design; JWT for authentication.
• Soft deletes on articles implemented via a “deleted” flag in the database (business logic in Util.js).