architecture

PredatorAlgo Landing

Generado por: oscar · 2026-06-19 14:57 · Fuentes: code, github

🇪🇸 Arquitectura — PredatorAlgo Landing

En una línea: Landing + funnel de suscripción en Next.js 16 (App Router) sobre Vercel, que al cobrar con Stripe otorga acceso automático a un indicador privado de TradingView y a un canal VIP de Telegram, con estado operativo en Redis (Upstash) y un job diario que revoca accesos vencidos.

Stack

Estructura del repo

app/
  (landing)/        # sitio público: home, pricing, about, faq, how-it-works, education
  (admin)/admin/    # dashboard interno: grant queue, customers/[id]/{stripe,telegram,tradingview}
  api/              # stripe/{checkout,webhook} · telegram/webhook · tv/grant-manual · cron/revoke-expired
  beta/             # activación por promo-code (JWT)
  checkout/success/ # confirmación post-pago + invite Telegram
  legal/            # billing, cookies, privacy, terms, trading-disclaimer
actions/            # Server Actions (admin.ts, checkout.ts)
components/         # admin · checkout · landing · shared · ui (shadcn)
lib/
  redis/            # client, keys, session-store, customer-paid-store, lock, idempotency
  stripe/           # client, checkout, webhook events, dispatch, price-map
  telegram/         # client, invite, kick, membership, dispatch
  tradingview/      # client, grant, revoke, session, expiration
  access/           # fallback-queue
  reconcile/        # reconcile.ts (lógica del cron)
  beta/ consent/ constants/ feature-flags.ts
scripts/            # CLIs: stripe-setup, tv-access, tg-set-webhook, mint-beta-tokens, verify-*
e2e/ openspec/ .docs/ · next.config.ts · vercel.json · .github/workflows/ci.yml

Componentes principales

ComponenteRolDónde
LandingSitio público (home, pricing, FAQ, etc.)app/(landing)/, components/landing/
Checkout API + Server ActionCrea la Stripe Checkout Sessionapp/api/stripe/checkout/route.ts, actions/checkout.ts
Stripe Webhookcheckout.session.completed + ciclo de suscripción → grant/revokeapp/api/stripe/webhook/route.ts, lib/stripe/dispatch.ts
Capa TradingViewCliente endurecido del API privado (grant/revoke de acceso Pine)lib/tradingview/{client,grant,revoke,session}.ts
Capa TelegramInvite single-use, kick, tracking de membresíalib/telegram/{client,invite,kick,membership}.ts
Capa RedisEstado: sesión TV, idempotencia, customer-paid, lock, fallback queuelib/redis/
Cola de fallbackCola en Redis para grants fallidos; se drena por endpoint/operadorlib/access/fallback-queue.ts, app/api/tv/grant-manual/route.ts
Cron de reconciliaciónRevoca accesos vencidos (TV + Telegram)app/api/cron/revoke-expired/route.ts, lib/reconcile/reconcile.ts
Admin DashboardGrant queue + gestión de clientes + ops manualesapp/(admin)/admin/, actions/admin.ts
BetaGate por token JWT para ~10 testersapp/beta/page.tsx, lib/beta/token.ts

Flujo de datos

Pago → acceso (principal):

  1. El usuario hace clic en el CTA (app/(landing)/pricing/)
  2. La Server Action (actions/checkout.ts) crea la Checkout Session (lib/stripe/checkout.ts) → redirige a Stripe
  3. Stripe envía checkout.session.completed a app/api/stripe/webhook/route.ts
  4. El webhook verifica firma (STRIPE_WEBHOOK_SECRET) y despacha (lib/stripe/dispatch.ts)
  5. Otorga acceso TV (lib/tradingview/grant.ts → sesión cacheada en Redis → API privado de TradingView)
  6. Persiste el cliente en Redis con clave de idempotencia (lib/redis/{customer-paid-store,idempotency}.ts)
  7. Si el grant TV falla → encola en la fallback queue (lib/access/fallback-queue.ts)
  8. Genera invite de Telegram (lib/telegram/invite.ts) y lo muestra en app/checkout/success/

Revocación diaria: Vercel Cron (06:00 UTC) → /api/cron/revoke-expired (auth CRON_SECRET) → lib/reconcile/reconcile.ts busca vencidos en Redis → revoca en TV + Telegram, con tope de blast-radius (RECONCILE_MAX_REVOCATIONS).

Fallback manual: POST /api/tv/grant-manual (auth OPERATOR_SECRET) o el Admin Dashboard drenan los grants que fallaron.

flowchart LR
  User --> Landing["Landing / Pricing"]
  Landing --> CO["Server Action checkout"]
  CO --> Stripe[("Stripe Checkout")]
  Stripe -->|webhook| WH["/api/stripe/webhook"]
  WH --> TV["lib/tradingview/grant"]
  WH --> TG["lib/telegram/invite"]
  WH --> Redis[("Upstash Redis")]
  TV -. falla .-> FQ["Fallback queue"]
  FQ --> Manual["/api/tv/grant-manual · Admin"]
  Cron["Vercel Cron 06:00"] --> REC["lib/reconcile"] --> Redis
  REC --> Revoke["TV revoke + Telegram kick"]

Integraciones externas

Build / deploy / entornos

Decisiones y riesgos técnicos

🇬🇧 Architecture — PredatorAlgo Landing (summary)

In one line: A Next.js 16 (App Router) subscription landing on Vercel that, on a Stripe payment, auto-grants access to a private TradingView indicator and a Telegram VIP channel; operational state lives in Upstash Redis, and a daily cron revokes expired access.

Read from real code at ../predatoralgo (commit 218d1f9, branch main) + GitHub swissbull-group/predatoralgo. Paths, stack, and integrations are verified against the source; nothing invented.