Skip to content

Modular 3-layer architecture (fetcher → normalizer → sdk) #52

@alexandretrotel

Description

@alexandretrotel

I’d like to propose a small structural improvement to make exchange integrations more explicitly modular and plug-and-play.

By venue, I mean every prediction market supported like Polymarket, Kalshi, etc.

Idea

For each venue, it would be great to clearly separate:

  1. Fetch layer
    Responsible for calling the venue API (via callApi), handling pagination/rate limits, and returning venue-native/raw data.

  2. Normalization layer
    Responsible for mapping venue-native shapes into pmxt unified types (UnifiedMarket, etc.).

  3. SDK class (composition layer)
    Finally, the SDK class wires fetchers + normalizers together and exposes the unified methods defined in BaseExchange.

The sidecar model and SDKs remain unchanged.

Why

Right now, fetching and normalization logic are often mixed inside exchange implementations or utilities. Making the boundary explicit would:

  • Make venues easier to reason about
  • Improve testability (mock fetchers separately from normalizers)
  • Allow advanced users to reuse only part of the stack
    • e.g. reuse pmxt’s Polymarket fetch layer but plug in a custom normalizer
    • or reuse pmxt’s normalization but fetch from a custom data source
  • Make adding new venues more straightforward

And, of course, we could have shared utilities if multiple venus share the same logic, but again, this should be explicit.

I won't have time for now to make a PR on this but I could help in the future. Anyone can take it until then.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions