Atlassian | Phone Screen | System Design / Low Level Design | Tic Tac Toe

Anonymous User
2048
Jun 16, 2023
Jun 16, 2023

Design a simple web app for a tic-tac-toe game. Be sure to mention the API design, data stores, and how the user will interact with the game. Bonus: create a sequence diagram to outline the game flow.

Best I could do was an API that does these simple actions:

POST api/make-move
Request:
{
	player_id: 123,
	move: X,
	location: 4
}

GET /api/game-status
Returns game state to be rendered on the frontend

GET /api/get-next-player
Returns whose turn it is next

Database design:

Player table:

  • id
  • username text
  • date_created timestamp

enum cell_number:
0: cell 1
1: cell 2, etc

Game state table:

  • id
  • cell
  • player_symbol
  • timestamp
    Cell would maintain which one has been taken, player_symbol would be X or O

Moves table:

  • id
  • player_name FK
  • game_id FK
  • cell_number, timestamp

Flow diagram:

  1. Users create an account
  2. Get game status
  3. Player makes move
  4. Get next player
  5. Repeat 2-4 until winner is reached

User -> React app <-> Game API <-> Postgres DB

I was unable to clearly design the data flow of this so I struggled there. Can anyone share a better answer?

Comments (4)