How fthabhishek-pandey/koshish-welfare works
Project Type & Purpose
• This is a full‐stack web application consisting of:
• Two React frontends:
– “Adminpannel/” for administrators, coordinators, mentors, etc.
– “koshish/” as the public site for students, guests, alumni.
• A Node.js/Express backend providing RESTful APIs.
• MongoDB for persistent data storage.
• Cloudinary (via multer) for file uploads.
• JWT and role‐based middleware for authentication & authorization.
File Structure
• Top‐level modules:
• Adminpannel/ (frontend #1)
• koshish/ (frontend #2)
• backend/ (API server & data layer)
• Each frontend follows a React + Vite layout: assets, components, context, pages, utils.
• The backend is organized in config, controllers, middleware, models, routes, repositories, server.js.
• Deployment configs: vercel.json for frontends, Render/Heroku for backend.
a. Frontends
– AdminPanel UI (Vite/React, Context API, Tailwind CSS)
– Public Koshish Site UI (Vite/React, Context API, Tailwind CSS)
b. API Layer
– Node.js + Express server
– Routes: /api/auth, /api/events, /api/announcements, /api/gallery, /api/users, etc.
c. Business Logic
– Controllers (app, cocirculer, coordinator, mentor, student domains)
– Repositories (data‐access layer)
d. Data Layer
– MongoDB cluster via Mongoose schemas
– Collections: users, events, announcements, gallery, mentors, attendance, classes, etc.
e. File Storage
– Cloudinary for images (via multer middleware)
– Fallback local uploads folder
f. Security & Middleware
– JWT authentication (verifyToken)
– Role‐based guards (checkRole: admin, coordinator, cocirculer, mentor, student)
– Error‐handler, logger
g. External Services & Deployment
– Vercel for both frontends (Adminpannel & koshish)
– Render/Heroku for backend
– MongoDB Atlas (or self-hosted)
– Cloudinary API
Relationships & Data Flows
• User (Web Browser) → Frontend (Adminpannel or koshish)
• Reads/writes UI state via React Context (AuthContext, UIContext, EventContext, etc.)
• Makes AJAX calls (Axios/fetch) to Express API at VITE_API_URL or backend URL.
• Frontend → REST API endpoints
• All calls carry JWT in Authorization header
• Role middleware gates protected routes
• Express API → Controllers → Repositories → MongoDB
• Express API → multer → Cloudinary → returns image URLs
• Backend logs actions via logger middleware → console or file
• Error flows bubble to centralized errorHandler → standardized HTTP responses
Architectural Patterns & Design Principles
• Three‐tier architecture: Presentation (React), Application (Express controllers), Data (MongoDB).
• MVC-like separation: controllers orchestrate, models define schemas, repositories handle persistence.
• Context API in React for global state (auth, UI toggles, domain data).
• RESTful APIs with clear URL structure and HTTP verbs.
• Middleware pipeline (authentication, authorization, file‐upload, error handling).
Final Checklist
• [ ] All major components represented (Frontends, API, DB, Cloudinary)
• [ ] Authentication & role middleware noted
• [ ] Deployment targets (Vercel, Render) shown as endpoints