Skip to content

pqpxo/sweet-nothings-api

Repository files navigation

πŸ’• Sweet Nothings as a Service (SNaaS)

A romantic REST API that serves random sweet nothings, compliments, and affectionate phrases. Perfect for building romantic apps, sending automated love notes, or just spreading some digital affection!

Sweet Nothings Logo

🌐 Live Demo: https://sweet.swakes.codes

🌟 Features

  • 🎯 Gender-Specific Categories: Get sweet nothings tailored for male, female, or neutral audiences
  • ⚑ Fast & Lightweight: Built with FastAPI for high performance
  • πŸ”’ Rate Limited: Prevents abuse with built-in rate limiting (120 requests/minute)
  • 🐳 Docker Ready: Includes Dockerfile and docker-compose for easy deployment
  • πŸ“Š Custom Swagger UI: Beautiful, branded API documentation
  • 🎲 Random Selection: Get completely random phrases or filter by category
  • ❀️ 100+ Phrases: Extensive collection of romantic messages across all categories

πŸš€ Quick Start

Using Docker (Recommended)

  1. Clone the repository:
git clone https://github.com/yourusername/sweet-nothings-api.git
cd sweet-nothings-api
  1. Build and run with Docker Compose:
docker-compose up -d
  1. Access the API:

Local Development

  1. Install dependencies:
pip install -r requirements.txt
  1. Run the server:
python main.py

Or with uvicorn:

uvicorn main:app --reload --host 0.0.0.0 --port 8000

πŸ“– API Documentation

Endpoints

GET /sn

Get a random sweet nothing.

Query Parameters:

  • gender (optional): male, female, or neutral (default: neutral)

Example Request:

curl "http://localhost:8000/sn?gender=female"

Example Response:

{
  "sweet_nothing": "Your smile lights up my entire world",
  "gender": "female",
  "total_available": 100
}

GET /random

Get a completely random sweet nothing from any gender category.

Example Request:

curl "http://localhost:8000/random"

GET /genders

Get all available gender categories and counts.

Example Response:

{
  "genders": ["male", "female", "neutral"],
  "counts": {
    "male": 100,
    "female": 100,
    "neutral": 136
  },
  "total_genders": 3,
  "total_sweet_nothings": 336
}

GET /health

Health check endpoint.

Example Response:

{
  "status": "healthy",
  "service": "Sweet Nothings as a Service",
  "version": "1.5.0",
  "total_sweet_nothings": 336
}

βš™οΈ Configuration

Environment Variables

Variable Description Default
ALLOWED_ORIGINS CORS allowed origins (comma-separated) * (all origins)
PORT Server port 8000

Example - Restrict CORS:

export ALLOWED_ORIGINS="https://yourdomain.com,https://www.yourdomain.com"
docker-compose up -d

Or in docker-compose.yml:

environment:
  - ALLOWED_ORIGINS=https://yourdomain.com,https://www.yourdomain.com

🐳 Docker Configuration

Build Custom Image

docker build -t sweet-nothings-api .

Run Container

docker run -d \
  -p 8000:8000 \
  -e ALLOWED_ORIGINS="*" \
  --name sweet-nothings \
  sweet-nothings-api

Docker Compose

# Start services
docker-compose up -d

# View logs
docker-compose logs -f

# Stop services
docker-compose down

πŸ› οΈ Development

Project Structure

sweet-nothings-api/
β”œβ”€β”€ main.py                 # FastAPI application
β”œβ”€β”€ sweet_nothings.py       # Database of phrases
β”œβ”€β”€ requirements.txt        # Python dependencies
β”œβ”€β”€ Dockerfile             # Docker image definition
β”œβ”€β”€ docker-compose.yml     # Docker Compose configuration
β”œβ”€β”€ start.sh              # Startup script
β”œβ”€β”€ test_api.py           # API tests
β”œβ”€β”€ templates/
β”‚   └── swagger_ui.html   # Custom Swagger UI
└── logo.png              # API logo

Running Tests

python test_api.py

Adding New Sweet Nothings

Edit sweet_nothings.py and add phrases to the appropriate category:

SWEET_NOTHINGS = {
    "male": [
        "Your new sweet nothing here",
        # ... more phrases
    ],
    "female": [
        "Your new sweet nothing here",
        # ... more phrases
    ],
    "neutral": [
        "Your new sweet nothing here",
        # ... more phrases
    ]
}

πŸ” Security Features

  • Rate Limiting: 120 requests/minute per IP for main endpoints
  • Non-root Docker User: Container runs as unprivileged appuser
  • CORS Configuration: Configurable allowed origins
  • Input Validation: Strict parameter validation
  • Health Monitoring: Built-in health check endpoint

πŸ“Š Rate Limits

Endpoint Limit
/sn 120/minute
/random 120/minute
/genders 60/minute
/health Unlimited

🀝 Contributing

Contributions are welcome! Here are some ways you can contribute:

  1. Add More Phrases: Submit PRs with new sweet nothings
  2. Improve Documentation: Help make the docs clearer
  3. Report Bugs: Open issues for any bugs you find
  4. Feature Requests: Suggest new features or improvements

Contribution Guidelines

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

🎯 Use Cases

  • Dating Apps: Add romantic elements to your app
  • Reminder Apps: Send sweet notifications to loved ones
  • Chatbots: Make your bot more romantic
  • Valentine's Day Campaigns: Spread the love!
  • Relationship Apps: Daily affirmations for couples
  • Greeting Card Generators: Create personalized cards

🌐 Production Deployment

For production deployment, consider:

  1. Set CORS restrictions:

    export ALLOWED_ORIGINS="https://yourdomain.com"
  2. Use a reverse proxy (NGINX, Traefik, Caddy)

  3. Enable HTTPS (Let's Encrypt, Cloudflare)

  4. Monitor with health checks:

    curl http://localhost:8000/health
  5. Set up logging and monitoring

πŸ’– Acknowledgments

  • Built with FastAPI
  • Rate limiting by SlowAPI
  • Containerized with Docker

πŸ“§ Contact

Have questions or suggestions? Open an issue on GitHub!


Made with ❀️ for spreading digital affection

About

A romantic REST API that serves random sweet nothings

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors