pounce/memory-bank/systemPatterns.md
yves.gugger 76a118ddbf
Some checks failed
CI / Frontend Lint & Type Check (push) Has been cancelled
CI / Frontend Build (push) Has been cancelled
CI / Backend Lint (push) Has been cancelled
CI / Backend Tests (push) Has been cancelled
CI / Docker Build (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
Deploy / Build & Push Images (push) Has been cancelled
Deploy / Deploy to Server (push) Has been cancelled
Deploy / Notify (push) Has been cancelled
feat: implement Yield/Intent Routing feature (pounce_endgame)
Backend:
- Add YieldDomain, YieldTransaction, YieldPayout, AffiliatePartner models
- Create IntentDetector service for keyword-based intent classification
- Implement /api/v1/yield/* endpoints (dashboard, domains, transactions, partners)
- Support domain activation, DNS verification, and revenue tracking

Frontend:
- Add /terminal/yield page with dashboard and activate wizard
- Add YIELD to sidebar navigation under 'Monetize' section
- Add 4th pillar 'Yield' to landing page 'Beyond Hunting' section
- Extend API client with yield endpoints and types

Features:
- AI-powered intent detection (medical, finance, legal, realestate, etc.)
- Swiss/German geo-targeting with city recognition
- Revenue estimation based on intent category and geo
- DNS verification via nameservers or CNAME
- 70/30 revenue split tracking
2025-12-12 14:39:56 +01:00

3.1 KiB

Pounce - System Patterns

Architecture

┌─────────────────┐      ┌────────────────────┐
│   Next.js App   │◀────▶│     FastAPI API     │
│   (Port 3000)   │      │     (Port 8000)     │
└─────────────────┘      └──────────┬─────────┘
                                 │
                    ┌───────────────┼────────────────┐
                    │               │                │
              ┌─────▼─────┐   ┌────▼────┐     ┌─────▼─────┐
              │ Postgres  │   │  Redis  │     │ External   │
              │ (primary) │   │ queue + │     │ I/O (DNS,  │
              └───────────┘   │ limiter │     │ WHOIS, HTTP│
                              └─────────┘     └───────────┘

Separate processes (recommended):
- API: `ENABLE_SCHEDULER=false`
- Scheduler: `python backend/run_scheduler.py`
- Worker: `arq app.jobs.worker.WorkerSettings`

Design Patterns

Backend

  • Repository Pattern: Database operations abstracted through SQLAlchemy
  • Service Layer: Business logic in /services (DomainChecker, AuthService)
  • Dependency Injection: FastAPI's Depends() for DB sessions and auth
  • Async First: All database and I/O operations are async

Frontend

  • Component-Based: Reusable React components
  • Global State: Zustand store for auth and domain state
  • API Client: Centralized API calls in /lib/api.ts
  • Server Components: Next.js 14 App Router with client components where needed

Authentication Flow

1. User registers → Creates user + free subscription
2. User logs in → Backend sets HttpOnly auth cookie (JWT inside cookie)
3. Frontend calls API with `credentials: 'include'`
4. Backend validates cookie → Returns user data
5. OAuth uses `state` + validated redirects, then sets cookie (no JWT in URL)

Domain Checking Strategy

1. Normalize domain (lowercase, remove protocol/www)
2. Quick DNS check (A + NS records)
3. Full WHOIS lookup for details
4. If WHOIS says available but DNS has records → Trust DNS
5. Store result and update domain status

Scheduler Pattern

APScheduler (AsyncIO mode) in separate scheduler process
                    │
    ├── Domain checks (tier-based frequency)
    ├── TLD price scrape + change detection
    ├── Auction scrape + cleanup
    └── Health cache refresh (writes DomainHealthCache used by UI)

Database Models

User (1) ─────┬───── (N) Domain
              │
              └───── (1) Subscription

Domain (1) ────── (N) DomainCheck

API Response Patterns

  • Success: JSON with data
  • Error: {"detail": "error message"}
  • Pagination: {items, total, page, per_page, pages}
  • Auth errors: 401 Unauthorized
  • Permission errors: 403 Forbidden