# benjaminkomen/tibiawikiapi architecture

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

- Interactive diagram: https://gitdiagram.com/benjaminkomen/tibiawikiapi
- Repository: https://github.com/benjaminkomen/tibiawikiapi

## Overview

1. **What this service is**
   - TibiaWikiApi is a **Spring Boot API** that pulls structured data from the Tibia wiki and exposes it as **JSON REST endpoints**.
   - The repository is a **mixed Java/Kotlin** codebase, with the application entrypoint and some controllers/configuration in Kotlin and most of the domain/process code in Java.

2. **Top-level architecture**
   - The code is organized in a layered style:
     - **REST adapters/controllers** receive HTTP requests.
     - **Process/use-case classes** implement the retrieval and transformation logic.
     - **Domain objects/enums** represent Tibia concepts.
     - **Repository/factory utilities** fetch and parse wiki content into domain models.
   - This is a read-heavy integration service rather than a transactional CRUD app.

3. **HTTP/API layer**
   - Controllers live under `src/main/java/com/tibiawiki/controller` and `src/main/kotlin/com/tibiawiki/adapters/rest`.
   - Endpoints are resource-oriented, e.g.:
     - achievements, books, buildings, corpses, creatures, effects, hunting places, items, keys, locations, loot statistics, missiles, mounts, NPCs, objects, outfits, quests, spells, streets, charms, and wiki pages.
   - The README shows a common query pattern such as `?expand=true` to return full object lists.

4. **Application entrypoint and framework setup**
   - `TibiaWikiApiApplication.kt` is the application bootstrap.
   - Supporting configuration includes:
     - `CORSResponseFilter` for cross-origin access,
     - `JacksonConfiguration` for JSON serialization behavior,
     - `OpenAPIConfiguration` for Swagger/OpenAPI docs.
   - A static `index.html` is bundled, likely to host a simple landing page or API docs entry point.

5. **Use-case / orchestration layer**
   - The `src/main/java/com/tibiawiki/process` package contains the core orchestration classes:
     - `RetrieveAny`, `ModifyAny`, and resource-specific variants like `RetrieveCreatures`, `RetrieveBooks`, `RetrieveItems`, `RetrieveLoot`, etc.
   - These classes are the main boundary between HTTP/API concerns and wiki parsing logic.
   - The naming suggests each resource has a dedicated retrieval pipeline, with shared generic behavior in the “Any” classes.

6. **Domain model**
   - `src/main/java/com/tibiawiki/domain/objects` contains the normalized business objects returned by the API, such as `Creature`, `Book`, `HuntingPlace`, `Quest`, `Spell`, `NPC`, `Outfit`, `Mount`, and others.
   - Supporting types like `LootItem`, `Percentage`, and `HuntingPlaceSkills` model nested or derived data.
   - `domain/enums` contains a large set of wiki-specific normalized enums, for example `City`, `Vocation`, `WeaponType`, `Rarity`, `SpellType`, `BestiaryLevel`, and `YesNo`.
   - These types are the stable API contract, independent of the wiki’s raw markup.

7. **Wiki parsing and transformation**
   - `src/main/java/com/tibiawiki/domain/factories` is where raw wiki content is turned into domain objects.
   - Key factories include:
     - `ArticleFactory` for article-level conversion,
     - `WikiObjectFactory` for object/template extraction,
     - `JsonFactory` for JSON creation/round-tripping.
   - `TemplateUtils`, `ListUtil`, and `PropertiesUtil` support parsing wiki templates, list normalization, and configuration handling.
   - `WikiObjectMixin` suggests custom Jackson handling for wiki-derived object serialization/deserialization.

8. **External data source boundary**
   - `src/main/java/com/tibiawiki/domain/repositories/JwikiArticleRepository.java` implements `ArticleRepository`.
   - This is the likely integration point to the external Tibia wiki content source, abstracting how pages/articles are retrieved.
   - The repository layer isolates the rest of the app from the underlying wiki client/API, making the parsing logic easier to test and swap.

9. **Specialized Kotlin domain additions**
   - Kotlin is used for a small slice of the domain and adapter layer, including `RetrieveWikiPages`, `Charm`, and `TibiaObject`.
   - This suggests Kotlin is used where concise data modeling or adapter code is helpful, while Java remains the main implementation language for the parsing pipeline.

10. **Validation and object contracts**
   - The domain has explicit contracts in `domain/interfaces`:
     - `WikiTemplate`,
     - `Description`,
     - `Validatable`.
   - Validation support lives in `domain/objects/validation`, with `ValidationResult`, `ValidationSeverity`, and `ValidationException`.
   - That implies objects are validated as they are built from wiki data, rather than only being trusted after parsing.

11. **Testing strategy**
   - Unit tests cover factories, utilities, repository behavior, and process classes under `src/test/java`.
   - Integration tests under `src/integrationTest` exercise controller endpoints and JSON factory behavior.
   - This split shows two important boundaries:
     - correctness of parsing/transformation,
     - correctness of the HTTP API surface.

12. **Runtime and deployment**
   - The project uses **Gradle** with the standard wrapper, and includes:
     - `docker/Dockerfile` for containerization,
     - `cloudbuild.yaml` and `cloudbuild-pr.yaml` for CI/CD,
     - `.github/workflows/buid.yml` for GitHub Actions,
     - `scripts/deploy.sh` for deployment automation.
   - The README references public hosting and Swagger docs, so the service is designed to run as a standalone containerized API.

13. **Operational concerns**
   - `src/main/resources/application.properties` and `credentials.properties.example` indicate external configuration is required, likely for wiki access and environment-specific settings.
   - Logging is configured via `logback.xml`.
   - The presence of `src/test/resources/credentials.properties` suggests tests may need mocked or controlled credentials to exercise the wiki integration path.

14. **How data flows through the system**
   - Request comes in to a resource controller.
   - Controller delegates to a retrieval process.
   - Process uses repository/factory utilities to fetch and parse wiki articles.
   - Parsed data is converted into domain objects and validated.
   - Jackson serializes the result to JSON for the client.
   - Swagger/OpenAPI and CORS are provided as supporting HTTP-layer concerns.

15. **Diagram takeaway**
   - The key architectural boundary is between the **public REST API** and the **wiki ingestion/parsing pipeline**.
   - The most important boxes for an architecture diagram are:
     - controllers/adapters,
     - process/use-case layer,
     - domain model and enums,
     - wiki repository/factories,
     - external Tibia wiki source,
     - configuration/documentation/runtime packaging around them.

Main entry points: [`src/main/java/com/tibiawiki/domain/factories`](https://github.com/benjaminkomen/tibiawikiapi/tree/master/src/main/java/com/tibiawiki/domain/factories) (Factories), [`src/main/java/com/tibiawiki/domain/objects`](https://github.com/benjaminkomen/tibiawikiapi/tree/master/src/main/java/com/tibiawiki/domain/objects) (Domain Objects), [`src/main/kotlin/com/tibiawiki/TibiaWikiApiApplication.kt`](https://github.com/benjaminkomen/tibiawikiapi/blob/master/src/main/kotlin/com/tibiawiki/TibiaWikiApiApplication.kt) (App Boot), [`src/main/java/com/tibiawiki/controller`](https://github.com/benjaminkomen/tibiawikiapi/tree/master/src/main/java/com/tibiawiki/controller) (REST Controllers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API Layer"]
  node_app(("App Boot<br/>Spring Boot app"))
  node_config["Config"]
  node_controllers["REST Controllers<br/>REST adapters"]
  node_kcontrollers["Kotlin Adapters<br/>REST adapters"]
end

subgraph group_usecase["Use Cases"]
  node_processbase["Generic Flow<br/>use-case base"]
  node_retrieve["Resource Retrieval<br/>use-case handlers"]
  node_wikiobject["Wiki Page Flow<br/>use-case handler"]
end

subgraph group_domain["Domain Model"]
  node_objects["Domain Objects<br/>api models"]
  node_enums["Enums<br/>value types"]
  node_validation["Validation<br/>contracts"]
  node_interfaces["Contracts<br/>interfaces"]
  node_mixins["Jackson Mixins<br/>serialization"]
  node_kdomain["Kotlin Domain<br/>Kotlin models"]
end

subgraph group_integration["Wiki Integration"]
  node_factories["Factories<br/>parsing/transform"]
  node_repo[("Article Repo<br/>wiki repository")]
  node_utils["Parse Utils<br/>helpers"]
  node_articleapi(("Wiki Source<br/>external wiki"))
end

node_app -->|"loads"| node_config
node_app -->|"serves"| node_controllers
node_app -->|"serves"| node_kcontrollers
node_controllers -->|"delegates"| node_processbase
node_kcontrollers -->|"delegates"| node_wikiobject
node_processbase -->|"specializes"| node_retrieve
node_retrieve -->|"uses"| node_factories
node_wikiobject -->|"uses"| node_factories
node_factories -->|"fetches via"| node_repo
node_repo -->|"reads from"| node_articleapi
node_factories -->|"parses with"| node_utils
node_factories -->|"builds"| node_objects
node_factories -->|"serializes with"| node_mixins
node_objects -->|"uses"| node_enums
node_objects -->|"implements"| node_interfaces
node_objects -->|"validates"| node_validation
node_kcontrollers -->|"returns"| node_kdomain
node_retrieve -->|"returns"| node_objects
node_controllers -->|"returns"| node_objects

click node_app "https://github.com/benjaminkomen/tibiawikiapi/blob/master/src/main/kotlin/com/tibiawiki/TibiaWikiApiApplication.kt"
click node_config "https://github.com/benjaminkomen/tibiawikiapi/tree/master/src/main/kotlin/com/tibiawiki/config"
click node_controllers "https://github.com/benjaminkomen/tibiawikiapi/tree/master/src/main/java/com/tibiawiki/controller"
click node_kcontrollers "https://github.com/benjaminkomen/tibiawikiapi/tree/master/src/main/kotlin/com/tibiawiki/adapters/rest"
click node_processbase "https://github.com/benjaminkomen/tibiawikiapi/tree/master/src/main/java/com/tibiawiki/process"
click node_retrieve "https://github.com/benjaminkomen/tibiawikiapi/tree/master/src/main/java/com/tibiawiki/process"
click node_wikiobject "https://github.com/benjaminkomen/tibiawikiapi/blob/master/src/main/kotlin/com/tibiawiki/domain/RetrieveWikiPages.kt"
click node_factories "https://github.com/benjaminkomen/tibiawikiapi/tree/master/src/main/java/com/tibiawiki/domain/factories"
click node_repo "https://github.com/benjaminkomen/tibiawikiapi/blob/master/src/main/java/com/tibiawiki/domain/repositories/JwikiArticleRepository.java"
click node_utils "https://github.com/benjaminkomen/tibiawikiapi/tree/master/src/main/java/com/tibiawiki/domain/utils"
click node_objects "https://github.com/benjaminkomen/tibiawikiapi/tree/master/src/main/java/com/tibiawiki/domain/objects"
click node_enums "https://github.com/benjaminkomen/tibiawikiapi/tree/master/src/main/java/com/tibiawiki/domain/enums"
click node_validation "https://github.com/benjaminkomen/tibiawikiapi/tree/master/src/main/java/com/tibiawiki/domain/objects/validation"
click node_interfaces "https://github.com/benjaminkomen/tibiawikiapi/tree/master/src/main/java/com/tibiawiki/domain/interfaces"
click node_mixins "https://github.com/benjaminkomen/tibiawikiapi/tree/master/src/main/java/com/tibiawiki/domain/jackson"
click node_kdomain "https://github.com/benjaminkomen/tibiawikiapi/tree/master/src/main/kotlin/com/tibiawiki/domain/objects"

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_app,node_config,node_controllers,node_kcontrollers toneBlue
class node_processbase,node_retrieve,node_wikiobject toneAmber
class node_objects,node_enums,node_validation,node_interfaces,node_mixins,node_kdomain toneMint
class node_factories,node_repo,node_utils,node_articleapi toneRose
```

## Components

### API Layer

HTTP controllers and Spring Boot entrypoints

- [App Boot](https://github.com/benjaminkomen/tibiawikiapi/blob/master/src/main/kotlin/com/tibiawiki/TibiaWikiApiApplication.kt): Spring Boot app · Application entrypoint and runtime bootstrap · `src/main/kotlin/com/tibiawiki/TibiaWikiApiApplication.kt`
- [Config](https://github.com/benjaminkomen/tibiawikiapi/tree/master/src/main/kotlin/com/tibiawiki/config): HTTP/config · CORS, Jackson, and OpenAPI setup · `src/main/kotlin/com/tibiawiki/config`
- [REST Controllers](https://github.com/benjaminkomen/tibiawikiapi/tree/master/src/main/java/com/tibiawiki/controller): REST adapters · Resource endpoints for wiki-backed JSON APIs · `src/main/java/com/tibiawiki/controller`
- [Kotlin Adapters](https://github.com/benjaminkomen/tibiawikiapi/tree/master/src/main/kotlin/com/tibiawiki/adapters/rest): REST adapters · Kotlin controller/adaptor endpoints · `src/main/kotlin/com/tibiawiki/adapters/rest`

### Use Cases

Retrieval and orchestration pipelines

- [Generic Flow](https://github.com/benjaminkomen/tibiawikiapi/tree/master/src/main/java/com/tibiawiki/process): use-case base · Shared retrieval and modification orchestration · `src/main/java/com/tibiawiki/process`
- [Resource Retrieval](https://github.com/benjaminkomen/tibiawikiapi/tree/master/src/main/java/com/tibiawiki/process): use-case handlers · Resource-specific retrieval pipelines for API resources · `src/main/java/com/tibiawiki/process`
- [Wiki Page Flow](https://github.com/benjaminkomen/tibiawikiapi/blob/master/src/main/kotlin/com/tibiawiki/domain/RetrieveWikiPages.kt): use-case handler · Wiki page retrieval entrypoint · `src/main/kotlin/com/tibiawiki/domain/RetrieveWikiPages.kt`

### Domain Model

Normalized wiki objects, enums, and validation

- [Domain Objects](https://github.com/benjaminkomen/tibiawikiapi/tree/master/src/main/java/com/tibiawiki/domain/objects): api models · Normalized API return types such as creatures, books, quests, and spells · `src/main/java/com/tibiawiki/domain/objects`
- [Enums](https://github.com/benjaminkomen/tibiawikiapi/tree/master/src/main/java/com/tibiawiki/domain/enums): value types · Normalized Tibia-specific enum vocabulary · `src/main/java/com/tibiawiki/domain/enums`
- [Validation](https://github.com/benjaminkomen/tibiawikiapi/tree/master/src/main/java/com/tibiawiki/domain/objects/validation): contracts · Validation results, severity, and exceptions · `src/main/java/com/tibiawiki/domain/objects/validation`
- [Contracts](https://github.com/benjaminkomen/tibiawikiapi/tree/master/src/main/java/com/tibiawiki/domain/interfaces): interfaces · Wiki template, description, and validatable contracts · `src/main/java/com/tibiawiki/domain/interfaces`
- [Jackson Mixins](https://github.com/benjaminkomen/tibiawikiapi/tree/master/src/main/java/com/tibiawiki/domain/jackson): serialization · Custom serialization support for wiki objects · `src/main/java/com/tibiawiki/domain/jackson`
- [Kotlin Domain](https://github.com/benjaminkomen/tibiawikiapi/tree/master/src/main/kotlin/com/tibiawiki/domain/objects): Kotlin models · Small Kotlin domain additions such as Charm and TibiaObject · `src/main/kotlin/com/tibiawiki/domain/objects`

### Wiki Integration

Repositories and factories that translate wiki content

- [Factories](https://github.com/benjaminkomen/tibiawikiapi/tree/master/src/main/java/com/tibiawiki/domain/factories): parsing/transform · Article, JSON, and wiki object conversion · `src/main/java/com/tibiawiki/domain/factories`
- [Article Repo](https://github.com/benjaminkomen/tibiawikiapi/blob/master/src/main/java/com/tibiawiki/domain/repositories/JwikiArticleRepository.java): wiki repository · Abstraction over external wiki article retrieval · `src/main/java/com/tibiawiki/domain/repositories/JwikiArticleRepository.java`
- [Parse Utils](https://github.com/benjaminkomen/tibiawikiapi/tree/master/src/main/java/com/tibiawiki/domain/utils): helpers · Template, list, and properties parsing helpers · `src/main/java/com/tibiawiki/domain/utils`
- **Wiki Source**: external wiki · External Tibia wiki content source

## Connections

- App Boot → Config: loads · Bootstraps HTTP and serialization configuration
- App Boot → REST Controllers: serves · Starts the REST API layer
- App Boot → Kotlin Adapters: serves · Starts Kotlin REST adapters
- REST Controllers → Generic Flow: delegates · Controller requests enter the use-case layer
- Kotlin Adapters → Wiki Page Flow: delegates · Wiki page and charm endpoints delegate to retrieval logic
- Generic Flow → Resource Retrieval: specializes · Shared behavior is reused by resource-specific retrieval flows
- Resource Retrieval → Factories: uses · Retrieval pipelines transform wiki content through factories
- Wiki Page Flow → Factories: uses · Wiki page retrieval relies on parsing and JSON conversion
- Factories → Article Repo: fetches via · Factories depend on article retrieval abstraction
- Article Repo → Wiki Source: reads from · External wiki content source
- Factories → Parse Utils: parses with · Helper utilities normalize templates and lists
- Factories → Domain Objects: builds · Factories produce normalized domain objects
- Factories → Jackson Mixins: serializes with · Custom Jackson behavior for wiki-derived objects
- Domain Objects → Enums: uses · Domain models are parameterized by normalized enums
- Domain Objects → Contracts: implements · Domain contracts define template and validation behavior
- Domain Objects → Validation: validates · Parsed objects can emit validation results and exceptions
- Kotlin Adapters → Kotlin Domain: returns · Kotlin adapters expose Kotlin domain models
- Resource Retrieval → Domain Objects: returns · Use cases return domain objects to controllers
- REST Controllers → Domain Objects: returns · REST resources serialize domain objects as JSON
