A modern, location-based blood donation platform built with Next.js that connects blood donors with recipients in real-time. The app helps save lives by making it easy to find nearby donors during emergencies.
- Features
- Tech Stack
- Getting Started
- Environment Variables
- Database Schema
- Project Structure
- API Routes
- Deployment
- π Authentication - Secure user authentication with Clerk
- π€ Profile Management - Multi-step profile completion with medical information
- πΊοΈ Location-Based Matching - Find donors/recipients using interactive maps (Leaflet)
- π Emergency Requests - Create and respond to urgent blood donation requests
- π Dashboard - Comprehensive dashboard for donors and recipients
- π Real-time Updates - Track donation requests and responses
- π Dark Mode - Full dark mode support with next-themes
- π± Responsive Design - Mobile-first, fully responsive UI
- Donors - Register availability, respond to requests, track donation history
- Recipients - Create blood requests, view nearby donors, manage responses
- Admin - Manage users and requests (role-based access)
- Blood group compatibility matching
- Distance-based donor search
- Urgency levels (Critical, High, Medium, Low)
- Donation history tracking
- Response management system
- Profile completion wizard
- Framework: Next.js 16 (App Router)
- Language: TypeScript
- Styling: Tailwind CSS 4
- UI Components: Radix UI, shadcn/ui
- Animations: Framer Motion
- Maps: Leaflet, React Leaflet
- Icons: Lucide React
- Forms: React Hook Form + Zod validation
- State Management: Zustand
- Database: PostgreSQL (Prisma ORM)
- Authentication: Clerk
- Email: Nodemailer, Resend
- API: Next.js API Routes
- Linting: ESLint
- Type Checking: TypeScript
- Package Manager: npm
- Node.js 18+ installed
- PostgreSQL database
- Clerk account for authentication
- Clone the repository
git clone <repository-url>
cd blood-donation-app- Install dependencies
npm install-
Set up environment variables Create a
.envfile in the root directory (see Environment Variables) -
Set up the database
npx prisma generate
npx prisma db push- Run the development server
npm run dev- Open your browser Navigate to http://localhost:3000
npm run dev- Start development servernpm run build- Build for productionnpm start- Start production servernpm run lint- Run ESLintnpx prisma studio- Open Prisma Studio (database GUI)npx prisma generate- Generate Prisma Clientnpx prisma db push- Push schema changes to database
Create a .env file with the following variables:
# Database
DATABASE_URL="postgresql://user:password@host:port/database"
DIRECT_URL="postgresql://user:password@host:port/database"
# Clerk Authentication
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_...
CLERK_SECRET_KEY=sk_test_...
NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in
NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up
# Email (Optional)
RESEND_API_KEY=re_...
EMAIL_FROM=noreply@yourdomain.com
# App URL
NEXT_PUBLIC_APP_URL=http://localhost:3000The app uses Prisma with PostgreSQL. Key models include:
- User information (name, email, phone, blood group, age, gender)
- Location data (latitude, longitude, state, city)
- Donor availability status
- Last donation date
- Blood donation requests
- Patient information and location
- Urgency level (Critical, High, Medium, Low)
- Units needed
- Status (Active, Fulfilled, Cancelled)
- Donation history
- Linked to donor and request
- Date and units donated
- Donor responses to requests
- Status (Pending, Accepted, Declined)
- Optional message
See prisma/schema.prisma for complete schema details.
See project_struct.md for detailed project structure.
POST /api/profile- Create/update user profile
GET /api/requests- Get all blood requestsPOST /api/requests- Create new blood request
GET /api/donors- Get available donors (with location filtering)
GET /api/donations- Get donation historyPOST /api/donations- Record new donation
GET /api/responses- Get responses to requestsPOST /api/responses- Respond to a blood request
- Push your code to GitHub
- Import project in Vercel
- Configure environment variables
- Deploy
Use a PostgreSQL hosting service:
- Neon (Recommended)
- Supabase
- Railway
- PlanetScale
- Run database migrations:
npx prisma db push-
Verify Clerk webhooks are configured
-
Test the application thoroughly
This project is private and proprietary.
Built with β€οΈ using Next.js, Prisma, and Clerk