A modern, serverless application for students to apply for joining the STEM Gharbiya GitHub organization. Built with Cloudflare Pages, Workers, and D1 database.
- Responsive Form: Clean, accessible form with real-time validation
- Dark/Light Theme: Automatic theme detection with manual toggle
- Rate Limiting: Prevents abuse with configurable rate limits on form submissions
- Bot Protection: Cloudflare Turnstile captcha integration for enhanced security
- Duplicate Prevention: Prevents multiple submissions with same email + GitHub username
- Serverless Backend: Cloudflare Workers for API endpoints
- Database Storage: Cloudflare D1 for persistent data storage
- Email Notifications: Automated emails to applicants and team via Resend (configurable)
- Error Handling: Comprehensive client and server-side error management
- Frontend: HTML5, CSS3, Vanilla JavaScript, Cloudflare Turnstile
- Backend: Cloudflare Workers (TypeScript)
- Database: Cloudflare D1 (SQLite)
- Rate Limiting: Cloudflare KV for distributed rate limiting
- Email: Resend API
- Deployment: Cloudflare Pages
- Development: Wrangler CLI
- Node.js 18+
- Cloudflare account
- Resend account for email
- Git
-
Clone the repository
git clone https://github.com/stemgharbiya/join.git cd stemgharbiya-join -
Install dependencies
npm install # or pnpm install -
Set up Cloudflare D1 database
npx wrangler d1 create stemgharbiya-applications npx wrangler d1 execute stemgharbiya-applications --command=" CREATE TABLE applications ( id INTEGER PRIMARY KEY AUTOINCREMENT, fullName TEXT NOT NULL, schoolEmail TEXT NOT NULL, githubUsername TEXT NOT NULL, seniorYear TEXT NOT NULL, interests TEXT NOT NULL, motivation TEXT NOT NULL, timestamp TEXT NOT NULL ); "
-
Set up Cloudflare KV namespace for rate limiting
npx wrangler kv:namespace create "SUBMIT_RATE_LIMITER" # Update the id in wrangler.toml with the generated namespace ID
-
Configure environment variables
Create
.dev.varsfile:RESEND_API_KEY=your_resend_api_key RESEND_SENDER_EMAIL=your-verified-email@resend.dev TEAM_NOTIFICATION_EMAIL=team@example.com TURNSTILE_SECRET_KEY=your_turnstile_secret_key DISABLE_EMAILS=false -
Start development server
npm run dev # or pnpm dev
- Sign up for Resend
- Verify your sender domain/email
- Get your API key
- Update environment variables
- Sign up for Cloudflare
- Go to Security > Turnstile
- Create a new site key
- Get your secret key
- Update the
TURNSTILE_SECRET_KEYenvironment variable - Update the site key in your frontend configuration
-
Update wrangler.toml
- Replace placeholder database ID with your actual D1 database ID
- Replace placeholder KV namespace ID with your actual KV namespace ID
- Update environment variables in Cloudflare Dashboard
-
Deploy to Cloudflare Pages
npx wrangler pages deploy . -
Set production environment variables
npx wrangler secret put RESEND_API_KEY npx wrangler secret put RESEND_SENDER_EMAIL npx wrangler secret put TEAM_NOTIFICATION_EMAIL npx wrangler secret put TURNSTILE_SECRET_KEY npx wrangler secret put DISABLE_EMAILS
npx wrangler d1 execute stemgharbiya-applications --command="SELECT * FROM applications;"npx wrangler d1 execute stemgharbiya-applications --remote --command="SELECT * FROM applications;"npx wrangler d1 backup create stemgharbiya-applications --name backup-$(date +%Y%m%d)-
Fill out the application form with:
- Full name
- School email (@stemgharbiya.moe.edu.eg)
- GitHub username
- Senior year (S25-S30)
- Interests (select at least one)
- Motivation (10-500 characters)
-
Complete the Turnstile captcha verification
-
Submit the form
-
Receive confirmation email (if enabled)
-
Team gets notification email (if enabled)
Note: Set DISABLE_EMAILS=true in environment variables to disable email notifications during development or testing.
├── public/
│ └── join/
│ ├── index.html # Main application form
│ ├── script.js # Frontend JavaScript
│ └── styles.css # Styling
├── functions/
│ ├── api/
│ │ ├── submit.ts # Cloudflare Worker API (TypeScript)
│ │ └── ratelimit.ts # KV-based rate limiting logic
│ ├── tsconfig.json # TypeScript configuration
│ └── types.d.ts # Type definitions
├── wrangler.toml # Cloudflare configuration
├── package.json
└── README.md
npm run dev- Start development servernpm run deploy- Deploy to production
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Email: Must end with
@stemgharbiya.moe.edu.eg - Senior Year: S25, S26, S27, S28, S29, or S30 only
- Interests: At least one must be selected
- Motivation: 10-500 characters
- Duplicates: Same email + GitHub username combination blocked
- Rate Limiting: KV-based distributed rate limiting to prevent abuse and spam
- Bot Protection: Cloudflare Turnstile captcha verification
- Input Validation: Comprehensive sanitization and validation
- SQL Injection Prevention: Prepared statements and parameterized queries
- XSS Protection: HTML escaping in emails and outputs
- Environment Security: Sensitive data stored in environment variables
This project is licensed under the MIT License - see the LICENSE file for details.
- Built for STEM Gharbiya community
- Powered by Cloudflare's edge platform
- Email service by Resend