How cyr17/action-lab-website works
Project Type & Purpose
• This is a full-stack website template that includes both a production-ready frontend (built with Next.js using the new App Router) and a robust backend powered by Payload CMS. The project is designed to manage websites, blogs, or portfolios with features like layout building, authentication, access control, SEO, media management, and draft/live preview capabilities. The system supports content publishing, customizable pages/posts, and even a pre-built admin panel.
Analyzing the File Structure
• Top-Level Organization: Notice many config files (e.g., Dockerfile, next.config.js, tsconfig.json, package.json) that manage project build, coding standards, and environment settings.
• The project is organized under a main “src” directory, which further splits into:
• "src/app": Contains two clear segments:
– (frontend): Houses Next.js page components, layouts, global CSS, and various routes serving the public site.
– (payload): Contains routes and admin panel components including API endpoints (e.g., for GraphQL and redirects), styling, and custom logic.
• "src/blocks", "src/components", "src/heros", etc.: These directories hold reusable UI components and layout blocks used both for the frontend page rendering and the Payload CMS-driven content management.
• "src/payload" outside of the “app”: Contains backend-specific code such as collections, globals, fields, access control modules, hooks, and utilities. This portion defines the CMS behavior for Users, Posts, Pages, Media, and Categories.
• Presence of Docker and docker-compose files indicates support for containerized deployment environments.
Key Components
a. Frontend (Next.js App):
• Next.js Application Routes: Show “src/app/(frontend)” containing pages, dynamic routes ([slug]), layouts, and globals.
• Static Assets & Styling: Reference public assets, global CSS, TailwindCSS configuration, and component-level styles.
• UI Components & Blocks: Include major UI components (e.g., Header, Footer, Hero, Cards) and layout blocks (e.g., ArchiveBlock, CallToAction) that make up the page structure.
b. Backend (Payload CMS):
• Payload Configuration: Represent the configuration files (src/payload/config.ts, payload-types.ts, etc.) that set up the CMS collections (Users, Posts, Pages, Media, Categories) and globals (Header, Footer, MegaMenu, etc.).
• API Endpoints: Illustrate the API routes in src/app/(payload)/api for custom endpoints (GraphQL, graphql-playground, and others) and note the usage of REST and GraphQL.
• Hooks & Utility Modules: Highlight middleware components such as afterChange hooks (for draft/live preview) and other utilities provided for content preview, revalidation, and access control.
c. Shared Components & Integrations:
• Layout Builder: A central design concept that connects both frontend (dynamic page layouts) and payload collections. Show how content blocks (hero, media, content, etc.) are interchanged between the two.
• External Services: Indicate integrations with third-party services like Cloudflare (via the Cloud Plugin) for caching, environment variables management (using .env), and authentication services.
Relationships & Data Flows
• User Interaction: Users interact with the frontend UI as well as the Payload Admin Panel.
• Data & Content Flow: Content and configuration data from the Payload backend (collections, globals) are pushed to the frontend to generate pages either via static generation or server-side rendering.
• API Communication: The frontend communicates with backend API endpoints (located in the payload API directory) to fetch dynamic data, handle authentication, and manage drafts.
• Admin Operations: Administrators utilize the Payload admin panel to create, update, publish, and seed content which then triggers hooks for revalidation or cache updates.
Architectural Patterns & Design Principles
• Full-Stack Separation: Emphasize the clear separation between the frontend and backend. Although they reside in a single codebase under distinct folders, their responsibilities and deployment strategies are modular.
• Component-Based UI: Leverage Next.js and React’s component model to compose UIs from discrete, reusable blocks.
• CMS-Driven Content: The backend is built around Payload CMS’s collection system, utilizing hooks and access control to manage content life cycles.
• API Gateway: The API endpoints under (payload)/api act as a gateway between the frontend (or external services) and the payload data store.