# naumsantos/voleiapp architecture

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

- Interactive diagram: https://gitdiagram.com/naumsantos/voleiapp
- Repository: https://github.com/naumsantos/voleiapp

## Overview

VoleiApp is an ASP.NET Core backend for managing recreational volleyball: users manage athletes and teams, draw balanced teams, create and track matches, record results and substitutions, and request AI match insights. The main flow is HTTP controllers into application services, which use domain repository contracts and infrastructure persistence; match results also invoke substitution logic. AI insights use configurable providers with a documented local fallback. The graph preserves these product areas and the core match, domain, and persistence layers. Some controller/service wiring and provider selection are represented only by the source index or README.

Main entry points: [`src/VoleiApp.Application/Services/PartidaService.cs`](https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Application/Services/PartidaService.cs) (Match lifecycle), [`src/VoleiApp.Infrastructure/AI/ResilienteAiInsightsService.cs`](https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Infrastructure/AI/ResilienteAiInsightsService.cs) (AI provider routing), [`src/VoleiApp.Application/Services/SorteioService.cs`](https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Application/Services/SorteioService.cs) (Team draw), [`src/VoleiApp.Infrastructure/Repositories/AtletaRepository.cs`](https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Infrastructure/Repositories/AtletaRepository.cs) (Athlete repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_athletes_api["Athlete endpoints"]
  node_teams_api["Team endpoints<br/>[TimeController.cs]"]
  node_draw_api["Draw endpoint"]
  node_matches_api["Match endpoints"]
  node_subs_api["Substitution endpoints"]
  node_insights_api["Insight endpoint"]
end

subgraph group_application["Application workflows"]
  node_athlete_service["Athlete management<br/>[AtletaService.cs]"]
  node_team_service["Team management<br/>[TimeService.cs]"]
  node_draw_service["Team draw<br/>[SorteioService.cs]"]
  node_match_service["Match lifecycle<br/>[PartidaService.cs]"]
  node_match_dtos["Match DTOs<br/>[Partida]"]
  node_insight_dtos["Insight DTOs<br/>[Insights]"]
end

subgraph group_domain["Domain model"]
  node_athlete_entity["Athlete<br/>[Atleta.cs]"]
  node_team_entity["Team roster<br/>[Time.cs]"]
  node_match_entity["Match and reserves<br/>[Partida.cs]"]
  node_sub_entity["Substitutions<br/>[Substituicao.cs]"]
end

subgraph group_infrastructure["Persistence"]
  node_athlete_repo["Athlete repository"]
  node_team_repo["Team repository<br/>[TimeRepository.cs]"]
  node_match_repo["Match repository"]
  node_db[("SQLite data context<br/>[VoleiContext.cs]")]
end

subgraph group_ai["AI insights"]
  node_ai_service["AI provider routing"]
  node_ollama["Ollama provider"]
  node_openai["OpenAI-compatible provider"]
  node_fallback["Local fallback"]
end

node_user(("API user"))
node_ai_provider{{"Configured AI service"}}

node_user -->|"manages athletes"| node_athletes_api
node_user -->|"manages teams"| node_teams_api
node_user -->|"requests draw"| node_draw_api
node_user -->|"tracks matches"| node_matches_api
node_user -->|"queries substitutions"| node_subs_api
node_user -->|"requests insights"| node_insights_api
node_athletes_api -->|"delegates"| node_athlete_service
node_teams_api -->|"delegates"| node_team_service
node_draw_api -.->|"delegates"| node_draw_service
node_matches_api -->|"delegates"| node_match_service
node_subs_api -->|"delegates"| node_match_service
node_insights_api -->|"loads match"| node_match_service
node_insights_api -->|"requests insight"| node_ai_service
node_athlete_service -->|"uses repository"| node_athlete_repo
node_team_service -->|"uses repository"| node_team_repo
node_draw_service -->|"loads athletes"| node_athlete_repo
node_draw_service -->|"persists drawn teams"| node_team_repo
node_match_service -->|"reads and writes"| node_match_repo
node_match_service -->|"loads athletes"| node_athlete_repo
node_match_service -->|"requests substitutions"| node_draw_service
node_match_service -->|"maps responses"| node_match_dtos
node_athlete_repo -->|"queries and saves"| node_db
node_team_repo -->|"queries and saves"| node_db
node_match_repo -->|"queries and saves"| node_db
node_ai_service -.->|"routes requests"| node_ollama
node_ai_service -.->|"routes requests"| node_openai
node_ai_service -.->|"falls back"| node_fallback
node_ollama -->|"sends prompt"| node_ai_provider
node_openai -.->|"sends prompt"| node_ai_provider

click node_athletes_api "https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.API/Controllers/AtletasController.cs"
click node_teams_api "https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.API/Controllers/TimeController.cs"
click node_draw_api "https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.API/Controllers/SorteioController.cs"
click node_matches_api "https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.API/Controllers/PartidasController.cs"
click node_subs_api "https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.API/Controllers/SubstituicoesController.cs"
click node_insights_api "https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.API/Controllers/InsightsController.cs"
click node_athlete_service "https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Application/Services/AtletaService.cs"
click node_team_service "https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Application/Services/TimeService.cs"
click node_draw_service "https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Application/Services/SorteioService.cs"
click node_match_service "https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Application/Services/PartidaService.cs"
click node_match_dtos "https://github.com/naumsantos/voleiapp/tree/main/src/VoleiApp.Application/DTOs/Partida"
click node_insight_dtos "https://github.com/naumsantos/voleiapp/tree/main/src/VoleiApp.Application/DTOs/Insights"
click node_athlete_entity "https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Domain/Entities/Atleta.cs"
click node_team_entity "https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Domain/Entities/Time.cs"
click node_match_entity "https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Domain/Entities/Partida.cs"
click node_sub_entity "https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Domain/Entities/Substituicao.cs"
click node_athlete_repo "https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Infrastructure/Repositories/AtletaRepository.cs"
click node_team_repo "https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Infrastructure/Repositories/TimeRepository.cs"
click node_match_repo "https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Infrastructure/Repositories/PartidaRepository.cs"
click node_db "https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Infrastructure/Persistence/VoleiContext.cs"
click node_ai_service "https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Infrastructure/AI/ResilienteAiInsightsService.cs"
click node_ollama "https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Infrastructure/AI/OllamaAiInsightsService.cs"
click node_openai "https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Infrastructure/AI/OpenAiInsightsService.cs"
click node_fallback "https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Infrastructure/AI/FallbackInsightsService.cs"

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_athletes_api,node_teams_api,node_draw_api,node_matches_api,node_subs_api,node_insights_api,node_user toneBlue
class node_athlete_service,node_team_service,node_draw_service,node_match_service,node_match_dtos,node_insight_dtos toneAmber
class node_athlete_entity,node_team_entity,node_match_entity,node_sub_entity toneMint
class node_athlete_repo,node_team_repo,node_match_repo,node_db toneRose
class node_ai_service,node_ollama,node_openai,node_fallback,node_ai_provider toneIndigo
```

## Components

### HTTP API

- [Athlete endpoints](https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.API/Controllers/AtletasController.cs): `src/VoleiApp.API/Controllers/AtletasController.cs`
- [Team endpoints](https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.API/Controllers/TimeController.cs): `src/VoleiApp.API/Controllers/TimeController.cs`
- [Draw endpoint](https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.API/Controllers/SorteioController.cs): `src/VoleiApp.API/Controllers/SorteioController.cs`
- [Match endpoints](https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.API/Controllers/PartidasController.cs): `src/VoleiApp.API/Controllers/PartidasController.cs`
- [Substitution endpoints](https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.API/Controllers/SubstituicoesController.cs): `src/VoleiApp.API/Controllers/SubstituicoesController.cs`
- [Insight endpoint](https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.API/Controllers/InsightsController.cs): `src/VoleiApp.API/Controllers/InsightsController.cs`

### Application workflows

- [Athlete management](https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Application/Services/AtletaService.cs): `src/VoleiApp.Application/Services/AtletaService.cs`
- [Team management](https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Application/Services/TimeService.cs): `src/VoleiApp.Application/Services/TimeService.cs`
- [Team draw](https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Application/Services/SorteioService.cs): `src/VoleiApp.Application/Services/SorteioService.cs`
- [Match lifecycle](https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Application/Services/PartidaService.cs): `src/VoleiApp.Application/Services/PartidaService.cs`
- [Match DTOs](https://github.com/naumsantos/voleiapp/tree/main/src/VoleiApp.Application/DTOs/Partida): `src/VoleiApp.Application/DTOs/Partida`
- [Insight DTOs](https://github.com/naumsantos/voleiapp/tree/main/src/VoleiApp.Application/DTOs/Insights): `src/VoleiApp.Application/DTOs/Insights`

### Domain model

- [Athlete](https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Domain/Entities/Atleta.cs): `src/VoleiApp.Domain/Entities/Atleta.cs`
- [Team roster](https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Domain/Entities/Time.cs): `src/VoleiApp.Domain/Entities/Time.cs`
- [Match and reserves](https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Domain/Entities/Partida.cs): `src/VoleiApp.Domain/Entities/Partida.cs`
- [Substitutions](https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Domain/Entities/Substituicao.cs): `src/VoleiApp.Domain/Entities/Substituicao.cs`

### Persistence

- [Athlete repository](https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Infrastructure/Repositories/AtletaRepository.cs): `src/VoleiApp.Infrastructure/Repositories/AtletaRepository.cs`
- [Team repository](https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Infrastructure/Repositories/TimeRepository.cs): `src/VoleiApp.Infrastructure/Repositories/TimeRepository.cs`
- [Match repository](https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Infrastructure/Repositories/PartidaRepository.cs): `src/VoleiApp.Infrastructure/Repositories/PartidaRepository.cs`
- [SQLite data context](https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Infrastructure/Persistence/VoleiContext.cs): `src/VoleiApp.Infrastructure/Persistence/VoleiContext.cs`

### AI insights

- [AI provider routing](https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Infrastructure/AI/ResilienteAiInsightsService.cs): `src/VoleiApp.Infrastructure/AI/ResilienteAiInsightsService.cs`
- [Ollama provider](https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Infrastructure/AI/OllamaAiInsightsService.cs): `src/VoleiApp.Infrastructure/AI/OllamaAiInsightsService.cs`
- [OpenAI-compatible provider](https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Infrastructure/AI/OpenAiInsightsService.cs): `src/VoleiApp.Infrastructure/AI/OpenAiInsightsService.cs`
- [Local fallback](https://github.com/naumsantos/voleiapp/blob/main/src/VoleiApp.Infrastructure/AI/FallbackInsightsService.cs): `src/VoleiApp.Infrastructure/AI/FallbackInsightsService.cs`

### Other components

- **API user**
- **Configured AI service**

## Connections

- API user → Athlete endpoints: manages athletes (evidence: `README.md`)
- API user → Team endpoints: manages teams (evidence: `README.md`)
- API user → Draw endpoint: requests draw (evidence: `README.md`)
- API user → Match endpoints: tracks matches (evidence: `README.md`)
- API user → Substitution endpoints: queries substitutions (evidence: `README.md`)
- API user → Insight endpoint: requests insights (evidence: `README.md`)
- Athlete endpoints → Athlete management: delegates (evidence: `src/VoleiApp.API/Controllers/AtletasController.cs`)
- Team endpoints → Team management: delegates (evidence: `src/VoleiApp.API/Controllers/TimeController.cs`)
- Draw endpoint → Team draw: delegates
- Match endpoints → Match lifecycle: delegates (evidence: `src/VoleiApp.API/Controllers/PartidasController.cs`)
- Substitution endpoints → Match lifecycle: delegates (evidence: `src/VoleiApp.API/Controllers/SubstituicoesController.cs`)
- Insight endpoint → Match lifecycle: loads match (evidence: `src/VoleiApp.API/Controllers/InsightsController.cs`)
- Insight endpoint → AI provider routing: requests insight (evidence: `src/VoleiApp.API/Controllers/InsightsController.cs`)
- Athlete management → Athlete repository: uses repository (evidence: `src/VoleiApp.Application/Services/AtletaService.cs`)
- Team management → Team repository: uses repository (evidence: `src/VoleiApp.Application/Services/TimeService.cs`)
- Team draw → Athlete repository: loads athletes (evidence: `src/VoleiApp.Application/Services/SorteioService.cs`)
- Team draw → Team repository: persists drawn teams (evidence: `src/VoleiApp.Application/Services/SorteioService.cs`)
- Match lifecycle → Match repository: reads and writes (evidence: `src/VoleiApp.Application/Services/PartidaService.cs`)
- Match lifecycle → Athlete repository: loads athletes (evidence: `src/VoleiApp.Application/Services/PartidaService.cs`)
- Match lifecycle → Team draw: requests substitutions (evidence: `src/VoleiApp.Application/Services/PartidaService.cs`)
- Match lifecycle → Match DTOs: maps responses (evidence: `src/VoleiApp.Application/Services/PartidaService.cs`)
- Athlete repository → SQLite data context: queries and saves (evidence: `src/VoleiApp.Infrastructure/Repositories/AtletaRepository.cs`)
- Team repository → SQLite data context: queries and saves (evidence: `src/VoleiApp.Infrastructure/Repositories/TimeRepository.cs`)
- Match repository → SQLite data context: queries and saves (evidence: `src/VoleiApp.Infrastructure/Repositories/PartidaRepository.cs`)
- AI provider routing → Ollama provider: routes requests (evidence: `src/VoleiApp.Infrastructure/AI/ResilienteAiInsightsService.cs`)
- AI provider routing → OpenAI-compatible provider: routes requests
- AI provider routing → Local fallback: falls back (evidence: `src/VoleiApp.Infrastructure/AI/ResilienteAiInsightsService.cs`)
- Ollama provider → Configured AI service: sends prompt (evidence: `src/VoleiApp.Infrastructure/AI/OllamaAiInsightsService.cs`)
- OpenAI-compatible provider → Configured AI service: sends prompt
