An AI hairstyle changer application built with React and Cloudflare Workers, leveraging AI technology to provide personalized hairstyle recommendations and image generation services.
- 🎨 AI-Powered Hairstyle Generation: Intelligent hairstyle design powered by GPT-4o and Flux Kontext
- 📱 Responsive Design: Optimized for both desktop and mobile devices
- 🔐 Google OAuth Authentication: Secure and convenient user authentication
- ☁️ Serverless Deployment: Built on Cloudflare Workers serverless architecture
- 💾 Full-Stack Data Storage: Integrated with D1 Database, R2 Object Storage, and KV Cache
This project is built with a modern tech stack:
- React: UI framework for building user interfaces
- React Router v7: Application routing and server-side API handling
- Cloudflare Workers: Serverless runtime environment
- Cloudflare D1: Serverless SQL database at the edge
- Cloudflare R2: Object storage service
- Cloudflare KV: Key-value storage
- Tailwind CSS: Utility-first CSS framework
- DaisyUI: Tailwind CSS component library
- React OAuth: Google OAuth authentication
- Node.js 18+
- pnpm
- Cloudflare account
git clone https://github.com/neyric/ai-hairstyle.git
cd ai-hairstylepnpm installCopy and edit the environment variables in wrangler.jsonc file:
Get your Kie AI API key:
{
"vars": {
"KIEAI_APIKEY": "your_kie_ai_api_key_here"
}
}Create OAuth 2.0 credentials in Google Cloud Console:
{
"vars": {
"GOOGLE_CLIENT_ID": "your_google_client_id",
"GOOGLE_CLIENT_SECRET": "your_google_client_secret"
}
}Create and configure the following Cloudflare services:
- D1 Database:
wrangler d1 create hairroom- KV Namespace:
wrangler kv:namespace create "hairroom-kv"- R2 Bucket:
wrangler r2 bucket create hairroomThen configure the bindings in wrangler.jsonc:
{
"d1_databases": [
{
"binding": "DB",
"database_name": "hairroom",
"database_id": "your_d1_database_id",
"migrations_dir": "./app/.server/drizzle/migrations"
}
],
"kv_namespaces": [
{
"binding": "KV",
"id": "your_kv_namespace_id"
}
],
"r2_buckets": [
{
"binding": "R2",
"bucket_name": "hairroom"
}
]
}Run database migrations to create the necessary tables:
pnpm run db:migrate # Remote database migration
pnpm run db:migrate:local # Local database migrationAfter running pnpm run db:migrate:local, start the development server:
pnpm run devNavigate to http://localhost:5173 to view the application.
pnpm run deployTo bind a custom domain, uncomment and modify the following configuration in wrangler.jsonc:
{
"routes": [
{
"pattern": "your-domain.com",
"custom_domain": true
},
{
"pattern": "www.your-domain.com",
"custom_domain": true
}
]
}Then redeploy:
pnpm run deploypnpm run dev- Start development serverpnpm run build- Build for productionpnpm run deploy- Build and deploy to Cloudflare Workerspnpm run preview- Preview production buildpnpm run typecheck- Run TypeScript type checkingpnpm run cf-typegen- Generate Cloudflare Workers type definitionspnpm run db:generate- Generate database migration filespnpm run db:migrate- Run database migrationspnpm run db:migrate:local- Run local database migrations
Contributions are welcome! Please ensure you:
- 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
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenAI - GPT-4o API
- Cloudflare - Infrastructure support
- Kie AI - AI service provider
For questions or suggestions, please reach out via:
- Open an Issue
⭐ If this project helped you, please give it a star!