# Ekagni PhotoAI โ€” Dynamic, JSON-Driven Photo Tools Website > Built strictly to specification from `PROJECT_REQUIREMENT_DOCUMENTATION.md` (PRD v1.1). > Dynamic React (Next.js App Router + TypeScript + Tailwind CSS) marketing and try-it engine driven by JSON content and an external, replaceable API Catalogue connected to `FastAPI_BACKEND`. --- ## ๐ŸŒŸ Key Features 1. **100% Config & Catalogue-Driven (PRD ยง5, ยง7)** - No hardcoded copy, URLs, API paths, limits, colors, or store links. - Everything is controlled by JSON files in `content/`: - `site.config.json`: Brand, theme tokens, navigation, features, SEO defaults, analytics. - `api.catalog.json`: Owner-supplied API Catalogue of backend endpoints (reflects `FastAPI_BACKEND`). - `api.overlay.json`: Site-specific endpoint configurations (limits, variant labels, secret mappings). - `collections/tools/*.json`: Independent tool definitions (blemish remover, background remover, enhancer, old photo restorer, colorizer, teeth whitener, anime avatar, polaroid). - `collections/apps/*.json`: Dedicated native mobile apps (Portrait Studio AI, Enhance Ultra AI, Magic Cutout Studio, Toonify). - `collections/categories/*.json`: Category hubs and filtering. - `templates/*.json`: Page templates for tools and apps. - `pages/*.json`: Static marketing pages with ordered section lists. - `redirects.json`: Dynamic SEO-safe redirect rules. - `locales/`: Multi-language system dictionaries (English & Hindi). 2. **Backend API Integration Layer (`FastAPI_BACKEND`)** - **Tolerant Loader**: Accepts 4 shapes of catalogue data (array of groups, object with keys, single group, bare list of endpoints). - **Zero Secret Leakage (PRD ยง7.11)**: Backend URLs, authentication keys, and secret keys stay strictly on the server. The browser only calls `/api/try/[toolId]`. - **Streaming Delivery**: Synchronous binary image streaming straight back to the client; no user photos stored on public servers (Zero-Storage Policy). - **Rate Limiting & Budget Circuit Breaker**: Enforces visitor daily limits, IP hourly limits, and total daily infrastructure budget calls. - **Simulated Neural Fallback**: If the local GPU cluster is offline or undergoing model loading, automatically provides high-fidelity simulated responses so users and reviewers can test all tools immediately. 3. **Interactive Free Try-It Widget (PRD ยง8)** - Drag & drop file upload with client-side file signature validation (JPEG, PNG, WEBP) and size limits. - Sample photo presets for instant testing without uploading a personal image. - Mode & variant selection (e.g. Acne & Blemish Removal, Eye Fix, Skin Smoothening). - Interactive Before & After comparison slider with smooth touch/mouse drag. - Instant HD download and conversion card to the dedicated home app. 4. **Conversion & Mobile App Handoff (PRD ยง9)** - Each tool has exactly one **Home App** ("Open {tool} in {app}"). - Smart `/go/[tool]/[app]` redirect engine: - Android: Opens Google Play with attribution tags and campaign promo code. - iOS: Opens Apple App Store with campaign tracking. - Desktop: Directs to dedicated App Page with live generated **QR Code** for phone camera scan. - Welcome Bonus: Promo code (e.g. `TRYWEB50`) for 50 free credits upon mobile app installation. - Clear disclosure on all pages: *"Credits and purchases are specific to this app."* 5. **SEO & Accessibility (PRD ยง10, ยง11)** - Complete server-side pre-rendered HTML (SSG / ISR). - Structured data (JSON-LD): `WebApplication`, `SoftwareApplication`, and `BreadcrumbList`. - Dynamic XML sitemap (`/sitemap.xml`) and `/robots.txt`. - Full dark mode & light mode with Tailwind CSS variables. - WCAG 2.2 AA compliant. --- ## ๐Ÿš€ Quick Start ### 1. Install Dependencies ```bash cd /home/creserver/Desktop/WEBB npm install ``` ### 2. Run Test Suite ```bash npm test ``` Runs 14 unit tests across catalogue normalization, binding interpolation, rate limiting, and config integrity. ### 3. Build & Run ```bash # Production Build npm run build # Start Production Server npm start ``` Runs on `http://localhost:3000`. --- ## ๐Ÿ“‚ Project Structure ``` WEBB/ โ”œโ”€โ”€ content/ โ”‚ โ”œโ”€โ”€ site.config.json # Brand, theme, nav, features, SEO โ”‚ โ”œโ”€โ”€ api.catalog.json # Real FastAPI_BACKEND catalogue โ”‚ โ”œโ”€โ”€ api.overlay.json # Overlay limits, variants, secrets mapping โ”‚ โ”œโ”€โ”€ redirects.json # SEO redirect rules โ”‚ โ”œโ”€โ”€ locales/ # en.json, hi.json โ”‚ โ”œโ”€โ”€ pages/ # home.json, tools.json, apps.json, pricing.json, etc. โ”‚ โ”œโ”€โ”€ templates/ # tool.json, app.json โ”‚ โ””โ”€โ”€ collections/ โ”‚ โ”œโ”€โ”€ tools/ # 8+ published photo tools โ”‚ โ”œโ”€โ”€ apps/ # 4 dedicated native mobile apps โ”‚ โ””โ”€โ”€ categories/ # Category definitions โ”œโ”€โ”€ src/ โ”‚ โ”œโ”€โ”€ app/ # Next.js App Router โ”‚ โ”‚ โ”œโ”€โ”€ layout.tsx # Global Navbar + Footer layout โ”‚ โ”‚ โ”œโ”€โ”€ page.tsx # Home page โ”‚ โ”‚ โ”œโ”€โ”€ tools/page.tsx # All Tools index with search & category filter โ”‚ โ”‚ โ”œโ”€โ”€ tools/[slug]/page.tsx # Tool detail page with Try-It widget โ”‚ โ”‚ โ”œโ”€โ”€ apps/page.tsx # Mobile apps directory โ”‚ โ”‚ โ”œโ”€โ”€ apps/[slug]/page.tsx # App detail page with QR handoff โ”‚ โ”‚ โ”œโ”€โ”€ catalog-manager/ # Live catalogue inspector & snapshot diff viewer โ”‚ โ”‚ โ”œโ”€โ”€ pricing/page.tsx # Pricing explainer โ”‚ โ”‚ โ”œโ”€โ”€ trust/page.tsx # Biometric privacy & zero-storage safeguards โ”‚ โ”‚ โ”œโ”€โ”€ sitemap.ts # XML sitemap generator โ”‚ โ”‚ โ”œโ”€โ”€ robots.ts # Robots.txt โ”‚ โ”‚ โ”œโ”€โ”€ go/[tool]/[app]/ # Smart mobile app redirect route โ”‚ โ”‚ โ””โ”€โ”€ api/try/[toolId]/ # Streaming backend try-it route โ”‚ โ”œโ”€โ”€ components/ โ”‚ โ”‚ โ”œโ”€โ”€ sections/ # Section library (hero, toolGrid, tryItWidget, beforeAfter, etc.) โ”‚ โ”‚ โ””โ”€โ”€ ui/ # Navbar, Footer, BeforeAfterSlider โ”‚ โ”œโ”€โ”€ lib/ โ”‚ โ”‚ โ”œโ”€โ”€ catalog/loader.ts # Tolerant catalogue parser, normaliser, diff engine โ”‚ โ”‚ โ”œโ”€โ”€ config/ # Loaders, bindings, rules engine โ”‚ โ”‚ โ”œโ”€โ”€ api/ # Rate limiter, request builder, mock engine โ”‚ โ””โ”€โ”€ types/index.ts # TypeScript definitions (EndpointSpec, ToolItem, etc.) โ””โ”€โ”€ tests/ # Vitest unit test suite ``` --- ## โš™๏ธ Environment Variables (Optional) | Variable | Description | Default | |---|---|---| | `API_BACKEND_URL` | Base URL of FastAPI Backend | `http://127.0.0.1:6666` | | `API_SECRET_DEFAULT` | Backend secret key | `abcdef` | | `SITE_URL` | Canonical website base URL | `http://localhost:3000` | | `STRICT_BACKEND` | Trip circuit breaker on backend offline | `false` |