Skip to content

Commit c3fb629

Browse files
JOYclaude
andcommitted
docs: add unified billing architecture section (DOS.Me owns)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 45ec548 commit c3fb629

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

DOSafe-Architecture.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,58 @@ DOSafe reads/writes `dosafe.*` schema tables directly with `SUPABASE_SERVICE_ROL
150150

151151
---
152152

153+
## Unified Billing (Planned — DOS.Me owns)
154+
155+
### Ownership
156+
157+
| Responsibility | Owner |
158+
|----------------|-------|
159+
| Subscription management (create, upgrade, cancel) | DOS.Me |
160+
| Payment processing (Stripe webhooks) | DOS.Me |
161+
| Credit top-up flows | DOS.Me |
162+
| `public.subscriptions` table (new) | DOS.Me |
163+
| `public.billing_accounts` (existing) | DOS.Me |
164+
| Credit deduction per API call | DOSafe / DOS.AI (write to Supabase directly) |
165+
166+
Products **never call DOS.Me per request** — they read/write Supabase directly to avoid latency.
167+
168+
### Two billing models
169+
170+
**Consumer subscription** — for end users of DOSafe, DOS.AI, DOS.Me products:
171+
- Monthly plan with included quota
172+
- One subscription unlocks all consumer products
173+
- Quota enforced per product via `dosafe.client_quota` / `dosai.dosafe_usage`
174+
175+
**Credits (B2B / developer)** — for API key holders (Bexly, Rate.Box, developers):
176+
- Buy credits, spend per request, no monthly reset
177+
- `dosafe.api_keys` linked to `public.billing_accounts`
178+
- Deduction written to `public.credit_transactions`
179+
180+
### Credit pricing (DOSafe)
181+
182+
| Endpoint | Credits/request |
183+
|----------|----------------|
184+
| `/check`, `/check/bulk` (per entity) | 1 |
185+
| `/url-check` | 1 |
186+
| `/entity-check` | 1 |
187+
| `/detect` (AI text) | 10 |
188+
| `/detect-image` | 20 |
189+
190+
### Tables needed from DOS.Me
191+
192+
```sql
193+
-- public schema (DOS.Me to create)
194+
public.subscriptions (
195+
id, profile_id, plan, status,
196+
period_start, period_end, stripe_subscription_id
197+
)
198+
199+
-- public.billing_accounts already exists
200+
-- public.credit_transactions already exists
201+
```
202+
203+
---
204+
153205
## Safety Data Flow
154206

155207
```

0 commit comments

Comments
 (0)