How bibashjaprel/pethub works
Project Type and Purpose
• PetHub is a full-stack pet adoption platform.
• The system allows users to browse available pets, donate pets, and make adoption requests.
• It incorporates role-based access control (admin, user, donor) and uses Cloudinary for pet image storage.
• The frontend is built in React.js (with Material UI and Tailwind CSS) while the backend uses Node.js, Express.js, and MongoDB via Mongoose.
Analyzing the File Structure
• The repository is clearly split into two main sections: “frontend” and “backend”.
• The backend contains specific folders such as “controllers”, “models”, “routes”, and “config”.
– Controllers: handle business logic for pet adoption, donations, and user-related actions.
– Models: represent the database structure (for pets, adoption, donation, and users).
– Routes: define the API endpoints.
– Configuration scripts (like cloudinary.js and dbconfig.js) manage integrations with external services.
• The frontend includes directories like “components”, “pages”, and “utils” which are used to render the UI, manage navigation (using React Router), and assist with API calls and authentication.
• There are also configuration files (e.g., tailwind.config.js) and build scripts that hint at modern frontend tooling.
Key Architectural Components
a. Frontend Component:
• Built with React.js.
• Organized into pages (Home, Login, Signup, Dashboard subpages) and reusable components (Navbar, Footer, etc.).
• Manages routing and state for user interactions.
b. Backend API:
• Constructed using Node.js and Express.js.
• Contains controllers, models, and route definitions.
• Handles user authentication (using JWT) and role-based access.
• Manages image uploads via Cloudinary (see cloudinary.js in config).
• Includes middleware for authentication and file uploads.
c. Database:
• Utilizes MongoDB with Mongoose ORM.
• Models define data structures like pets, adoption requests, donations, and users.
d. External Services & Utilities:
• Cloudinary for storing pet images.
• JWT for secure authentication.
• Environmental variables (via .env) for configuration.