How valehernandezz/spookify works
Project type and purpose
• This is a full-stack web application built with Next.js 13’s App Router, React, TypeScript and Tailwind CSS.
• It lets end users upload or pick images, apply AI-powered horror effects (via Perplexity API), manage image assets (via Cloudinary), then download or share the results.
Key file-structure insights
• Top level: next.config.mjs, tsconfig.json, Tailwind/PostCSS configs → a Next.js build and styling pipeline.
• src/app/ → Next.js App Router directory:
• (routes) contains dynamic pages (/[publicId], /editar).
• api/generate, api/upload, api/shared → serverless API routes.
• layout.tsx, globals.css, page.tsx etc. → root layout and entry points.
• src/hooks, src/lib, src/store → custom hooks, shared types/utilities, React context providers for state.
README-derived tech stack
• Next.js 13 (React) for UI and SSR/SSG.
• Cloudinary API for image storage, transformation, upload/presets.
• Perplexity API for generative-AI effects.
• Tailwind CSS for styling.
• TypeScript (static types) alongside some JSX.
Main components in the system design
a. Client (Browser)
• Next.js pages (SSR/SSG), React components, user interactions (upload, select tool, preview, download).
b. Next.js Frontend Layer
• app/layout.tsx as root, global CSS, navigation headers/footers.
• page components under src/app/(routes).
• React component tree under src/components.
• State management via Providers.tsx, custom hooks.
c. Next.js Backend Layer (Serverless Functions)
• /api/upload → receives raw image from client, calls Cloudinary upload API, returns asset URL.
• /api/generate → takes image URL + selected effect parameters, calls Perplexity API (or Cloudinary transformations), returns modified image URL.
• /api/shared → fetches public image by ID (from Cloudinary or metadata store).
d. External Services
• Cloudinary
• Storage of originals & derived images
• On-the-fly transformations (background replacement, overlays, cropping)
• Perplexity AI
• AI prompts to generate custom effects not covered by presets
e. Static Asset Store
• public/examples, public/tools, public/profiles for demo images and built-in assets.
Relationships and data flows
• User uploads image → Browser → POST /api/upload → Cloudinary → upload response → Browser updates state.
• User selects effect → Browser → POST /api/generate with image URL + effect ID → Perplexity API or Cloudinary transformation → returns new image URL → Browser updates preview.
• User downloads/shares → Browser either fetches from Cloudinary URL or routes through /api/shared → presents final asset.
• Next.js pages render via SSR/SSG, fetch initial data (e.g., examples) from public folder or service endpoints.
Architectural patterns & design principles
• Component-based UI (Atoms → Molecules → Organisms under src/components).
• Serverless functions as micro-APIs (each API route handles a single responsibility).
• Separation of concerns:
• UI (components, pages)
• State (context providers, hooks)
• Data access (API routes, lib/types)
• Externalize assets & transformations via third-party APIs instead of self-hosted services.
• Consistent styling via Tailwind utility classes.
Essential call-outs
• Root layout (src/app/layout.tsx) as the SSR entrypoint.
• State Provider component (src/store/Providers.tsx).
• API endpoints under src/app/api.
• Static asset folder feeding into SSR and client (public/*).