Generate personalized birthday invitation cards, custom t-shirt designs, and AI-powered party plans using FastAPI, Google Generative AI, and image processing.
- π Birthday Card Generation: Create personalized invitation cards with custom themes, messages, and AI-generated images
- π T-Shirt Design: Generate custom t-shirt designs and mockups based on user preferences
- π Party Planning: AI-powered party planning with gift suggestions and product recommendations
- βοΈ Cloud Integration: Automatic image upload to Cloudinary for storage and delivery
- π€ AI-Powered: Uses Google Generative AI (Gemini 2.5) for text and image generation
- Backend: FastAPI, Uvicorn
- AI/ML: Google Generative AI (Gemini 2.5), ONNX Runtime
- Image Processing: Pillow, rembg (background removal)
- Cloud Storage: Cloudinary
- Utilities: Tenacity (retry logic), python-dotenv
- Validation: Pydantic
- Python 3.8+
- Google Generative AI API key
- Cloudinary account credentials
-
Clone the repository:
git clone <repo-url> cd PartyPlaneGenerator
-
Install dependencies:
pip install -r requirements.txt
-
Environment Configuration: Create a
.envfile in the root directory:GEMINI_API_KEY=your_gemini_api_key CLOUDINARY_CLOUD_NAME=your_cloud_name CLOUDINARY_API_KEY=your_api_key CLOUDINARY_API_SECRET=your_api_secret
-
Run the application:
uvicorn main:app --reload
-
Access API Documentation:
- Swagger UI: http://127.0.0.1:8000/docs
- ReDoc: http://127.0.0.1:8000/redoc
Endpoint: POST /api/v1/generate-card
Description: Generates personalized birthday invitation cards with AI-generated text and images.
Request Body:
{
"theme": "Football lover",
"description": "Playing a boy football with cake",
"age": 10,
"gender": "Male",
"birthday_person_name": "Prinom",
"venue": "Party Hall",
"date": "12 Oct 2025",
"time": "4:00 PM",
"contact_info": "01610982021"
}Response:
{
"invitation_text": "Generated invitation text...",
"images": [
{
"url": "https://cloudinary.com/image-url",
"public_id": "image_public_id"
}
]
}Endpoint: POST /t_shirt_generate
Description: Creates custom t-shirt designs and mockups based on user specifications.
Request: Form Data
t_shirt_type(required): Type of t-shirt (Adult or child)t_shirt_size(required): Size (S, M, L, XL)gender(required): Gender fit (male, female)t_shirt_color(required): Base color (black, white, red, etc.)age(required): Age of target wearert_shirt_theme(required): Theme/style (birthday, sports, cartoon)optional_description(optional): Additional design descriptionimg_file(optional): Image file for design reference
Response:
{
"generated_design_url": "https://cloudinary.com/design-url",
"generated_mockup_url": "https://cloudinary.com/mockup-url"
}Supported File Types: JPEG, PNG, BMP
Endpoint: POST /party_generate
Description: Generates comprehensive party plans with gift suggestions and product recommendations.
Request Body:
{
"person_name": "John",
"person_age": 8,
"budget": 1500.0,
"num_guests": 15,
"party_date": "2025-12-15",
"location": "Home",
"party_details": {
"theme": "Superhero",
"favorite_activities": ["games", "dancing", "crafts"]
},
"num_product": 5
}Response:
{
"party_plan": {
"π¨ Theme & Decorations": ["decoration suggestions"],
"π Fun Activities": ["activity list"],
"π Food & Treats": ["food suggestions"],
"ποΈ Party Supplies": ["supply list"],
"β° Party Timeline": ["timeline with emojis"],
"π Suggested Gifts": ["gift suggestions"],
"π New Adventure Ideas": ["adventure ideas"]
},
"suggest_gifts": ["product recommendations"],
"all_product": ["available products"]
}PartyPlaneGenerator/
βββ app/
β βββ api/v1/endpoints/ # API route handlers
β β βββ generate_card.py # Birthday card endpoints
β β βββ t_shirt_endpoint.py # T-shirt design endpoints
β β βββ generate_party.py # Party planning endpoints
β βββ schemas/ # Pydantic models
β β βββ invite.py # Birthday card schemas
β β βββ schema.py # T-shirt and party schemas
β βββ services/ # Business logic
β β βββ generator.py # Card generation service
β β βββ t_shirt/shirt.py # T-shirt generation service
β β βββ party/party.py # Party planning service
β βββ utils/ # Utilities
β β βββ helper.py # Helper functions
β β βββ logger.py # Logging configuration
β βββ config.py # Application configuration
βββ config/ # Configuration files
βββ data/ # Sample/reference images
βββ generated_cards/ # Generated card outputs
βββ logs/ # Application logs
βββ main.py # FastAPI application entry point
βββ requirements.txt # Python dependencies
| Variable | Description | Required |
|---|---|---|
GEMINI_API_KEY |
Google Generative AI API key | Yes |
CLOUDINARY_CLOUD_NAME |
Cloudinary cloud name | Yes |
CLOUDINARY_API_KEY |
Cloudinary API key | Yes |
CLOUDINARY_API_SECRET |
Cloudinary API secret | Yes |
Key configuration constants in app/config.py:
MODEL_NAME: "gemini-2.5-flash-image-preview"PRODUCT_MODEL: "gemini-2.5-flash"TEMPERATURE: 1.0PRODUCT_API: External product API endpoint
The API implements comprehensive error handling:
- 400: Bad Request (invalid file types, missing files)
- 404: Not Found (file not found)
- 500: Internal Server Error (AI generation failures, processing errors)
Retry logic is implemented for AI API calls with exponential backoff.
Application logs are stored in the logs/ directory with timestamps. Logs include:
- Request processing information
- AI generation status
- Error details and stack traces
- Retry attempts
uvicorn main:app --reload --host 0.0.0.0 --port 8000The application includes test files and sample data in the data/ directory for development and testing purposes.
The application is configured for production deployment with:
- CORS middleware for cross-origin requests
- Async request handling
- Background task processing
- Automatic cleanup of temporary files
MIT
For more detailed API testing, visit the interactive documentation at /docs when running the application.