How djmiguelr/fcfcamps works
Main Components
• Frontend (Next.js Application):
• Pages and Layout: Located under the "app" directory with pages such as the landing page (app/page.tsx) and checkout pages (app/checkout/page.tsx, app/checkout/success/page.tsx).
• Global styles: app/globals.css and additional styles in the "styles" folder.
• Layout and Routing: The standard Next.js layout (app/layout.tsx) and sitemap configuration (app/sitemap.ts).
• Backend/API:
• API Route: An API endpoint is provided in app/api/submit-form/route.ts. This endpoint likely handles form submissions (e.g., pre-registration or contact forms).
• Environment Configuration: Use of environment variables (.env.local) to secure credentials for the Google Sheets API (Google service email, private key, and sheet ID).
• Components and UI Library:
• Reusable Components: Various UI elements such as benefit cards, photo galleries, checkout buttons, modal dialogs, and so on are found in the "components" directory.
• Component Library: The "components/ui" subfolder contains detailed UI primitives (e.g., accordion, dialog, input, slider, toast, etc.) that provide building blocks for the user interface.
• Hooks and Utility Functions:
• Custom Hooks: Found in the "hooks" folder (e.g., use-mobile, use-toast) to encapsulate common functionality.
• Utility Functions: The "lib" folder, specifically lib/utils.ts, which may contain helper functions utilized throughout the application.
• External Dependencies:
• Google Sheets API: Configured via environment variables.
• Tailwind CSS: For styling, configured through tailwind.config.ts.
• Build and Deployment: Next.js configuration (next.config.mjs), along with package management (package.json, pnpm-lock.yaml) and deployment scripts mentioned in the README (including PM2 for production).
Relationships and Data Flow
• User Interactions:
• Users access the landing page and interact with various UI components and checkout processes.
• As users navigate through UI components, custom hooks manage responsiveness (mobile view) and toast notifications.
• Data Flow:
• The client-side pages interact with the backend API (e.g., form submission via /api/submit-form) using Next.js built-in API routes.
• Upon submission, the server-side component communicates with Google Sheets API to save data.
• Component Integration:
• The UI components form the core building blocks of the interface, interacting with the pages.
• The layout is wrapped with theme providers and global styles to ensure consistency.
• Environment & External Service Integration:
• When deployed, server startup and runtime configurations (with PM2) ensure persistence.
• Environment-specific variables enable secure integration with Google Sheets for data management.
Architectural Patterns and Principles
• Next.js File-based Routing: Utilize the app directory to define the routes and API endpoints.
• Modular and Component-Based Architecture: Separation of concerns is clear with dedicated directories for pages, components, hooks, and utilities.
• Separation of Concerns: Clear separation between presentation (React components and UI elements) and business logic (API routes and server configurations).
• Declarative UI and Reusability: Usage of React functional components and custom hooks fosters code reuse and easier maintenance.
Final Checklist
• Clearly labeled major components: Frontend (pages, components, hooks), API backend, external integrations (Google Sheets).
• Reference any critical technologies (Next.js, React, Tailwind, TypeScript) to provide context on the underlying stack.
• Integration of deployment and build processes as noted in the README for production environments.