Skip to content

Database

LeNDuyA edited this page Oct 30, 2025 · 10 revisions
---
title: MoveListDB Architecture
---
graph TB
    subgraph wikiWavu["wikiWavu feature module"]
        Interface["MoveListDB Interface"]
        UseCase["CacheMoveListUseCase"]
        UseCase -->|depends on| Interface
    end

    subgraph botModule["Discord bot"]
        InMemory["InMemoryMoveListDB"]
        BotDI["Koin DI module<br/>bind InMemoryDB → Interface"]
        InMemory -.->|implements| Interface
        BotDI -->|provides| InMemory
    end

    subgraph composeApp["composeApp"]
        Room["RoomMoveListDB"]
        AppDI["Koin DI module<br/>bind RoomDB → Interface"]
        Room -.->|implements| Interface
        AppDI -->|provides| Room
    end

    style wikiWavu fill:#fff4e1,stroke:#333,stroke-width:2px,color:#000
    style botModule fill:#e1f5ff,stroke:#333,stroke-width:2px,color:#000
    style composeApp fill:#ffe1f0,stroke:#333,stroke-width:2px,stroke-dasharray: 5 5,color:#000

    style Interface fill:#fff,color:#000
    style UseCase fill:#fff,color:#000
    style InMemory fill:#fff,color:#000
    style BotDI fill:#fff,color:#000
    style Room fill:#fff,color:#000
    style AppDI fill:#fff,color:#000
Loading

There are differences between the end clients:

  • Discord bot - uses in-memory database (something like Map<String,Move>) 1
  • mobile apps - use SQL database (Room)

Because of that split, each end client provides its own MoveListDB implementation. Koin then binds the implementation to the interface.

I highly encourage you to use this approach when creating a Wiki-based feature module for these reasons:

  • we do not want to make an API call for every query
  • bots do not need persistent data that survives process death
    • the bot runs continuously and if the bot crashes, we have bigger issues to worry about
    • we download fresh data every hour 2 to stay in sync anyway
  • mobile clients need persistent data because their whole point is offline data access
    • allows for longer-period data downloads (6 hours by default)
    • also allows manual data refresh

1 A simple in-memory implementation: LINK

2 One hour seems to be about right to get fresh community updates, especially when a new character releases

Clone this wiki locally