Lake Forest Caucus - Volunteer Management System
A Next.js web application for managing volunteer profiles with filtering, sorting, and PDF export capabilities.
Features
- 🔍 Advanced Filtering: Filter volunteers by skills, availability, and search terms
- 📊 Data Table: Clean, sortable table view of volunteer information
- 📄 PDF Export: Generate professional PDF reports of filtered volunteer lists
- 🎨 Modern UI: Built with Tailwind CSS and responsive design
- 🗄️ PostgreSQL Database: Robust data persistence with Prisma ORM
- 🔐 NationBuilder Authentication: Secure OAuth integration with your NationBuilder account
- 🚀 Netlify Ready: Configured for easy deployment to Netlify
Tech Stack
- Frontend: Next.js 14, React 18, TypeScript
- Styling: Tailwind CSS
- Database: PostgreSQL with Prisma ORM
- PDF Generation: Puppeteer
- Deployment: Netlify
Getting Started
Prerequisites
- Node.js 18+
- PostgreSQL database (local or cloud)
- npm or yarn
Installation
-
Clone and install dependencies:
git clone <your-repo-url> cd lfc-volunteer-app npm install
-
Set up the database:
# Copy environment file and configure cp .env.local.example .env.local # Edit .env.local with your database URL # DATABASE_URL="postgresql://username:password@localhost:5432/lfc_volunteers" # Generate Prisma client and push schema npx prisma generate npx prisma db push
-
Run the development server:
Database Setup
Local PostgreSQL
- Install PostgreSQL locally
- Create a database:
createdb lfc_volunteers - Update
.env.localwith your connection string
Cloud Database (Recommended for Production)
We recommend using:
- Supabase (Free tier available)
- Neon (Serverless PostgreSQL)
- Railway (Easy deployment)
- PlanetScale (MySQL alternative)
Environment Variables
Create a .env.local file in the root directory:
# Database DATABASE_URL="postgresql://username:password@hostname:5432/database_name" # NextAuth Configuration NEXTAUTH_URL="http://localhost:3000" NEXTAUTH_SECRET="your-secure-random-secret-key-here" # NationBuilder OAuth Configuration NATIONBUILDER_BASE_URL="https://your-nation.nationbuilder.com" NATIONBUILDER_CLIENT_ID="your-nationbuilder-client-id" NATIONBUILDER_CLIENT_SECRET="your-nationbuilder-client-secret"
NationBuilder Setup
1. Create OAuth Application
- Log in to your NationBuilder admin panel
- Go to Settings > Developer > API Tokens & OAuth Applications
- Click "Create OAuth Application"
- Fill in the details:
- Name: "Lake Forest Caucus Volunteer Management"
- Redirect URI:
http://localhost:3000/api/auth/callback/nationbuilder(for development) - Redirect URI:
https://your-netlify-site.netlify.app/api/auth/callback/nationbuilder(for production)
2. Get Your Credentials
After creating the OAuth application, you'll receive:
- Client ID: Copy this to
NATIONBUILDER_CLIENT_ID - Client Secret: Copy this to
NATIONBUILDER_CLIENT_SECRET
3. Configure Base URL
Set NATIONBUILDER_BASE_URL to your NationBuilder nation URL:
- For example:
https://lakeforestcaucus.nationbuilder.com
4. User Permissions
The authentication system will automatically retrieve:
- User's membership level
- Tags/roles in NationBuilder
- Profile information (name, email, etc.)
You can use this information to control access levels within your application.
Deployment to Netlify
Automatic Deployment
-
Connect your GitHub repository to Netlify
-
Set build settings:
- Build command:
npm run build - Publish directory:
.next - Node version: 18
- Build command:
-
Add environment variables in Netlify:
- Go to Site settings > Environment variables
- Add your
DATABASE_URLand other environment variables
-
Deploy:
- Push to your main branch
- Netlify will automatically build and deploy
Manual Deployment
# Build the application npm run build # The .next folder will be created # Upload this to Netlify or use Netlify CLI
Database Management
Prisma Commands
# Generate Prisma client npx prisma generate # Push schema changes to database npx prisma db push # Open Prisma Studio (database GUI) npx prisma studio # Create migration (if using migrations) npx prisma migrate dev
Project Structure
├── app/ # Next.js App Router
│ ├── api/ # API routes
│ │ ├── volunteers/ # Volunteer CRUD operations
│ │ └── export-pdf/ # PDF generation
│ ├── globals.css # Global styles
│ ├── layout.tsx # Root layout
│ └── page.tsx # Home page
├── components/ # Reusable UI components
│ ├── volunteer-dashboard.tsx
│ ├── volunteer-table.tsx
│ ├── volunteer-filters.tsx
│ └── export-button.tsx
├── lib/ # Utilities and types
│ ├── db.ts # Database connection
│ ├── types.ts # TypeScript types
│ └── utils.ts # Utility functions
├── prisma/ # Database schema
│ └── schema.prisma # Prisma schema
└── public/ # Static assets
API Routes
GET /api/volunteers- Fetch volunteers with filteringPOST /api/volunteers- Create new volunteerPOST /api/export-pdf- Generate PDF report
Features to Add
- User authentication integration
- Volunteer profile editing/deletion
- Bulk import/export
- Email notifications
- Advanced reporting
- Admin dashboard
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
License
This project is licensed under the MIT License.