How benjaminkomen/tibiawikiapi works
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: factories Factories · objects Domain Objects · TibiaWikiApiApplication.kt App Boot · controller REST Controllers
Components 17
API Layer
HTTP controllers and Spring Boot entrypoints
- App Boot · Application entrypoint and runtime bootstrap
src/main/kotlin/com/tibiawiki/TibiaWikiApiApplication.kt - Config · CORS, Jackson, and OpenAPI setup
src/main/kotlin/com/tibiawiki/config - REST Controllers · Resource endpoints for wiki-backed JSON APIs
src/main/java/com/tibiawiki/controller - Kotlin Adapters · Kotlin controller/adaptor endpoints
src/main/kotlin/com/tibiawiki/adapters/rest
Use Cases
Retrieval and orchestration pipelines
- Generic Flow · Shared retrieval and modification orchestration
src/main/java/com/tibiawiki/process - Resource Retrieval · Resource-specific retrieval pipelines for API resources
src/main/java/com/tibiawiki/process - Wiki Page Flow · Wiki page retrieval entrypoint
src/main/kotlin/com/tibiawiki/domain/RetrieveWikiPages.kt
Domain Model
Normalized wiki objects, enums, and validation
- Domain Objects · Normalized API return types such as creatures, books, quests, and spells
src/main/java/com/tibiawiki/domain/objects - Enums · Normalized Tibia-specific enum vocabulary
src/main/java/com/tibiawiki/domain/enums - Validation · Validation results, severity, and exceptions
src/main/java/com/tibiawiki/domain/objects/validation - Contracts · Wiki template, description, and validatable contracts
src/main/java/com/tibiawiki/domain/interfaces - Jackson Mixins · Custom serialization support for wiki objects
src/main/java/com/tibiawiki/domain/jackson - Kotlin Domain · 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 · Article, JSON, and wiki object conversion
src/main/java/com/tibiawiki/domain/factories - Article Repo · Abstraction over external wiki article retrieval
src/main/java/com/tibiawiki/domain/repositories/JwikiArticleRepository.java - Parse Utils · Template, list, and properties parsing helpers
src/main/java/com/tibiawiki/domain/utils - Wiki Source · External Tibia wiki content source
Connections 19
- 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