This application is a platform for donating blood and finding donors.
Current version: 0.8.0 (beta)
npm i drizzle-orm @neondatabase/serverless dotenv
npm i -D drizzle-kit tsxDATABASE_URL=postgresql://postgres:password@localhost:5432/postgresCreate the database file under db/db.ts
Create the drizzle.config.ts file under the root directory
then run to generate the schema of authentication
npx @better-auth/cli generatePush schema to the database
npx drizzle-kit pushnpm install husky
npx husky initEdit the .husky/pre-commit file to run the build command
Add the following to the .husky/pre-commit file
npm run buildAdd the following to the .gitignore file
.husky/_- Email & Password Authentication - Secure sign-up and sign-in
- Email Verification - Required email verification for new accounts
- Social Login Providers - Google and GitHub OAuth integration
- Profile Management - Upload profile images and manage user information
- Session Management - Secure session handling with automatic redirects
- Protected Routes - Dashboard access requires authentication
- Modern Design - Built with shadcn/ui components and Tailwind CSS
- Responsive Layout - Mobile-first design that works on all devices
- Dark Mode Support - Automatic theme switching
- Loading States - Smooth loading indicators and error handling
- Toast Notifications - User-friendly feedback with Sonner
- Email & Password Authentication - Secure sign-up and sign-in
- Email Verification - Required email verification for new accounts
- Social Login Providers - Google and GitHub OAuth integration
- Profile Management - Upload profile images and manage user information
- Session Management - Secure session handling with automatic redirects
- Protected Routes - Dashboard access requires authentication
- Password Reset - Forgot password functionality
- Account Lockout - Security after multiple failed attempts
- Modern Design - Built with shadcn/ui components and Tailwind CSS
- Responsive Layout - Mobile-first design that works on all devices
- Loading States - Smooth loading indicators and error handling
- Toast Notifications - User-friendly feedback with Sonner
- Dark Mode Support - Automatic theme switching
- Accessibility Features - Screen reader support and keyboard navigation
- Internationalization (i18n) - Multi-language support
- PWA Support - Progressive Web App capabilities
- Database Integration - Drizzle ORM with PostgreSQL
- Form Validation - Zod schema validation
- Form Handling - React Hook Form integration
- Real-time Notifications - WebSocket or Server-Sent Events
- API Rate Limiting - Protect against abuse
- Caching Strategy - Redis or in-memory caching
- Search Functionality - Advanced search and filtering
- Next.js 15 - Latest React framework with App Router
- TypeScript - Full type safety throughout the application
- ESLint - Code linting and formatting
- Performance Monitoring - Analytics and error tracking
- SEO Optimization - Meta tags and structured data
- CDN Integration - Global content delivery
- Database Optimization - Query optimization and indexing
- Automated Testing - Unit, integration, and E2E tests
The authentication is configured in lib/auth.ts:
export const auth = betterAuth({
emailAndPassword: {
enabled: true
},
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID!,
clientSecret: process.env.GOOGLE_CLIENT_SECRET!
},
github: {
clientId: process.env.GITHUB_CLIENT_ID!,
clientSecret: process.env.GITHUB_CLIENT_SECRET!
}
},
plugins: [nextCookies()],
});- Go to Google Cloud Console
- Create a new project or select existing one
- Enable Google+ API
- Create OAuth 2.0 credentials
- Add
http://localhost:3000/api/auth/callback/googleto authorized redirect URIs
- Go to GitHub Settings > Developer settings > OAuth Apps
- Create a new OAuth App
- Set Authorization callback URL to
http://localhost:3000/api/auth/callback/github
This project includes comprehensive testing infrastructure with unit, integration, and end-to-end tests.
- Vitest - Fast unit and integration testing
- React Testing Library - Component testing utilities
- Playwright - End-to-end testing for critical user flows
- MSW (Mock Service Worker) - API mocking for integration tests
# Run all unit and integration tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with UI dashboard
npm run test:ui
# Generate coverage report
npm run test:coverage
# Run end-to-end tests
npm run test:e2e
# Run E2E tests with UI
npm run test:e2e:uiβββ actions/__tests__/ # Server action unit tests
βββ components/ # Component tests (co-located)
β βββ navigation.test.tsx
β βββ theme-toggle.test.tsx
βββ lib/__tests__/ # Utility function tests
βββ app/[locale]/signin/ # Page component tests
β βββ sign-in-form.test.tsx
βββ tests/ # Test utilities and setup
β βββ setup.ts # Global test setup
β βββ utils.tsx # Custom render functions
β βββ factories/ # Test data factories
β βββ mocks/ # Mock implementations
β βββ integration/ # Integration tests
βββ e2e/ # End-to-end tests
β βββ auth.spec.ts
β βββ search.spec.ts
β βββ profile.spec.ts
βββ vitest.config.ts # Vitest configuration
βββ playwright.config.ts # Playwright configuration
- Components: Tests are co-located with components (same folder)
- Pages: Page tests are in
__tests__folders within page directories - Server Actions: Tests are in
__tests__folders within action directories - Utilities: Tests are in
__tests__folders within lib directories
- Server actions: 80%+ coverage
- Utility functions: 90%+ coverage
- Components: 70%+ coverage
- Overall: 75%+ coverage
When writing new tests:
- Unit Tests: Test individual functions and components in isolation
- Integration Tests: Test interactions between multiple components or services
- E2E Tests: Test complete user flows from start to finish
Example unit test:
import { describe, it, expect } from 'vitest';
import { render, screen } from '@/tests/utils';
import MyComponent from './MyComponent';
describe('MyComponent', () => {
it('should render correctly', () => {
render(<MyComponent />);
expect(screen.getByText('Hello')).toBeInTheDocument();
});
});- Next.js Documentation - Learn about Next.js features
- Better Auth Documentation - Authentication library docs
- shadcn/ui Documentation - UI component library
- Tailwind CSS Documentation - CSS framework
- Drizzle Documentation - Database ORM library
- Vitest Documentation - Testing framework
- Playwright Documentation - E2E testing framework
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License.