How toastboy/next-www-toastboy works
Project type and purpose
• This is a full-stack, server-centric Next.js 13 application (“app” directory) backed by a MySQL database via Prisma ORM.
• Styled with Tailwind CSS.
• Infrastructure‐as‐code in terraform/ targets Azure, plus local development defined in docker-compose.yml.
• Automated testing with Jest (unit tests), Playwright (E2E), and CI/CD via GitHub Actions.
File structure
• Frontend: src/components/ (React UI), src/app/*/page.tsx (Next.js Server & Client Components).
• API layer: src/app/api/footy/.../route.ts (Next.js Route Handlers) + src/actions (server‐side business actions).
• Business logic & data access: src/services/ (domain services), src/lib/ (utilities, API client wrappers, auth, config).
• Data layer: prisma/ (schema.prisma, migrations, generated client).
• Infrastructure: terraform/ (Azure MySQL, resource groups, outputs), docker-compose.yml (local MySQL, Next.js).
• Testing: tests/ for unit, e2e/ for end-to-end using Playwright.
• CI/CD: .github/workflows/* (lint, test, terraform plan/apply).
README for additional insights
• Azure + MySQL sample adapted to own domain (“footy” data).
• Uses Prisma introspection to generate schema from live DB.
• Local dev expects DATABASE_URL environment variable.
• Run with npm run dev → localhost:3000.
a. Main components
• Browser (Next.js front-end pages & client components).
• Next.js server layer (React Server Components, Route Handlers / API).
• Business services layer (src/services, src/actions).
• Prisma Client (generated client communicates via SQL).
• MySQL database (Azure-hosted in production, Docker container locally).
• Infrastructure as Code (Terraform → Azure resources).
• CI/CD pipelines (GitHub Actions).
• Observability (Sentry, instrumentation).
• Test runners (Jest, Playwright) as separate logical components.
b. Relationships and interactions
• Browser ⟷ Next.js Server Components (HTTP/SSR).
• Browser → API Route Handlers (fetch/XHR for dynamic data).
• Route Handlers → Services (internal method calls).
• Services → Prisma Client → MySQL (SQL queries over TCP).
• CI/CD workflows trigger Terraform plan/apply and deploy Next.js to hosting.
• Instrumentation calls from both client & server to Sentry.
• Playwright interacts with Browser → Server in test environment.
• Docker Compose connects Next.js container to MySQL container in dev.
c. Architectural patterns & design principles
• Monolithic web app split into Presentation (React), Application (Route Handlers & Services), Data (Prisma + MySQL).
• Serverless‐style functions (Next.js Route Handlers deployed as lambdas or Azure Functions).
• Infrastructure as Code (Terraform).
• Automated CI/CD.
• Test pyramid: unit (Jest), integration (Jest API tests), E2E (Playwright).
d. Key technologies
• Next.js 13 App Router (React server/client components).
• Tailwind CSS.
• Prisma ORM with generated client.
• MySQL (prod on Azure, dev via Docker).
• Terraform (Azure provider).
• GitHub Actions.
• Jest, Playwright.
• Sentry (error monitoring).