# orozzzz/testpart4 architecture

> Architecture diagram of the GitHub repository orozzzz/testpart4, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/orozzzz/testpart4
- Repository: https://github.com/orozzzz/testpart4

## Overview

This is a Go tic-tac-toe game service with HTTP endpoints for creating games, making moves, and retrieving game state. A request passes from the HTTP handler to the game service, which applies domain rules and persists state through a repository; computer games also ask the minimax strategy for a reply. The repository uses in-memory storage. The README is empty, so capabilities and links here are limited to the supplied source excerpts; unsampled routing or behavior is not inferred.

Main entry points: [`src/internal/di/container.go`](https://github.com/orozzzz/testpart4/blob/main/src/internal/di/container.go) (Dependency Container), [`src/internal/domain/service/service.go`](https://github.com/orozzzz/testpart4/blob/main/src/internal/domain/service/service.go) (Game Service), [`src/internal/web/handlers/game_handler.go`](https://github.com/orozzzz/testpart4/blob/main/src/internal/web/handlers/game_handler.go) (Game Handler), [`src/internal/datasource/repository/game_repo.go`](https://github.com/orozzzz/testpart4/blob/main/src/internal/datasource/repository/game_repo.go) (Game Repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_handler["Game Handler<br/>[game_handler.go]"]
  node_webmapper["Response Mapper<br/>[game_mapper.go]"]
  node_webmodel["Web Models<br/>[game.go]"]
end

subgraph group_domain["Game Domain"]
  node_service["Game Service<br/>[service.go]"]
  node_servicectract["Service Contract<br/>[interface.go]"]
  node_gamerules["Game Rules<br/>[game.go]"]
  node_board["Board<br/>[board.go]"]
  node_strategy["Minimax Strategy<br/>[minimax.go]"]
end

subgraph group_storage["Persistence"]
  node_repositoryport["Repository Port<br/>[game_repository.go]"]
  node_repository["Game Repository<br/>[game_repo.go]"]
  node_datamapper["Data Mapper<br/>[game_mapper.go]"]
  node_datamodel["Stored Game DTO<br/>[game.go]"]
  node_memstore[("In-memory Store<br/>[game_repo.go]")]
end

subgraph group_runtime["Runtime Wiring"]
  node_entry["Main Entry<br/>[main.go]"]
  node_container["Dependency Container<br/>[container.go]"]
end

node_caller(("API Caller"))

node_caller -->|"sends requests"| node_handler
node_handler -->|"dispatches game actions"| node_service
node_handler -->|"maps responses"| node_webmapper
node_webmapper -->|"builds responses"| node_webmodel
node_service -->|"applies game rules"| node_gamerules
node_service -->|"loads and saves"| node_repositoryport
node_service -->|"requests computer move"| node_strategy
node_strategy -->|"evaluates board"| node_board
node_gamerules -->|"updates board"| node_board
node_repository -->|"converts game data"| node_datamapper
node_datamapper -->|"maps stored fields"| node_datamodel
node_repository -->|"reads and writes"| node_memstore
node_entry -->|"builds application"| node_container
node_container -->|"registers routes"| node_handler
node_container -->|"provides service"| node_service
node_container -->|"provides repository"| node_repository
node_container -->|"provides strategy"| node_strategy

click node_handler "https://github.com/orozzzz/testpart4/blob/main/src/internal/web/handlers/game_handler.go"
click node_webmapper "https://github.com/orozzzz/testpart4/blob/main/src/internal/web/mappers/game_mapper.go"
click node_webmodel "https://github.com/orozzzz/testpart4/blob/main/src/internal/web/models/game.go"
click node_service "https://github.com/orozzzz/testpart4/blob/main/src/internal/domain/service/service.go"
click node_servicectract "https://github.com/orozzzz/testpart4/blob/main/src/internal/domain/service/interface.go"
click node_gamerules "https://github.com/orozzzz/testpart4/blob/main/src/internal/domain/models/game.go"
click node_board "https://github.com/orozzzz/testpart4/blob/main/src/internal/domain/models/board.go"
click node_strategy "https://github.com/orozzzz/testpart4/blob/main/src/internal/domain/strategy/minimax.go"
click node_repositoryport "https://github.com/orozzzz/testpart4/blob/main/src/internal/domain/ports/game_repository.go"
click node_repository "https://github.com/orozzzz/testpart4/blob/main/src/internal/datasource/repository/game_repo.go"
click node_datamapper "https://github.com/orozzzz/testpart4/blob/main/src/internal/datasource/mappers/game_mapper.go"
click node_datamodel "https://github.com/orozzzz/testpart4/blob/main/src/internal/datasource/models/game.go"
click node_memstore "https://github.com/orozzzz/testpart4/blob/main/src/internal/datasource/repository/game_repo.go"
click node_entry "https://github.com/orozzzz/testpart4/blob/main/src/cmd/main.go"
click node_container "https://github.com/orozzzz/testpart4/blob/main/src/internal/di/container.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_handler,node_webmapper,node_webmodel toneBlue
class node_service,node_servicectract,node_gamerules,node_board,node_strategy toneAmber
class node_repositoryport,node_repository,node_datamapper,node_datamodel,node_memstore,node_caller toneMint
class node_entry,node_container toneRose
```

## Components

### HTTP API

- [Game Handler](https://github.com/orozzzz/testpart4/blob/main/src/internal/web/handlers/game_handler.go): `src/internal/web/handlers/game_handler.go`
- [Response Mapper](https://github.com/orozzzz/testpart4/blob/main/src/internal/web/mappers/game_mapper.go): `src/internal/web/mappers/game_mapper.go`
- [Web Models](https://github.com/orozzzz/testpart4/blob/main/src/internal/web/models/game.go): `src/internal/web/models/game.go`

### Game Domain

- [Game Service](https://github.com/orozzzz/testpart4/blob/main/src/internal/domain/service/service.go): `src/internal/domain/service/service.go`
- [Service Contract](https://github.com/orozzzz/testpart4/blob/main/src/internal/domain/service/interface.go): `src/internal/domain/service/interface.go`
- [Game Rules](https://github.com/orozzzz/testpart4/blob/main/src/internal/domain/models/game.go): `src/internal/domain/models/game.go`
- [Board](https://github.com/orozzzz/testpart4/blob/main/src/internal/domain/models/board.go): `src/internal/domain/models/board.go`
- [Minimax Strategy](https://github.com/orozzzz/testpart4/blob/main/src/internal/domain/strategy/minimax.go): `src/internal/domain/strategy/minimax.go`

### Persistence

- [Repository Port](https://github.com/orozzzz/testpart4/blob/main/src/internal/domain/ports/game_repository.go): `src/internal/domain/ports/game_repository.go`
- [Game Repository](https://github.com/orozzzz/testpart4/blob/main/src/internal/datasource/repository/game_repo.go): `src/internal/datasource/repository/game_repo.go`
- [Data Mapper](https://github.com/orozzzz/testpart4/blob/main/src/internal/datasource/mappers/game_mapper.go): `src/internal/datasource/mappers/game_mapper.go`
- [Stored Game DTO](https://github.com/orozzzz/testpart4/blob/main/src/internal/datasource/models/game.go): `src/internal/datasource/models/game.go`
- [In-memory Store](https://github.com/orozzzz/testpart4/blob/main/src/internal/datasource/repository/game_repo.go): `src/internal/datasource/repository/game_repo.go`

### Runtime Wiring

- [Main Entry](https://github.com/orozzzz/testpart4/blob/main/src/cmd/main.go): `src/cmd/main.go`
- [Dependency Container](https://github.com/orozzzz/testpart4/blob/main/src/internal/di/container.go): `src/internal/di/container.go`

### Other components

- **API Caller**

## Connections

- API Caller → Game Handler: sends requests
- Game Handler → Game Service: dispatches game actions (evidence: `src/internal/web/handlers/game_handler.go`)
- Game Handler → Response Mapper: maps responses (evidence: `src/internal/web/handlers/game_handler.go`)
- Response Mapper → Web Models: builds responses (evidence: `src/internal/web/mappers/game_mapper.go`)
- Game Service → Game Rules: applies game rules (evidence: `src/internal/domain/service/service.go`)
- Game Service → Repository Port: loads and saves (evidence: `src/internal/domain/service/service.go`)
- Game Service → Minimax Strategy: requests computer move (evidence: `src/internal/domain/service/service.go`)
- Minimax Strategy → Board: evaluates board (evidence: `src/internal/domain/strategy/minimax.go`)
- Game Rules → Board: updates board (evidence: `src/internal/domain/models/game.go`)
- Game Repository → Data Mapper: converts game data (evidence: `src/internal/datasource/repository/game_repo.go`)
- Data Mapper → Stored Game DTO: maps stored fields (evidence: `src/internal/datasource/mappers/game_mapper.go`)
- Game Repository → In-memory Store: reads and writes (evidence: `src/internal/datasource/repository/game_repo.go`)
- Main Entry → Dependency Container: builds application (evidence: `src/cmd/main.go`)
- Dependency Container → Game Handler: registers routes (evidence: `src/internal/di/container.go`)
- Dependency Container → Game Service: provides service (evidence: `src/internal/di/container.go`)
- Dependency Container → Game Repository: provides repository (evidence: `src/internal/di/container.go`)
- Dependency Container → Minimax Strategy: provides strategy (evidence: `src/internal/di/container.go`)
