A community-powered, multi-tenant blood donation platform connecting blood donors with patients in rural areas of Bangladesh. Built with modern web technologies and designed for organizations to manage their own blood bank networks.
/savar-blood-bank, /uttara-donors)/admin| Category | Technology |
|---|---|
| Framework | Next.js 16 (App Router with Turbopack) |
| Language | TypeScript 5.x |
| Database | MongoDB with Mongoose 9 |
| Authentication | NextAuth.js 4.x |
| Styling | Tailwind CSS 4.x |
| Forms | React Hook Form + Zod Validation |
| Notifications | Sonner (Toast notifications) |
| Icons | Lucide React |
| PWA | @ducanh2912/next-pwa |
bloodbank/
βββ app/
β βββ (auth)/ # Auth route group (empty, uses /login)
β βββ (dashboard)/ # Dashboard route group (empty, uses org-scoped)
β βββ [orgSlug]/ # Organization-scoped pages
β β βββ layout.tsx # Org layout with Navbar & Footer
β β βββ page.tsx # Org landing page
β β βββ dashboard/ # Admin dashboard
β β β βββ page.tsx # Dashboard overview
β β β βββ donors/page.tsx # Donor management
β β β βββ requests/page.tsx # Request management
β β βββ donors/page.tsx # Public donor discovery
β β βββ register/page.tsx # Donor registration
β β βββ requests/ # Blood requests
β β βββ page.tsx # Requests listing
β β βββ new/page.tsx # New request form
β βββ api/ # API routes
β β βββ auth/[...nextauth]/ # NextAuth.js handler
β β βββ donors/ # Donor APIs
β β β βββ route.ts # GET: List donors
β β β βββ register/route.ts # POST: Register donor
β β β βββ verify/route.ts # POST: Verify donor
β β βββ requests/ # Request APIs
β β β βββ route.ts # GET: List requests
β β β βββ new/route.ts # POST: Create request
β β β βββ status/route.ts # POST: Update status
β β βββ org/stats/route.ts # GET: Organization stats
β βββ login/page.tsx # Global login page
β βββ page.tsx # Main landing page
β βββ layout.tsx # Root layout
β βββ globals.css # Global styles
βββ components/
β βββ AuthProvider.tsx # NextAuth session provider
β βββ Navbar.tsx # Organization-aware navbar
β βββ Footer.tsx # Organization-aware footer
β βββ ui/ # Reusable UI components
β βββ button.tsx
β βββ card.tsx
β βββ input.tsx
βββ lib/
β βββ authOptions.ts # NextAuth configuration
β βββ orgUtils.ts # Organization utilities
β βββ context/
β β βββ OrganizationContext.tsx # Organization React context
β βββ db/
β β βββ mongodb.ts # MongoDB connection
β βββ models/
β βββ User.ts # User & DonorProfile models
β βββ BloodRequest.ts # Blood request model
β βββ Organization.ts # Organization model
βββ scripts/
β βββ seed.ts # Database seeder
βββ public/ # Static assets
{
name: string; // Required
phone: string; // Required, unique identifier
email?: string; // Optional
password?: string; // Optional (for demo, uses simple bypass)
role: UserRole; // donor | patient | volunteer | admin | super_admin
organization?: ObjectId;
image?: string;
createdAt: Date;
updatedAt: Date;
}
{
user: ObjectId; // Reference to User
organization: ObjectId; // Reference to Organization
bloodGroup: string; // A+, A-, B+, B-, O+, O-, AB+, AB-
district: string;
upazila: string;
village?: string;
lastDonationDate?: Date;
isAvailable: boolean; // Default: true
isVerified: boolean; // Default: false (requires admin verification)
}
{
patientName: string;
bloodGroup: string;
location: string;
district: string;
upazila: string;
urgency: UrgencyLevel; // normal | urgent | emergency
requiredDate: Date;
contactNumber: string;
additionalNotes?: string;
status: RequestStatus; // pending | fulfilled | canceled
requester: ObjectId; // Reference to User
organization: ObjectId; // Reference to Organization
createdAt: Date;
updatedAt: Date;
}
{
name: string;
slug: string; // Unique, lowercase URL slug
logo?: string;
primaryColor?: string; // Default: #D32F2F (red)
contactEmail?: string;
contactPhone?: string;
address?: string;
isActive: boolean; // Default: true
createdAt: Date;
updatedAt: Date;
}
| Method | Endpoint | Description |
|βββ|βββ-|ββββ-|
| GET | /api/donors?orgSlug=X&bloodGroup=Y&district=Z&upazila=W | List donors with optional filters |
| POST | /api/donors/register | Register a new donor |
| POST | /api/donors/verify | Verify/unverify a donor (admin) |
| Method | Endpoint | Description |
|βββ|βββ-|ββββ-|
| GET | /api/requests?orgSlug=X&urgency=Y&status=Z | List requests with optional filters |
| POST | /api/requests/new | Create a new blood request |
| POST | /api/requests/status | Update request status |
| Method | Endpoint | Description |
|βββ|βββ-|ββββ-|
| GET | /api/org/stats?orgSlug=X | Get organization statistics |
| Method | Endpoint | Description |
|βββ|βββ-|ββββ-|
| GET | /api/admin/organizations | List all organizations |
| POST | /api/admin/organizations | Create new organization |
| GET | /api/admin/organizations/[id] | Get organization by ID with stats |
| PUT | /api/admin/organizations/[id] | Update organization |
| DELETE | /api/admin/organizations/[id] | Delete organization |
| GET | /api/admin/stats | Get platform-wide statistics |
| Method | Endpoint | Description |
|βββ|βββ-|ββββ-|
| POST | /api/auth/[...nextauth] | NextAuth.js authentication handler |
git clone https://github.com/3s-Soft/bloodbank.git
cd bloodbank
npm install
Create a .env.local file in the root directory:
# MongoDB Connection
MONGODB_URI=mongodb://localhost:27017/bloodbank
# NextAuth Configuration
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your-secret-key-here-generate-with-openssl
Run the seed script to create test organizations and users:
npx tsx scripts/seed.ts
npm run dev
Open http://localhost:3000 to view the application.
| Field | Value |
|ββ-|ββ-|
| Phone | 01700000000 |
| Password | demo123 |
| Organization | URL Slug | Primary Color |
|---|---|---|
| Savar Blood Bank | savar-blood-bank |
Red (#D32F2F) |
| Uttara Donors | uttara-donors |
Blue (#1976D2) |
| Mirpur Life Savers | mirpur-life-savers |
Green (#388E3C) |
| Command | Description |
|---|---|
npm run dev |
Start development server with Turbopack |
npm run build |
Build production bundle |
npm run start |
Start production server |
npm run lint |
Run ESLint |
npx tsx scripts/seed.ts |
Seed database with test data |
Contributions are welcome! Please read our Contributing Guide and Code of Conduct before submitting a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.
For security vulnerabilities, please refer to our Security Policy.