Skip to content

ofagbenro/nigeria-support-programs

Repository files navigation

Nigerian Support Programs Database

A comprehensive knowledge base web application for Nigerian support and intervention programs. Built with Next.js and designed for easy deployment to Vercel.

Features

  • Public Interface: Browse and search support programs with advanced filtering
  • Responsive Design: Works on desktop, tablet, and mobile devices
  • Admin Panel: Secure interface for adding new programs
  • No External Database: Uses file-based storage for simplicity
  • Search & Filter: Find programs by name, type, operator, or target group
  • Export Ready: Easy deployment to Vercel

Getting Started

Prerequisites

  • Node.js 18+ installed
  • npm or yarn package manager

Installation

  1. Clone or download the project files

  2. Install dependencies:

    npm install
  3. Set up environment variables:

    cp .env.example .env.local
  4. Configure your admin credentials in .env.local:

    # Generate a password hash
    node -e "console.log(require('bcryptjs').hashSync('your-secure-password', 12))"
    
    # Update .env.local with your values
    ADMIN_USERNAME=your-admin-username
    ADMIN_PASSWORD_HASH=generated-hash-from-above
    JWT_SECRET=your-very-secure-random-secret-key
  5. Create the data directory and add your programs:

    mkdir data

    Copy your programs data to data/programs.json using the structure shown in the example file.

  6. Run the development server:

    npm run dev
  7. Open your browser to http://localhost:3000

Adding Your Excel Data

The application expects data in JSON format. Here's how to convert your Excel file:

Data Structure

Each program should have this structure:

{
  "id": "unique-id",
  "programme": "Program Name",
  "type": "Program Type",
  "operator": "Operating Organization",
  "targetGroup": "Target Beneficiaries",
  "benefit": "What the program offers",
  "loanGrantSize": "Amount or size",
  "statusWindow": "Current status or application window",
  "whereToApply": "How to apply",
  "source": "Official website URL",
  "dateAdded": "2024-09-27T18:20:00.000Z",
  "lastUpdated": "2024-09-27T18:20:00.000Z"
}

Converting Your Excel Data

  1. Export your Excel file to CSV
  2. Use any CSV to JSON converter online, or
  3. Use the admin panel to add programs one by one
  4. Or create a script to batch import (see scripts/import.js example below)

Deployment to Vercel

One-Click Deploy

Deploy with Vercel

Manual Deployment

  1. Push your code to GitHub/GitLab

  2. Connect to Vercel:

    • Go to vercel.com
    • Import your repository
    • Configure environment variables in Vercel dashboard
  3. Set Environment Variables in Vercel:

    ADMIN_USERNAME=your-admin-username
    ADMIN_PASSWORD_HASH=your-generated-hash
    JWT_SECRET=your-secure-secret-key
    NODE_ENV=production
    
  4. Deploy: Vercel will automatically build and deploy your application.

Admin Access

  1. Navigate to /admin on your deployed site
  2. Login with your configured credentials
  3. Add new programs through the secure form interface

Default Admin Credentials (Change These!)

  • Username: admin
  • Password: admin123

⚠️ IMPORTANT: Change these credentials before deploying to production!

File Structure

├── app/
│   ├── admin/
│   │   └── page.tsx          # Admin panel
│   ├── api/
│   │   ├── auth/
│   │   │   ├── route.ts      # Authentication endpoints
│   │   │   └── verify/
│   │   │       └── route.ts  # Auth verification
│   │   └── programs/
│   │       └── route.ts      # Programs API
│   ├── globals.css           # Global styles
│   ├── layout.tsx            # App layout
│   └── page.tsx              # Home page
├── data/
│   └── programs.json         # Programs database
├── lib/
│   └── auth.ts               # Authentication utilities
├── .env.example              # Environment variables template
├── next.config.js            # Next.js configuration
├── package.json              # Dependencies
├── tailwind.config.js        # Tailwind CSS config
└── README.md                 # This file

Security Features

  • Password Hashing: Secure bcrypt password storage
  • JWT Authentication: Secure token-based auth
  • HTTP-Only Cookies: Prevents XSS attacks
  • Input Validation: Server-side validation for all inputs
  • CSRF Protection: Built-in Next.js CSRF protection

Customization

Styling

  • Edit app/globals.css for custom styles
  • Modify tailwind.config.js for theme changes
  • Update colors in the Nigeria green theme

Adding Features

  • Add new API routes in app/api/
  • Create new pages in app/
  • Extend the Program interface in TypeScript files

Backup and Updates

Backing Up Data

Your programs data is stored in data/programs.json. Regular backups are recommended:

# Download from Vercel (if using Vercel CLI)
vercel env pull .env.local

# Or manually copy the file from your repository

Updating Programs

  1. Use the admin panel for individual updates
  2. Edit data/programs.json directly for bulk updates
  3. Deploy changes through your Git workflow

Troubleshooting

Common Issues

  1. Admin login not working:

    • Check environment variables are set correctly
    • Verify password hash generation
    • Check browser developer tools for error messages
  2. Programs not loading:

    • Ensure data/programs.json exists and is valid JSON
    • Check file permissions
    • Verify API routes are accessible
  3. Deployment issues:

    • Check Vercel build logs
    • Verify all environment variables are set
    • Ensure all dependencies are in package.json

Getting Help

  • Check the browser console for JavaScript errors
  • Review server logs in Vercel dashboard
  • Ensure all environment variables are properly configured

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

License

This project is designed for public benefit and information sharing about Nigerian support programs.


Built with ❤️ for the Nigerian community

About

Nigerian Support & Intervention Programs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published