Skip to content

yzx396/ngo-platform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

204 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Lead Forward Platform

An NGO community platform connecting mentors and mentees

Deploy to Cloudflare

Lead Forward Platform is a comprehensive NGO community platform that connects members through mentorship, challenges, and shared learning. Beyond mentor-mentee matching, the platform features a modern community feed, gamified points system, admin-curated challenges, and member-created blogs. Built on Cloudflare's edge network, it provides fast, reliable performance for global NGO communities.


✨ Features

Community Features

  • πŸ“° Community Feed - Shared posts and updates from community members
  • 🎯 Challenges - Member challenges with points rewards (admin-curated)
  • πŸ“ Blogs - Members can publish and share blog posts with the community
  • πŸ† Leaderboard - Gamified points system showing top community contributors
  • πŸ’¬ Engagement - Like, comment, and interact with community content

Mentorship Features

  • πŸ” Google OAuth Authentication - Secure, password-free sign-in
  • πŸ‘€ Mentor Profiles - Create rich profiles with expertise, availability, and rates
  • πŸ” Public Mentor Browsing - Search and discover mentors by level, payment type, and availability
  • 🀝 User-Driven Matching - Mentees initiate match requests; mentors accept or decline
  • πŸ“Š Match Management - Track match lifecycle: pending β†’ accepted β†’ active β†’ completed
  • πŸ’³ Flexible Payments - Support for Venmo, PayPal, Zelle, Alipay, WeChat Pay, and Crypto

Platform Features

  • πŸ‘₯ Role-Based Access Control - Admin and Member roles for permission management
  • ⭐ Points & Gamification - Earn points for activities, visible on leaderboard
  • 🎨 Modern Navigation - Intuitive sidebar with Feed, Member Area, and Links sections
  • πŸ“± Responsive Design - Works seamlessly on desktop, tablet, and mobile devices
  • 🌍 Internationalization - Support for Simplified Chinese (default) and English
  • β™Ώ Accessibility - WCAG 2.1 compliant with semantic HTML and ARIA labels

πŸš€ Tech Stack

Frontend

Backend

Build & Development

  • Vite - Lightning-fast build tooling with HMR
  • Vitest - Unit testing framework
  • Wrangler - Cloudflare deployment CLI

πŸ“‹ Prerequisites

  • Node.js 18+ and npm
  • Cloudflare Account (free tier works)
  • Google Cloud Console Project (for OAuth - see setup guide below)

πŸ› οΈ Getting Started

1. Install Dependencies

npm install

2. Set Up Google OAuth

Follow the step-by-step guide in GOOGLE_OAUTH_SETUP.md to:

  1. Create a Google Cloud Console project
  2. Configure OAuth credentials
  3. Set up redirect URIs for local and production environments

Then create a .dev.vars file in the project root:

# .dev.vars (for local development)
GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=your-client-secret
JWT_SECRET=your-local-dev-secret

⚠️ Never commit .dev.vars to version control (already in .gitignore)

3. Set Up Database

Run migrations to create the database schema:

# Create local D1 database and run migrations
npm run db:migrate

Verify the schema was created:

npm run db:schema

4. Start Development Server

npm run dev

Your application will be available at http://localhost:5173


πŸ“¦ Development Commands

Core Commands

# Start development server with HMR
npm run dev

# Build for production (TypeScript compilation + Vite bundle)
npm run build

# Preview production build locally
npm run preview

# Type-check and verify build (includes dry-run deploy)
npm run check

# Lint codebase
npm run lint

Testing Commands

This project follows Test-Driven Development (TDD). Always write tests before implementing features.

# Run all tests once
npm run test

# Run tests in watch mode (auto-rerun on changes) - best for TDD
npm run test:watch

# Run tests with coverage report
npm run test:coverage

# Run tests with interactive UI
npm run test:ui

# Run specific test file
npm run test:watch -- src/react-app/__tests__/App.test.tsx

# Run only React tests
npm run test:watch -- --project=react

# Run only Worker/API tests
npm run test:watch -- --project=worker

Database Commands

# Run migrations on local D1 database
npm run db:migrate

# View local database schema
npm run db:schema

# Run migrations on production D1 database
npm run db:migrate:prod

# View production database schema
npm run db:schema:prod

Deployment Commands

# Build and deploy to Cloudflare Workers
npm run build && npm run deploy

# Deploy to production
npm run deploy

# Monitor worker logs
npx wrangler tail

# Regenerate Cloudflare types after wrangler.json changes
npm run cf-typegen

πŸ“‚ Project Structure

ngo-platform/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ react-app/           # Frontend React application
β”‚   β”‚   β”œβ”€β”€ components/      # UI components
β”‚   β”‚   β”‚   β”œβ”€β”€ Layout.tsx            # Two-column layout wrapper
β”‚   β”‚   β”‚   β”œβ”€β”€ Sidebar.tsx           # Navigation sidebar
β”‚   β”‚   β”‚   β”œβ”€β”€ Navbar.tsx            # Top navigation bar
β”‚   β”‚   β”‚   β”œβ”€β”€ UserRoleBadge.tsx     # User role display
β”‚   β”‚   β”‚   β”œβ”€β”€ UserPointsBadge.tsx   # User points display
β”‚   β”‚   β”‚   β”œβ”€β”€ MentorCard.tsx        # Mentor profile card
β”‚   β”‚   β”‚   β”œβ”€β”€ ProtectedRoute.tsx    # Auth route wrapper
β”‚   β”‚   β”‚   └── ...other components/
β”‚   β”‚   β”œβ”€β”€ context/         # React context (AuthContext)
β”‚   β”‚   β”œβ”€β”€ pages/           # Route pages (Login, HomePage, MentorBrowse, etc.)
β”‚   β”‚   β”œβ”€β”€ services/        # API client and service layer (mentorService, pointsService, etc.)
β”‚   β”‚   β”œβ”€β”€ i18n/            # Internationalization (Chinese and English)
β”‚   β”‚   └── __tests__/       # React component tests
β”‚   β”œβ”€β”€ worker/              # Backend Hono API (Cloudflare Worker)
β”‚   β”‚   β”œβ”€β”€ auth/            # Authentication (JWT, Google OAuth, middleware)
β”‚   β”‚   β”œβ”€β”€ index.ts         # Main API routes (roles, points, mentors, matches, etc.)
β”‚   β”‚   └── __tests__/       # API route tests
β”‚   └── types/               # Shared TypeScript types
β”‚       β”œβ”€β”€ user.ts          # User types
β”‚       β”œβ”€β”€ role.ts          # Role system types
β”‚       β”œβ”€β”€ points.ts        # Points system types
β”‚       β”œβ”€β”€ mentor.ts        # Mentor profile types
β”‚       β”œβ”€β”€ match.ts         # Match/mentorship types
β”‚       └── api.ts           # API request/response types
β”œβ”€β”€ migrations/              # D1 database migrations (SQLite)
β”‚   β”œβ”€β”€ 0001-0006/          # Original mentor-mentee migrations
β”‚   β”œβ”€β”€ 0007_create_user_roles_table.sql        # Role system
β”‚   └── 0008_create_user_points_table.sql       # Points system
β”œβ”€β”€ docs/                    # Documentation
β”‚   β”œβ”€β”€ ARCHITECTURE.md      # System architecture and design
β”‚   β”œβ”€β”€ NGO_PLATFORM_TRANSFORMATION.md # Vertical slice transformation plan
β”‚   └── ...other docs/
β”œβ”€β”€ dist/                    # Build output (generated)
β”‚   β”œβ”€β”€ client/              # Frontend bundle (served as static assets)
β”‚   └── worker/              # Worker bundle
β”œβ”€β”€ wrangler.json            # Cloudflare Workers configuration
β”œβ”€β”€ vite.config.ts           # Vite build configuration
β”œβ”€β”€ vitest.config.ts         # Vitest test configuration
β”œβ”€β”€ CLAUDE.md                # Detailed developer documentation
└── README.md                # This file

πŸ—οΈ Architecture Overview

Hybrid Full-Stack Architecture

The platform uses a unified deployment model where both the React frontend and Hono backend are deployed together to Cloudflare Workers:

  • Frontend: React app built with Vite, served as static assets from dist/client/
  • Backend: Hono framework handles API routes at /api/v1/*
  • Database: Cloudflare D1 (serverless SQLite) for persistent data
  • Authentication: Google OAuth 2.0 + JWT tokens (stateless, edge-friendly)

API Design

All API endpoints follow versioned RESTful conventions:

/api/v1/auth/*              # Authentication (login, callback, logout)
/api/v1/users               # User management
/api/v1/users/:id/points    # Points system
/api/v1/users/:id/role      # Role management
/api/v1/roles               # Role assignment (admin only)
/api/v1/mentors/profiles/*  # Mentor profile CRUD
/api/v1/mentors/search      # Public mentor search
/api/v1/matches/*           # Match requests and lifecycle
/api/v1/posts/*             # Feed posts (coming soon)
/api/v1/challenges/*        # Challenges system (coming soon)
/api/v1/blogs/*             # Blog management (coming soon)
/api/v1/leaderboard         # Leaderboard rankings (coming soon)

Type Safety: Shared TypeScript types (src/types/) ensure consistency between frontend and backend.

For detailed architecture documentation, database schema, development patterns, and the transformation plan, see CLAUDE.md and docs/ARCHITECTURE.md.


πŸ§ͺ Testing Philosophy

This project follows Test-Driven Development (TDD) using the Red-Green-Refactor cycle:

  1. Red - Write a failing test first
  2. Green - Write minimal code to make the test pass
  3. Refactor - Improve code while keeping tests green

When to Write Tests

Always write tests when:

  • Adding a new feature (write test first, then implement)
  • Fixing a bug (write test that reproduces bug, then fix)
  • Refactoring existing code (ensure tests exist and pass before/after)

Tests are not optional - they are part of the definition of "done."

Test Organization

Tests are colocated with source files in __tests__/ directories:

src/react-app/__tests__/    # React component tests (jsdom environment)
src/worker/__tests__/        # API route tests (node environment)

Run tests in watch mode during development for instant feedback:

npm run test:watch

πŸš€ Deployment

1. Set Up Production Secrets

Store sensitive environment variables as Cloudflare secrets (not in wrangler.json):

wrangler secret put GOOGLE_CLIENT_ID
wrangler secret put GOOGLE_CLIENT_SECRET
wrangler secret put JWT_SECRET

2. Create Production Database

If not already created, set up your production D1 database:

# Create database (if needed)
wrangler d1 create platform-db

# Update database_id in wrangler.json with the returned ID

3. Run Production Migrations

npm run db:migrate:prod

4. Build and Deploy

npm run build
npm run deploy

Your application will be deployed to Cloudflare's global edge network!

5. Monitor Logs

npx wrangler tail

🀝 Contributing

Development Workflow

  1. Write tests first (TDD approach)
  2. Run tests in watch mode during development
  3. Ensure all tests pass before committing
  4. Run linter to catch style issues
npm run test:watch    # Keep running during development
npm run test          # Final check before commit
npm run lint          # Fix linting issues
npm run build         # Verify build succeeds

Code Quality Standards

  • TypeScript strict mode - No implicit any, unused variables, or fallthrough cases
  • Test coverage - Aim for >80% coverage on critical paths
  • API versioning - All API routes must use /api/v1/ prefix
  • Type safety - Use shared types from src/types/ for API contracts

For detailed development guidelines, project-specific patterns (like bit flags), and architecture decisions, see CLAUDE.md.


πŸ“š Additional Resources


πŸ“„ License

[Your License Here - e.g., MIT]


πŸ™‹ Support

For issues, questions, or feature requests, please open an issue.


Built with ❀️ for the NGO community

About

NGO platform

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages