arctic-api

byD Subbarao

# SYSTEM ROLE You are a world-class: * Senior Full Stack Engineer * SaaS Architect * API Gateway Engineer * Security Engineer * Billing System Designer You MUST build a **production-grade API Marketplace (Play Store for APIs)**. This is NOT a demo. This must be a **fully working SaaS product**. --- # ๐ŸŽฏ PRODUCT GOAL Build a platform where: 1. Users can browse APIs 2. If API is FREE โ†’ user can use instantly 3. If API is PAID โ†’ user must: * Either subscribe via platform (Stripe) * OR add their own API key (BYOK model) 4. Users can test APIs inside the platform (Playground) 5. Platform tracks usage + analytics --- # ๐Ÿง  CORE BUSINESS LOGIC (VERY IMPORTANT) ## API TYPES ### ๐ŸŸข FREE APIs * No payment required * Direct access via gateway * No API key required (or public key) ### ๐Ÿ”ด PAID APIs Two modes: #### MODE A: BYOK (Bring Your Own Key) * User enters their own API key * Platform stores it securely (encrypted) * Requests are proxied using user's key #### MODE B: PLATFORM BILLING * User pays via Stripe * Platform provides access * Platform tracks usage + charges per request --- # ๐Ÿ—๏ธ TECH STACK ## FRONTEND * Next.js 14 (App Router) * TypeScript * Tailwind CSS * ShadCN UI * React Query ## BACKEND * NestJS (Node.js) * PostgreSQL * Prisma ORM * Redis (rate limiting, caching) * JWT Authentication ## PAYMENTS * Stripe ## INFRA * Docker * Nginx * Monorepo structure --- # ๐Ÿ“ฆ MONOREPO STRUCTURE /api-store โ”œโ”€โ”€ apps/ โ”‚ โ”œโ”€โ”€ web (Next.js frontend) โ”‚ โ”œโ”€โ”€ api (NestJS backend) โ”‚ โ”œโ”€โ”€ gateway (API proxy service) โ”œโ”€โ”€ packages/ โ”‚ โ”œโ”€โ”€ ui โ”‚ โ”œโ”€โ”€ sdk-generator โ”‚ โ”œโ”€โ”€ utils โ”œโ”€โ”€ infra/ โ”‚ โ”œโ”€โ”€ docker โ”‚ โ”œโ”€โ”€ nginx --- # ๐Ÿ—„๏ธ DATABASE SCHEMA (PRISMA) model User { id String @id @default(uuid()) email String @unique password String credits Float @default(0) createdAt DateTime @default(now()) } model API { id String @id @default(uuid()) name String category String baseUrl String isFree Boolean pricePerRequest Float? requiresSubscription Boolean authType String createdAt DateTime @default(now()) } model Subscription { id String @id @default(uuid()) userId String apiId String active Boolean } model UserAPIKey { id String @id @default(uuid()) userId String apiId String encryptedKey String } model UsageLog { id String @id @default(uuid()) userId String apiId String cost Float createdAt DateTime @default(now()) } --- # ๐Ÿ” SECURITY * JWT authentication * Encrypt API keys before storing * Rate limiting via Redis * Validate all inputs (Zod) --- # โš™๏ธ API GATEWAY (CRITICAL) Create a proxy system: Endpoint: POST /gateway/:apiId ### Logic: 1. Fetch API config from DB 2. Check: * If FREE โ†’ allow * If PAID: * Check subscription OR * Fetch user API key (BYOK) 3. Inject correct API key into headers 4. Forward request to external API 5. Log usage 6. Return response --- # ๐Ÿง  GATEWAY SAMPLE LOGIC * Handle: * Timeouts * Retries * Errors * Rate limits --- # ๐Ÿ’ณ BILLING SYSTEM (STRIPE) * Subscription plans * Pay-per-request billing * Webhook handling * Credit system --- # ๐Ÿ–ฅ๏ธ FRONTEND FEATURES ## Pages 1. Homepage * Trending APIs * Categories 2. Marketplace * Filters (Free / Paid) * Search 3. API Detail Page * Description * Pricing * Try Now button 4. Playground * JSON input editor * Response viewer * Headers input 5. Dashboard * API Keys * Usage analytics * Billing info --- # ๐ŸŽจ UI LOGIC Each API card shows: * Name * Category * Badge: FREE or PAID Buttons: * FREE โ†’ "Use Now" * PAID โ†’ "Subscribe" or "Add API Key" --- # ๐Ÿงช PLAYGROUND SYSTEM User can: * Enter JSON input * Add headers * Execute request System calls: POST /gateway/:apiId --- # ๐Ÿ”‘ API KEY SYSTEM * User can save API keys * Encrypt keys before DB storage * Decrypt only during request --- # ๐Ÿ“Š ANALYTICS * Track: * Requests per API * Cost per user * Usage trends --- # ๐ŸŒฑ SEED DATA (MANDATORY) Insert initial APIs: * OpenAI * HuggingFace * OpenWeather * CoinGecko * News API * REST Countries * NASA API --- # ๐Ÿณ DOCKER SETUP * Dockerfile for frontend * Dockerfile for backend * Docker Compose for all services --- # ๐Ÿ”„ CI/CD READY * Environment variables * Production configs --- # โš ๏ธ RULES (STRICT) DO NOT: * Skip any module * Give pseudo code * Leave incomplete parts DO: * Write full working code * Make system runnable locally * Include setup instructions --- # ๐Ÿš€ FINAL OUTPUT You MUST generate: 1. Full backend (NestJS modules) 2. Full frontend (Next.js pages) 3. API gateway implementation 4. Prisma schema 5. Docker setup 6. Stripe integration 7. Seed script 8. SDK generator 9. Auth system --- # ๐Ÿ FINAL GOAL This should result in: ๐Ÿ‘‰ A working SaaS product similar to an API marketplace ๐Ÿ‘‰ Free APIs usable instantly ๐Ÿ‘‰ Paid APIs accessible via subscription or BYOK --- # START BUILDING NOW

LandingAPI ManagerLogin
Landing

Comments (0)

No comments yet. Be the first!

Project Tasks

No tasks generated yet.

Tasks will appear here as requirements are defined.

Login: Sign In
Dashboard: View Reports
Dashboard: Monitor Usage
API Manager: Add API
API Manager: Update API
API Manager: Remove API
Analytics: Generate Report