How planetscale/beam works
Main Components
• Frontend: Represented by the Next.js pages (located under the pages/ directory) and UI components (in the components/ folder). These include the core public pages (home, post details, profile, sign-in) and controls that bring the Markdown editor, image handling, and interactive elements like buttons and dialogs together.
• Backend/API: Capture the API endpoints and server-side routing. This includes the API routes in pages/api (e.g., authentication with NextAuth.js, Cloudinary sign, and trpc integration) as well as the server/ folder which contains the context and routers that handle business logic (comment, post, user operations).
• Business Logic & Services Layer: The lib/ folder holds key utility functions and service integrations (e.g., auth, prisma, cloudinary, slack, and tRPC). This layer encapsulates much of the application logic.
• Database: Indicate the connection with a PlanetScale database managed via Prisma (prisma/schema.prisma), with additional seed data and schema definitions under .pscale/seed-data.
• External Services: Include integrations with Cloudinary (for image uploads), Slack (for notifications), and the authentication providers (GitHub/Okta via NextAuth.js).
Relationships and Interactions
• Backend’s interaction with the Database using Prisma, outlining how requests for data (user posts, comments) are pushed/pulled from PlanetScale.
• Authentication flows where NextAuth.js manages logins and callbacks.
• Image uploads which route to Cloudinary.
• Slack notifications being triggered after certain events like new posts.
• That the business logic (server/routers and lib/ functions) serves as the intermediary between the API and the database/external integrations.
Architectural Patterns and Design Principles
• That the project follows a typical full-stack separation: a React-based frontend with a Node/Next.js backend.
• Modular, component-based structure in both UI (components/) and server routing (server/routers).
• Stress the use of environment-specific configuration (separated in env/ and .env files) to properly configure services like PlanetScale, Cloudinary, and Slack.
• That tRPC is used to create a typesafe API layer between the frontend and backend.