diff --git a/README.md b/README.md new file mode 100644 index 0000000..e9b3614 --- /dev/null +++ b/README.md @@ -0,0 +1,64 @@ +# GPTKit + +GPTKit is a unified backend designed to provide tools via HTTP Actions for Custom GPTs. + +## Tools + +### WHOIS (`/domain/whois`) + +Allows checking domain name availability and retrieving WHOIS information. + +- **Endpoint**: `GET /domain/whois` +- **Parameters**: + - `domain` (required): The domain name to check (e.g., `google.com`). + - `force` (optional): `1` to force a fresh WHOIS lookup (ignores cache). +- **Features**: + - Persistent cache (SQLite). + - Rate limiting (global and per domain). + - Automatic availability parsing for major TLDs. + +## Deployment + +### Docker Compose + +Here is an example `docker-compose.yml` configuration to deploy GPTKit. + +> **Note**: The image is available on GHCR. Make sure to replace `your-username` with your GitHub username. + +```yaml +services: + gptkit: + image: ghcr.io/your-username/gptkit:latest + restart: unless-stopped + ports: + - "8000:8000" + environment: + # Database path inside the container + - DB_PATH=/app/data/whois_cache.db + volumes: + # Data persistence (WHOIS cache) + - ./gptkit_data:/app/data +``` + +### Environment Variables + +| Variable | Description | Default | +|----------|-------------|--------| +| `DB_PATH` | Path to the SQLite database file | `whois_cache.db` | + +## Development + +1. **Installation**: + ```bash + pip install -r requirements.txt + ``` + +2. **Run**: + ```bash + uvicorn app.main:app --reload + ``` + +3. **Tests**: + ```bash + curl "http://localhost:8000/domain/whois?domain=example.com" + ``` diff --git a/app/services/cache.py b/app/services/cache.py index c6f0151..abb2478 100644 --- a/app/services/cache.py +++ b/app/services/cache.py @@ -2,9 +2,11 @@ from datetime import datetime, timezone from typing import Optional, Dict, Any +import os + class WhoisCache: - def __init__(self, db_path: str = "whois_cache.db"): - self.db_path = db_path + def __init__(self, db_path: str = None): + self.db_path = db_path or os.getenv("DB_PATH", "whois_cache.db") self._init_db() def _init_db(self):