How mwickett/blitzer works
Project Type and Purpose
• This is a full-stack web application designed to capture and analyze scores for the card game Dutch Blitz. The project uses Next.js for its front-end and API routes, Prisma with Neon for database operations, and incorporates external services like Clerk for authentication, PostHog for analytics, and Sentry for error tracking. The README makes it clear that the primary goal is to create an engaging, personal dataset and analytics experience for Dutch Blitz enthusiasts.
Analyzing the File Structure
• Notice the Next.js layout in the “src/app” directory. It contains pages (for home, dashboard, sign-in, etc.), API routes (for rounds, webhooks, games, friends), and shared UI components (in “src/components” and “src/components/ui”).
• The “src/server” directory holds business logic, queries, mutations, and database integrations—including migrations and the Prisma schema. This shows a clear separation where API endpoints in the app directory delegate more complex or secure operations to backend modules.
• Additional configuration files are present (e.g., next.config.mjs, jest.config.js, tailwind.config.ts) alongside Docker and GitHub workflow files, indicating CI/CD and styling considerations.
Main Components to be Included
a. Frontend (User Interface):
• Next.js pages in “src/app”: Home, Dashboard, Games, Friends, and Sign-in pages.
• Shared UI components (buttons, cards, dialogs, etc.) in “src/components/ui”.
• Client-side integrations such as PostHog analytics (see PostHogProvider.tsx) and Sentry configurations.
b. API Layer:
• API endpoints within “src/app/api” for handling dynamic actions (e.g., game rounds and webhooks).
• These endpoints act as bridges between the UI and server-side logic.
c. Backend/Server:
• “src/server”: Handles heavier business logic, including database queries, mutations, and utility functions.
• Server-side tests ensuring business rules and validation logic (in “src/lib/__tests__” and “src/server/__tests__”).
d. Database:
• Prisma ORM, indicated by the “schema.prisma”, database migrations in “src/server/db/migrations”, and the database initialization file.
• Neon as the hosting provider for the database.
e. Authentication & Analytics:
• Clerk is used for user authentication, and the integration is configured with Clerk’s API endpoints.
• PostHog for event tracking and analytics.
f. External Tools & Configuration:
• Docker Compose for container orchestration.
• GitHub workflows for continuous integration and deployment.
Relationships and Interactions
• The API endpoints, encapsulated in Next.js routes, interface with the backend logic in “src/server” and access the database via Prisma.
• User authentication (Clerk) and analytics (PostHog) are integrated across the application layers, ensuring authentication state and user interactions are tracked.
• Sentry configurations (available as separate config files for client, server, and edge) are integrated to monitor errors throughout the system.
• External services like Vercel (deployment environment) and Neon (hosted database) should be represented as external endpoints linked to their respective components.
Architectural Patterns and Design Principles
• Component-based architecture typical of Next.js, separating presentation, API, and server layers.
• Emphasis on modularity: clear separation of concerns between frontend pages, UI components, and deeper server logic.
• Layering: Graphically distinguish between client-side (Next.js app and UI), server-side (business logic, queries, mutations), and persistence (database with Prisma).
• Use of migration files and strict test folders indicates a strong focus on version control and reliability.