A delightful containerized FastAPI application with a beautiful web interface for generating creative pet names. Perfect for pet adoption centers, veterinary clinics, or anyone looking for the perfect name for their furry (or scaly) friend!
- π Beautiful Web Interface: Quasi-modern, responsive frontend with animations
- π Multiple Pet Types: Dogs, cats, birds, fish, and rabbits
- π² Random Name Generation: Get random names or select from curated lists
- οΏ½ PWA Support: Works offline and can be installed as an app
- π¨ Modern Design: Beautiful gradient backgrounds and smooth animations
- π― Interactive UI: Click animations, hover effects, and visual feedback
- οΏ½π Flexible API: RESTful endpoints with comprehensive documentation
- π³ Containerized: Ready-to-deploy Docker container
- π₯ Health Checks: Built-in health monitoring
- π Auto Documentation: Interactive API docs with Swagger UI
- π§ Fun Pet Facts: Learn interesting facts about your chosen pet type
- β¨οΈ Keyboard Shortcuts: Space for generate, R for random, C to copy
- Clone or download the project files
- Run the application:
docker-compose up --build- Access the application:
- Web Interface: http://localhost:8000
- API Documentation: http://localhost:8000/docs
- Alternative Docs: http://localhost:8000/redoc
# Build the image
docker build -t pet-name-api .
# Run the container
docker run -p 8000:8000 pet-name-api# Build the image
docker build -t pet-name-api .
# Run the container
docker run -p 8000:8000 pet-name-api# Install dependencies
pip install -r requirements.txt
# Run the application
python main.pyGET /- Web interface (frontend)GET /health- Health check endpoint
GET /pets/{pet_type}/names- Get names for a specific pet type- Parameters:
count(1-10, default 3),random_selection(boolean)
- Parameters:
GET /pets/{pet_type}/random- Get a single random name for a pet type
GET /pets/{pet_type}/facts- Get facts for a specific pet type- Parameters:
count(1-5, default 1)
- Parameters:
GET /pets/{pet_type}/facts/random- Get a single random fact for a pet typeGET /facts- Get random facts from all pet types- Parameters:
count(1-10, default 3)
- Parameters:
GET /facts/random- Get a single random fact from any pet type
- π
dog- Popular dog names - π±
cat- Adorable cat names - π¦
bird- Colorful bird names - π
fish- Aquatic-themed names - π°
rabbit- Cute rabbit names
The beautiful web interface includes:
- Modern gradient backgrounds with glassmorphism effects
- Smooth animations and hover effects
- Responsive design that works on all devices
- Beautiful typography with Google Fonts
- Click animations with ripple effects
- Hover transformations and scaling
- Visual feedback for all interactions
- Animated pet type selection cards
- One-click pet type selection
- Adjustable name count with +/- buttons
- Copy individual names or all names to clipboard
- Visual success/error messages
- Loading animations during API calls
Space- Generate namesR- Get random nameC- Copy names to clipboardEscape- Close error messages
- Works offline with service worker
- Can be installed as a standalone app
- App-like experience on mobile devices
- Fast loading with smart caching
- Learn fascinating facts about each pet type
- Educational content fetched dynamically from the API
- Extensive collection of interesting pet facts
curl "http://localhost:8000/pets/dog/names?count=3"Response:
{
"pet_type": "dog",
"names": ["Buddy", "Luna", "Charlie"],
"count": 3
}curl "http://localhost:8000/pets/dog/facts"Response:
{
"pet_type": "dog",
"facts": ["Dogs have been domesticated for over 15,000 years"],
"count": 1
}curl "http://localhost:8000/pets/bird/random"Response:
{
"pet_type": "bird",
"name": "Rainbow"
}curl "http://localhost:8000/facts?count=2"Response:
{
"facts": [
"Dogs have been domesticated for over 15,000 years",
"Cats spend 70% of their lives sleeping"
],
"count": 2
}Note: Check out the API docs for more examples.
The application supports the following environment variables:
PORT- Server port (default: 8000)HOST- Server host (default: 0.0.0.0)
The container includes health checks that verify the API is responding correctly:
- Interval: 30 seconds
- Timeout: 30 seconds
- Retries: 3
- Start Period: 5 seconds
To add support for new pet types:
- Add the pet type, names, and facts to
PET_NAMES_DBandPET_FACTS_DBinmain.py - The API will automatically support the new pet type for both names and facts
The codebase is structured for easy extension:
- Models: Pydantic models for request/response validation
- Data: Pet names and facts databases as dictionaries
- Routes: FastAPI route handlers with clear separation of concerns
- Validation: Built-in request/response validation with OpenAPI docs
Once running, visit these URLs for interactive documentation:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
- OpenAPI Schema: http://localhost:8000/openapi.json
For production deployment:
- Security: Use secrets management for sensitive data
- Monitoring: Implement proper logging and monitoring
- Scaling: Use a container orchestration platform like Kubernetes for scaling
- The API is stateless and suitable for horizontal scaling
- Consider adding Redis for caching if extending functionality
- Database integration can be added for dynamic pet name management
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the GNU General Public License v2.0 (GPLv2).
For questions or issues:
- Check the interactive API documentation at
/docs - Review the health endpoint at
/health - Test the API endpoints using the included
test_api.pyscript - Open an issue in the repository
Made with β€οΈ for pet lovers everywhere! πΎ