Skip to content

Commit 79b097e

Browse files
committed
feat: integrate business routes and update documentation
- Updated README with complete project structure, endpoints, and setup - Integrated business routes into main.py (Paddle, onboarding, analytics, calculators, dashboard) - Routes are optional with graceful fallback if not available
1 parent a2e9f06 commit 79b097e

File tree

2 files changed

+180
-94
lines changed

2 files changed

+180
-94
lines changed

README.md

Lines changed: 160 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,6 @@ Reliability layer for API calls: retries, caching, dedup, circuit breakers.
66
[![PyPI version](https://badge.fury.io/py/reliapi-sdk.svg)](https://pypi.org/project/reliapi-sdk/)
77
[![Docker](https://img.shields.io/docker/v/kikudoc/reliapi?label=docker)](https://hub.docker.com/r/kikudoc/reliapi)
88

9-
## Installation
10-
11-
- **Product Hunt**: [⭐ Support us on Product Hunt](https://www.producthunt.com/products/reliapi) - Help us reach more developers!
12-
- **RapidAPI**: [Try ReliAPI on RapidAPI](https://rapidapi.com/kikuai-lab-kikuai-lab-default/api/reliapi) - No installation required, use directly from RapidAPI
13-
- **NPM Package**: [reliapi-sdk](https://www.npmjs.com/package/reliapi-sdk) - `npm install reliapi-sdk`
14-
- **PyPI Package**: [reliapi-sdk](https://pypi.org/project/reliapi-sdk/) - `pip install reliapi-sdk`
15-
- **Docker Image**: [kikudoc/reliapi](https://hub.docker.com/r/kikudoc/reliapi) - `docker pull kikudoc/reliapi`
16-
- **CLI Package**: [reliapi-cli](https://pypi.org/project/reliapi-cli/) - `pip install reliapi-cli`
17-
189
## Features
1910

2011
- **Retries with Backoff** - Automatic retries with exponential backoff
@@ -24,69 +15,177 @@ Reliability layer for API calls: retries, caching, dedup, circuit breakers.
2415
- **Rate Limiting** - Built-in rate limiting per tier
2516
- **LLM Proxy** - Unified interface for OpenAI, Anthropic, Mistral
2617
- **Cost Control** - Budget caps and cost estimation
18+
- **Self-Service Onboarding** - Automated API key generation
19+
- **Paddle Payments** - Subscription management
2720

28-
## Quick Start
21+
## Project Structure
2922

30-
### Using RapidAPI (No Installation Required)
23+
```
24+
reliapi/
25+
├── core/ # Core reliability components
26+
│ ├── cache.py # Redis-based TTL cache
27+
│ ├── circuit_breaker.py
28+
│ ├── idempotency.py # Request coalescing
29+
│ ├── retry.py # Exponential backoff
30+
│ ├── rate_limiter.py # Per-tenant rate limits
31+
│ ├── rate_scheduler.py # Token bucket algorithm
32+
│ ├── key_pool.py # Multi-key management
33+
│ └── cost_estimator.py # LLM cost calculation
34+
├── app/
35+
│ ├── main.py # FastAPI application
36+
│ ├── services.py # Business logic
37+
│ ├── schemas.py # Pydantic models
38+
│ └── routes/ # Business routes
39+
│ ├── paddle.py # Payment processing
40+
│ ├── onboarding.py # Self-service signup
41+
│ ├── analytics.py # Usage analytics
42+
│ ├── calculators.py# ROI/pricing calculators
43+
│ └── dashboard.py # Admin dashboard
44+
├── adapters/
45+
│ └── llm/ # LLM provider adapters
46+
│ ├── openai.py
47+
│ ├── anthropic.py
48+
│ └── mistral.py
49+
├── config/ # Configuration loader
50+
├── metrics/ # Prometheus metrics
51+
├── examples/ # Code examples
52+
├── integrations/ # LangChain, LlamaIndex
53+
├── openapi/ # OpenAPI specs
54+
├── postman/ # Postman collection
55+
└── tests/ # Test suite
56+
```
3157

32-
Try ReliAPI directly on [RapidAPI](https://rapidapi.com/kikuai-lab-kikuai-lab-default/api/reliapi) - no SDK installation needed. Just subscribe to the API and start making requests!
58+
## Quick Start
59+
60+
### Using RapidAPI (No Installation)
3361

34-
### Using the SDK
62+
Try ReliAPI directly on [RapidAPI](https://rapidapi.com/kikuai-lab-kikuai-lab-default/api/reliapi).
3563

36-
**JavaScript/TypeScript:**
64+
### Self-Hosting with Docker
3765

3866
```bash
39-
npm install reliapi-sdk
67+
docker run -d -p 8000:8000 \
68+
-e REDIS_URL="redis://localhost:6379/0" \
69+
-e RELIAPI_CONFIG_PATH=/app/config.yaml \
70+
kikudoc/reliapi:latest
4071
```
4172

42-
```typescript
43-
import { ReliAPI } from 'reliapi-sdk';
73+
### Local Development
4474

45-
const client = new ReliAPI({
46-
baseUrl: 'https://api.reliapi.dev',
47-
apiKey: 'your-api-key'
48-
});
75+
```bash
76+
# Clone repository
77+
git clone https://github.com/KikuAI-Lab/reliapi.git
78+
cd reliapi
4979

50-
// HTTP proxy with retries
51-
const response = await client.proxyHttp({
52-
target: 'my-api',
53-
method: 'GET',
54-
path: '/users/123',
55-
cache: 300 // cache for 5 minutes
56-
});
80+
# Create virtual environment
81+
python3 -m venv venv
82+
source venv/bin/activate
5783

58-
// LLM proxy with idempotency
59-
const llmResponse = await client.proxyLlm({
60-
target: 'openai',
61-
model: 'gpt-4o-mini',
62-
messages: [{ role: 'user', content: 'Hello!' }],
63-
idempotencyKey: 'unique-key-123'
64-
});
84+
# Install dependencies
85+
pip install -r requirements.txt
86+
87+
# Start Redis
88+
docker run -d -p 6379:6379 redis:7-alpine
89+
90+
# Run server
91+
export REDIS_URL=redis://localhost:6379/0
92+
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
93+
```
94+
95+
## Configuration
96+
97+
Create `config.yaml`:
98+
99+
```yaml
100+
targets:
101+
openai:
102+
base_url: https://api.openai.com/v1
103+
llm:
104+
provider: openai
105+
default_model: gpt-4o-mini
106+
soft_cost_cap_usd: 0.10
107+
hard_cost_cap_usd: 0.50
108+
cache:
109+
enabled: true
110+
ttl_s: 3600
111+
circuit:
112+
error_threshold: 5
113+
cooldown_s: 60
114+
auth:
115+
type: bearer_env
116+
env_var: OPENAI_API_KEY
65117
```
66118
67-
**Python:**
119+
## API Endpoints
120+
121+
### Core Proxy
122+
123+
| Endpoint | Method | Description |
124+
|----------|--------|-------------|
125+
| `/proxy/http` | POST | Proxy any HTTP API with reliability |
126+
| `/proxy/llm` | POST | Proxy LLM requests with cost control |
127+
| `/healthz` | GET | Health check |
128+
| `/metrics` | GET | Prometheus metrics |
129+
130+
### Business Routes
131+
132+
| Endpoint | Method | Description |
133+
|----------|--------|-------------|
134+
| `/paddle/plans` | GET | List subscription plans |
135+
| `/paddle/checkout` | POST | Create checkout session |
136+
| `/paddle/webhook` | POST | Handle Paddle webhooks |
137+
| `/onboarding/start` | POST | Generate API key |
138+
| `/onboarding/quick-start` | GET | Get quick start guide |
139+
| `/onboarding/verify` | POST | Verify integration |
140+
| `/calculators/pricing` | POST | Calculate pricing |
141+
| `/calculators/roi` | POST | Calculate ROI |
142+
| `/dashboard/metrics` | GET | Usage metrics |
143+
144+
## Environment Variables
68145

69146
```bash
70-
pip install reliapi-sdk
147+
# Required
148+
REDIS_URL=redis://localhost:6379/0
149+
150+
# Optional
151+
RELIAPI_CONFIG_PATH=config.yaml
152+
RELIAPI_API_KEY=your-api-key
153+
CORS_ORIGINS=*
154+
LOG_LEVEL=INFO
155+
156+
# LLM Providers
157+
OPENAI_API_KEY=sk-...
158+
ANTHROPIC_API_KEY=sk-ant-...
159+
MISTRAL_API_KEY=...
160+
161+
# Paddle (for payments)
162+
PADDLE_API_KEY=...
163+
PADDLE_VENDOR_ID=...
164+
PADDLE_WEBHOOK_SECRET=...
165+
PADDLE_ENVIRONMENT=sandbox
71166
```
72167

168+
## SDK Usage
169+
170+
### Python
171+
73172
```python
74173
from reliapi_sdk import ReliAPI
75174
76175
client = ReliAPI(
77-
base_url="https://api.reliapi.dev",
176+
base_url="https://reliapi.kikuai.dev",
78177
api_key="your-api-key"
79178
)
80179
81-
# HTTP proxy with retries
180+
# HTTP proxy
82181
response = client.proxy_http(
83182
target="my-api",
84183
method="GET",
85184
path="/users/123",
86185
cache=300
87186
)
88187
89-
# LLM proxy with idempotency
188+
# LLM proxy
90189
llm_response = client.proxy_llm(
91190
target="openai",
92191
model="gpt-4o-mini",
@@ -95,74 +194,42 @@ llm_response = client.proxy_llm(
95194
)
96195
```
97196

98-
### Using the CLI
197+
### JavaScript
99198

100-
```bash
101-
pip install reliapi-cli
102-
```
103-
104-
```bash
105-
# Check health
106-
reli ping
107-
108-
# Make HTTP request
109-
reli request --method GET --url https://api.example.com/users
110-
111-
# Make LLM request
112-
reli llm --target openai --message "Hello, world!"
113-
```
114-
115-
### Using the GitHub Action
116-
117-
```yaml
118-
- uses: KikuAI-Lab/reliapi@v1
119-
with:
120-
api-url: 'https://api.reliapi.dev'
121-
api-key: ${{ secrets.RELIAPI_KEY }}
122-
endpoint: '/proxy/http'
123-
method: 'POST'
124-
body: '{"target": "my-api", "method": "GET", "path": "/health"}'
125-
```
126-
127-
## API Endpoints
128-
129-
### HTTP Proxy
130-
131-
```
132-
POST /proxy/http
133-
```
134-
135-
Proxy any HTTP API with reliability layers.
199+
```typescript
200+
import { ReliAPI } from 'reliapi-sdk';
136201
137-
### LLM Proxy
202+
const client = new ReliAPI({
203+
baseUrl: 'https://reliapi.kikuai.dev',
204+
apiKey: 'your-api-key'
205+
});
138206
139-
```
140-
POST /proxy/llm
207+
const response = await client.proxyLlm({
208+
target: 'openai',
209+
model: 'gpt-4o-mini',
210+
messages: [{ role: 'user', content: 'Hello!' }]
211+
});
141212
```
142213

143-
Proxy LLM requests with idempotency, caching, and cost control.
214+
## Testing
144215

145-
### Health Check
216+
```bash
217+
# Run tests
218+
pytest
146219
220+
# With coverage
221+
pytest --cov=reliapi --cov-report=html
147222
```
148-
GET /healthz
149-
```
150-
151-
Health check endpoint for monitoring.
152223

153-
## Self-Hosting
224+
## Deployment
154225

155-
```bash
156-
docker run -d -p 8000:8000 \
157-
-e REDIS_URL="redis://localhost:6379/0" \
158-
kikudoc/reliapi:latest
159-
```
226+
See [DEPLOYMENT.md](./docs/DEPLOYMENT.md) for production deployment guide.
160227

161228
## Documentation
162229

163230
- [OpenAPI Spec](./openapi/openapi.yaml)
164231
- [Postman Collection](./postman/collection.json)
165-
- [Full Documentation](https://reliapi.kikuai.dev)
232+
- [Live Docs](https://reliapi.kikuai.dev/docs)
166233

167234
## License
168235

@@ -172,4 +239,3 @@ MIT License - see [LICENSE](./LICENSE) for details.
172239

173240
- GitHub Issues: https://github.com/KikuAI-Lab/reliapi/issues
174241
- Email: dev@kikuai.dev
175-

app/main.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,27 @@ async def rapidapi_status(request: Request):
13221322
)
13231323

13241324

1325+
# =============================================================================
1326+
# Business Routes (Paddle, Onboarding, Analytics, Calculators, Dashboard)
1327+
# =============================================================================
1328+
1329+
# Import and register business routes
1330+
try:
1331+
from reliapi.app.routes import paddle, onboarding, analytics, calculators, dashboard
1332+
1333+
app.include_router(paddle.router)
1334+
app.include_router(onboarding.router)
1335+
app.include_router(analytics.router)
1336+
app.include_router(calculators.router)
1337+
app.include_router(dashboard.router)
1338+
1339+
logger.info("Business routes registered: paddle, onboarding, analytics, calculators, dashboard")
1340+
except ImportError as e:
1341+
logger.warning(f"Business routes not available: {e}")
1342+
1343+
13251344
if __name__ == "__main__":
13261345
import uvicorn
13271346

13281347
uvicorn.run(app, host="0.0.0.0", port=8000)
1348+

0 commit comments

Comments
 (0)