How forkidd214/echo-apply works
Project Type and Purpose
• This is a full-stack web application built with Next.js (app directory + React), focused on dynamic form building, management (admin), and public form publishing.
• It uses Supabase for authentication, database (PostgreSQL), and possibly storage; it also contains a JSON-server helper for local/dev purposes.
File Structure Analysis
• Top-level config: next.config.mjs, tsconfig.json, tailwind.config.ts, ESLint/Prettier configs.
• src/app: Next.js app-router pages and layouts – routes for login, auth callbacks, account management, workspace (admin dashboard), form builder (admin create, share, result), and public publish views.
• src/components: reusable React UI and domain controls (blocks, navigation, buttons, carousels).
• src/lib & src/utils: React context/providers (React Query, Supabase client), custom hooks (use-form, use-block), supabase server/client wrappers, JSON-server fallback, type definitions.
• supabase/: local CLI configuration, migrations, and seed scripts for PostgreSQL schema.
Key Architectural Patterns
• Frontend: Next.js with server-components and client-components, folder-based routing composing layouts for admin vs. public flows.
• Data layer: React Query for client-side data fetching, combined with Supabase client on the browser and server-side helpers for SSR/API routes.
• Backend: Supabase handles auth (login/logout/confirm), storage, and database. Custom middleware wraps Next.js requests to verify session.
• Development: JSON-server used in utils/json-server.ts for mocking API in dev mode if Supabase is not available.
a. Main Components
• Client (Browser): React/Next.js rendered UI, React Query hooks, Supabase JS client.
• Next.js Server: SSR and API routing layer, React server components, middleware (auth verification).
• Supabase Services:
• Auth service (signup, login, confirmation)
• Postgres DB (forms, blocks, users, results)
• Storage (if used for block thumbnails or assets)
• Remote Schema (GraphQL if configured)
• Dev Mock (JSON-server): optional local API fallback.
• Deployment Platform (e.g., Vercel): hosts Next.js, environment variables, built artifacts.
b. Relationships and Data Flows
1. Browser requests page → Next.js Server
2. Next.js SSR or RSC fetches data via:
– Supabase client (browser) for client-side queries;
– Supabase server helper (server) for SSR/API calls.
3. Supabase Auth verifies JWT session, returns auth state to Next.js middleware.
4. Postgres holds form schemas, block definitions, user accounts, results.
5. React Query caches & manages remote data, updates UI.
6. JSON-server intercepts calls when running in local/mock mode.
c. Architectural Patterns & Principles
• Separation of Concerns: UI components vs. data hooks vs. providers vs. server helpers.
• Provider pattern: react-query-provider + supabase provider wrap entire app.
• Folder-based routing enforces clear Admin vs. Public layouts.
• Migration-driven DB evolution ensures consistency between code and database schema.
d. Key Technologies
• Next.js (app router, server & client components)
• React Query (data fetching & caching)
• Supabase (Auth, Postgres, storage, GraphQL remote schema)
• Tailwind CSS (styling)
• pnpm (package management)
• JSON-server (local mocking)
Final Recommendations
• React Query layer between Browser and all data sources.
• Environment-specific paths (dev vs. prod).