Architecture (App) - MsCornell/2425Repo GitHub Wiki
This outlines the components in a simple Tic Tac Toe game. It uses Mermaid for class diagrams, which can be edited here.
flowchart LR
subgraph End User
Browser
end
subgraph SQL Server
Database[(Database)]
end
subgraph Static Web App
API[[Data API]]
MLService((ML API))
Client[Game]
end
Browser <-->|HTTP| Client
Client <-->|HTTP<br/>JSON| API
Client -->|Game<br/>State| MLService
MLService -->|Next<br/>Move| Client
API -->|TSQL| Database
This diagram explains the basic layout of the code from a Class View point of view.
classDiagram
direction TB
class GameInfo {
-Dictionary~BoardIndex, BoardInfo~ boards
-HttpClient httpClient
-GameResult winner
-Players NextPlayer
-BoardIndex[] NextBoards
+event EventHandler~GameResult~ WinnerChanged
+GameResult Winner
+void Play(BoardIndex boardIndex, CellIndex cellIndex)
+bool CanPlay(BoardIndex boardIndex, CellIndex cellIndex)
+BoardInfo GetBoard(BoardIndex boardIndex)
+BoardIndex[] Boards(GameResult? gameResult = null)
+async Task SendBoardStateToFunctionAsync(Dictionary~string, string~ boardState)
}
class BoardInfo {
-Dictionary~CellIndex, CellInfo~ cells
-HttpClient http
-GameResult winner
+event EventHandler~GameResult~ WinnerChanged
+GameResult Winner
+void Play(CellIndex cellIndex, Players player)
+bool CanPlay(CellIndex cellIndex)
+CellInfo GetCell(CellIndex cellIndex)
}
class CellInfo {
+CellValue Value
+string ImageName
+event EventHandler ValueChanged
}
class GameResult {
<<enumeration>>
X
O
Cat
InProgress
Unknown
XWins
OWins
}
class CellValue {
<<enumeration>>
Blank
X
O
}
class Players {
<<enumeration>>
X
O
Cat
}
class CellIndex {
<<enumeration>>
Cell1
Cell2
Cell3
Cell4
Cell5
Cell6
Cell7
Cell8
Cell9
}
class BoardIndex {
<<enumeration>>
Board1
Board2
Board3
Board4
Board5
Board6
Board7
Board8
Board9
}
GameInfo --> BoardInfo
BoardInfo --> CellInfo
CellInfo --> CellValue
GameInfo --> GameResult
BoardInfo --> GameResult
flowchart TD
A["Start Game"] --> B["NextPlayer's Turn"]
B --> C["Play(boardIndex, cellIndex)"]
C --> D{"CanPlay(boardIndex, cellIndex)?"}
D -->|No| E["Throw Exception: Invalid Move"] --> B
D -->|Yes| F["Update Cell State in BoardInfo.Play()"]
F --> G["Check Current Board Winner via BoardInfo.CalculateWinner()"]
G --> H{"Board Winner Determined?"}
H -->|Yes| I["Update Overall Winner via GameInfo.CalculateOverallWinner()"]
H -->|No| J["Continue Current Board"]
I --> K{"Overall Winner Determined?"}
K -->|Yes| L["Declare Winner and Navigate to End Page"]
K -->|No| M["Set NextBoards via Boards(GameResult.InProgress)"]
M --> N["Switch Player via NextPlayer"]
N --> O{"Are All Boards Completed?"}
O -->|Yes| L
O -->|No| B
This shows the basic authentication flow when a user attempts to log in.
sequenceDiagram
participant User
participant LoginPage
participant PlayerRepository
participant DataAPI
participant Database
participant PlayerStateService
User->>+LoginPage: Attempt Login
critical Login Process
LoginPage->>LoginPage: Validate Input Fields
alt Input is Valid
LoginPage->>+PlayerRepository: GetAsync(Email, Password)
PlayerRepository->>+DataAPI: Call Data API (Email, Password)
DataAPI->>+Database: Query User Record
Database-->>-DataAPI: Return User Data / Null
DataAPI-->>-PlayerRepository: Return User Data / Null
alt Player Found
PlayerRepository-->>LoginPage: Return Player
LoginPage->>+PlayerStateService: Set CurrentPlayer
PlayerStateService-->>LoginPage: Player State Updated
LoginPage-->>User: Grant Access (Navigate to Home)
else Player Not Found
PlayerRepository-->>LoginPage: Return Null
LoginPage-->>User: Show Invalid Credentials
end
else Input is Invalid
LoginPage-->>User: Show Alert: Invalid Input
end
end
User->>LoginPage: Navigate to Reset, Terms, or LoginBox