A full-stack web application that connects donors and buyers in a simple, intuitive marketplace. Share and discover donations or sell items seamlessly.
- Features
- Tech Stack
- Project Structure
- Prerequisites
- Installation
- Configuration
- Running the Application
- API Endpoints
- Database Models
- Contributing
- License
-
User Management
- User registration and authentication (JWT-based)
- Role-based access control (User, Admin)
- Profile management
- Email verification and password reset
-
Donation System
- Create, view, and manage donations
- Multiple donation types: blood, cash, books, food, knowledge, items
- Track donation history and status
- Real-time donation notifications
-
Marketplace
- Browse and search items
- List items for sale
- Item categorization
- Seller ratings and reviews
- Image uploads (Cloudinary integration)
-
Transactions
- Process donations and purchases
- Transaction history tracking
- Payment status management
- Receipt generation
-
Admin Dashboard
- User management
- Donation and transaction monitoring
- System statistics and analytics
- Content moderation
-
Security & Reliability
- Helmet for HTTP headers security
- Rate limiting to prevent abuse
- CORS protection
- Input validation and sanitization
- Password hashing with bcrypt
- JavaScript (~97%) - Primary language for both backend and frontend
- CSS (~2%) - Styling (global.css, component styles)
- HTML (~1%) - React templates and static assets
- JSON - Configuration and package management
- PowerShell - Database seeding and utility scripts
- Runtime: Node.js
- Framework: Express.js
- Database: MongoDB (Mongoose ODM)
- Authentication: JWT (JSON Web Tokens)
- File Upload: Multer + Cloudinary
- Email: Nodemailer
- Validation: express-validator
- Security: Helmet, bcryptjs, express-rate-limit
- Framework: React 18
- Routing: React Router
- State Management: Context API
- HTTP Client: Axios
- Styling: CSS (Global + Component-level)
- UI Components: Custom React components
- Development: Nodemon (auto-reload)
- Database: MongoDB Atlas / Local MongoDB
- Storage: Cloudinary CDN
- Email Service: Gmail/SMTP compatible
- Package Manager: npm / yarn
donatehub/
├── donatehub-backend/ # Node.js + Express API
│ ├── src/
│ │ ├── index.js # Server entry point
│ │ ├── config/
│ │ │ └── database.js # MongoDB connection
│ │ ├── controllers/ # Business logic handlers
│ │ ├── models/ # Mongoose schemas
│ │ ├── routes/ # API endpoints
│ │ ├── middleware/ # Auth, validation middleware
│ │ ├── utils/ # Helper functions (email, tokens, uploads)
│ │ ├── scripts/ # Database seeding
│ │ └── uploads/ # Local file storage
│ ├── .env # Environment variables
│ └── package.json
│
├── donatehub-frontend/ # React application
│ ├── src/
│ │ ├── index.js # React entry point
│ │ ├── App.js # Root component
│ │ ├── components/ # Reusable UI components
│ │ ├── pages/ # Page components
│ │ ├── services/ # API calls
│ │ ├── context/ # Context providers (Auth, Theme)
│ │ ├── styles/ # Global stylesheets
│ │ └── utils/ # Validation, helpers
│ ├── public/ # Static assets
│ └── package.json
│
└── README.md # This file
Before you begin, ensure you have the following installed:
- Node.js (v16 or higher)
- npm (v7 or higher) or yarn
- MongoDB (v5+) - Local or Atlas account
- Git
git clone https://github.com/yourusername/donatehub.git
cd donatehubcd donatehub-backend
npm installcd ../donatehub-frontend
npm installCreate a .env file in donatehub-backend/:
# Server
PORT=5000
NODE_ENV=development
# Database
MONGODB_URI=mongodb://localhost:27017/donatehub
# OR for MongoDB Atlas:
# MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/donatehub
# JWT
JWT_SECRET=your_jwt_secret_key_here
JWT_REFRESH_SECRET=your_refresh_secret_key_here
JWT_EXPIRY=1h
JWT_REFRESH_EXPIRY=7d
# Cloudinary (for image uploads)
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret
# Email (Nodemailer)
EMAIL_USER=your_email@gmail.com
EMAIL_PASSWORD=your_app_password
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
# Frontend URL (CORS)
FRONTEND_URL=http://localhost:3000
# Admin Email
ADMIN_EMAIL=admin@donatehub.comCreate a .env file in donatehub-frontend/:
REACT_APP_API_URL=http://localhost:5000/api
REACT_APP_API_TIMEOUT=10000Seed the database with sample data:
cd donatehub-backend
npm run seedTerminal 1 - Backend:
cd donatehub-backend
npm run devBackend runs at http://localhost:5000
Terminal 2 - Frontend:
cd donatehub-frontend
npm startFrontend runs at http://localhost:3000
Backend:
cd donatehub-backend
npm startFrontend:
cd donatehub-frontend
npm run build
# Serve the build folder using a static server
npx serve -s build| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/register |
Register new user |
| POST | /api/auth/login |
Login user |
| POST | /api/auth/logout |
Logout user |
| POST | /api/auth/refresh-token |
Refresh JWT token |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/users/profile |
Get user profile |
| PUT | /api/users/profile |
Update profile |
| GET | /api/users/:id |
Get user by ID |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/donations |
Get all donations |
| POST | /api/donations |
Create donation |
| GET | /api/donations/:id |
Get donation details |
| PUT | /api/donations/:id |
Update donation |
| DELETE | /api/donations/:id |
Delete donation |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/items |
Get all items |
| POST | /api/items |
List new item |
| GET | /api/items/:id |
Get item details |
| PUT | /api/items/:id |
Update item |
| DELETE | /api/items/:id |
Delete item |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/transactions |
Get user transactions |
| POST | /api/transactions |
Create transaction |
| GET | /api/transactions/:id |
Get transaction details |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/admin/dashboard |
Admin dashboard stats |
| GET | /api/admin/users |
List all users |
| DELETE | /api/admin/users/:id |
Remove user |
{
firstName, lastName, email, password, phone,
avatar, bio, address, role, verified, createdAt
}{
title, description, type, category, donor,
quantity, status, image, createdAt
}{
title, description, category, seller, price,
image, available, createdAt
}{
buyer, seller, item, amount, status, date, receipt
}- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For questions or issues, please:
- Open an issue on GitHub
- Contact: support@donatehub.com
- Check existing documentation
Happy Contributing! 🎉
Built with ❤️ for the community.