How jdds97/tic-tac-toe works
Project type and purpose
• This is a full-stack web application:
– Frontend and backend are built together using Next.js App Router with Server Actions
– Persistent game data and stats stored in MongoDB
– Containerized with Docker/Docker Compose
1. Developer workstation / CI (optional)
– Git repo, ESLint, Jest tests
2. Docker Compose layer
– Node.js “app” service running the Next.js application
– MongoDB service for data persistence
3. Next.js application
A. Frontend Client (React + TypeScript)
– Renders pages under src/app (layout, page.tsx)
– Renders UI components in src/components (GameBoard, GameStats)
– Uses global CSS from src/app/globals.css
B. Backend Server Actions (Next.js API layer)
– Defined in src/lib/actions.ts
– Exposes functions to read/write games and stats
– Validates inputs using TypeScript types in src/lib/types.ts
C. Custom Hooks (client-side calls to server actions)
– useGameState (src/hooks/useGameState.ts)
– useGameStats (src/hooks/useGameStats.ts)
D. Business Logic & Utilities (shared client/server)
– Game logic in src/lib/gameLogic.ts
– Constants and helpers in src/lib/constants.ts, utils.ts
4. Database
– MongoDB collections for Game and Stats models (src/db/models)
– Connection logic in src/db/mongoDb.ts
Architectural patterns & design principles
• Monolithic containerized service with clear separation of concerns
• Next.js App Router enforcing server/client boundaries
• Server Actions as thin API endpoints behind the scenes
• Shared code (gameLogic, types) to avoid duplication
• Custom React hooks abstracting data fetching/state
Relevant technologies
• Next.js (React, App Router, Server Actions)
• TypeScript for type safety
• MongoDB with Mongoose-style models
• Docker & Docker Compose for environment reproducibility
• Jest for unit testing, ESLint for linting