File size: 1,901 Bytes
246dcd7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | # Data Science & ML Document Generation API
> Generate PDFs, contracts, reports, and forms from templates with dynamic Data Science & ML data. Embed document generation in any app.
## Features
- Full REST API
## Quick Start
```bash
# 1. Install dependencies
pip install -r requirements.txt
# 2. Configure environment
cp .env.example .env
# Edit .env with your settings
# 3. Run locally
uvicorn main:app --reload --port 8000
# 4. View interactive docs
open http://localhost:8000/docs
```
## Docker Deployment
```bash
# Build and run
docker compose up -d
# Check health
curl http://localhost:8000/health
```
## Authentication
Get a token first:
```bash
curl -X POST "http://localhost:8000/auth/token?username=admin&password=admin123"
```
Use the token in subsequent requests:
```bash
curl -H "Authorization: Bearer YOUR_TOKEN" http://localhost:8000/items
```
## API Endpoints
| Method | Path | Description |
|--------|------|-------------|
| GET | `/health` | System health |
| POST | `/auth/token` | Get JWT token |
| GET | `/items` | List all items |
| POST | `/items` | Create item |
| GET | `/items/{id}` | Get item |
| PATCH | `/items/{id}` | Update item |
| DELETE | `/items/{id}` | Delete item |
| GET | `/stats` | API statistics |
Full interactive docs: `http://localhost:8000/docs`
## Rate Limits
| Endpoint | Limit |
|----------|-------|
| `/auth/token` | 10/minute |
| `GET /items` | 60/minute |
| `POST /items` | 30/minute |
| `DELETE /items` | 20/minute |
## Running Tests
```bash
pip install pytest httpx
pytest tests/ -v
```
## Production Notes
- Change `SECRET_KEY` in `.env` before deploying
- Replace in-memory `_db` with a real database
- Add proper user management to `auth.py`
- Configure `ALLOWED_ORIGINS` for CORS
- Use Nginx/Traefik as reverse proxy
## License
MIT
|