How joseph-v-a/tic-tac-toe-game works
Project type + purpose (what you’re diagramming)
Given the tiny file tree:
• index.c = entire implementation (all modules/functions likely live here)
• README.md = usage/build notes
• .gitignore = not architecturally relevant
What to extract from the code (since everything is in index.c)
• State: how the board is represented (array of 9 chars? 3x3 grid?), current player, move count
• Core functions (names may vary, but roles are consistent):
• main() (entry point)
• drawBoard() / printBoard() (rendering)
• readMove() / playerInput() (input)
• isValidMove() (validation / cell occupancy check)
• applyMove() (write into board state)
• checkWin() / checkWinner() (winning conditions)
• checkDraw() (move count == 9)
• resetGame() / initBoard()
• playAgain() / replay prompt
• I/O dependencies:
• stdio.h for printf/scanf etc.
• conio.h for getch (not portable on all OSes). This is an important “external dependency” to show because it affects portability.
Main components
Program as a set of internal components plus a couple of external actors:
External actors
• Player 1 / Player 2 (human users)
• Console/Terminal (stdin/stdout)
Game Controller / Main Loop
• Orchestrates turns, calls render/input/check logic, manages replay.
Board State (Data Model)
• The board representation + current player + move counter.
Input Handler
• Reads user selection (1–9), optionally uses getch for immediate keypress.
Move Validator
• Ensures input is in range and cell is not already occupied.
Renderer (UI)
• Prints the board, prompts, error messages, and results.
Platform/Library dependencies
• C Runtime + Standard I/O (stdio)
• Console I/O extension (conio / getch) if used
Core turn sequence (control flow)
• Player -> Input Handler -> Move Validator -> Game Controller
• If valid:
• Game Controller -> Board State (apply move)
• Game Controller -> Renderer (print updated board + status)
• If invalid:
• Game Controller -> Renderer (error message)
• Loop back to Input Handler
Game lifecycle (state transitions)
• Start:
• main() initializes Board State and currentPlayer
• Each move increments move count
• Terminal conditions:
• Win: announce winner -> replay prompt -> reset or exit
Data dependencies
• Renderer reads Board State (to print)
• Rules Engine reads Board State (to evaluate)
• Validator reads Board State (to check occupancy)
• Controller writes Board State (to apply move/reset)