WakaStart
Getting started

Architecture

Overview of the Wakapp architecture: multi-tenant hierarchy, services, communication flows and access modes.

Version v1.04 min read

Architecture

A Wakapp is a third-party application integrated with the WakaStart platform. This chapter gives the full map of the territory before diving into the details.

Why this step

Before writing a single line of integration code, you need to understand how the entities fit together and which services expose which boundaries. A common mistake is to treat the platform as a plain REST CRUD, when it actually carries a strict multi-tenant hierarchy on which all data isolation depends.

Multi-tenant hierarchy

WakaStart organizes entities top to bottom:

text
Partner └── App ←── the Wakapp connects here └── Network (1 realm Keycloak) └── Customer ├── User └── Team
EntityRoleShort identifier (WID)
PartnerPlatform owner (e.g. Wakastellar)PTR001
AppWakapp application, attached directly to a PartnerAPP001
NetworkGrouping of Customers for a given App, 1 dedicated Keycloak realmNET001
CustomerEnd tenant (a client company), attached to a NetworkACM001
UserHuman user, member of a CustomerWKST05
TeamGroup of users within a CustomerTEAM01

Golden rule: all data belongs to a Customer. Isolation is enforced at the query level (Prisma filters) — never through separate databases.

Where the WakaApp sits in the ecosystem

text
┌──────────────────────────────────────────┐ │ PLATEFORME WAKASTART │ │ │ ┌──────────┐ │ ┌──────────────┐ ┌──────────────┐ │ │ │ │ │ API Discovery │ │ Keycloak │ │ │ Wakapp ├──┼──►│ pré-auth │───►│ OAuth2 OIDC │ │ │(frontend)│ │ └──────────────┘ └──────┬───────┘ │ │ │◄─┼──────────────────────────────┘ (PKCE) │ │ │ │ │ │ │ │ ┌──────────────────────────────────┐ │ │ ├──┼──►│ API d'enrichissement /auth/enrich│ │ │ │ │ └──────────────────────────────────┘ │ │ │ │ │ │ │ │ ┌──────────────────────────────────┐ │ │ ├──┼──►│ API publique /api/... │ │ │ │ │ │ CRUD multi-tenant + autorisations│ │ │ │ │ └──────────────────────────────────┘ │ └──────────┘ └──────────────────────────────────────────┘

Key points:

  • The Discovery API is consumed before authentication to obtain the Keycloak login URL (start-login).
  • The /api/auth/enrich endpoint is publicly exposed: any Wakapp can call it after receiving a Keycloak access_token to obtain an enriched wakaToken.
  • The public API is the single entry point for all business operations post-auth.

The two public APIs consumed by a Wakapp

APIWhenEndpoint examples
Discovery APIBefore authenticationPOST /discover/start-login, GET /discover/subdomain, GET /discover/email
Public APIAfter authenticationGET /api/me, GET /api/config/users, POST /api/invitations, etc.

The canonical URLs are documented in Environments. No other internal URL can be consumed from a Wakapp.

Stack on the Wakastart side vs. the WakaApp side

AspectWakaStart platformYour WakaApp
AuthKeycloak OAuth2 PKCEImplement the PKCE flow (see chapter 3)
Enriched tokenManaged by WakaStart, to be forwarded as x-enriched-tokenStore in an HttpOnly cookie, do not inspect locally
Rights verificationPOST /api/token/authorize endpointDelegate the verification — never decode/validate the wakaToken locally
IdentifiersWID (6 chars) + UUIDPrefer using WIDs in URLs

Two access modes

ModeUsageRequired header(s)
JWT Bearer + enrichedUser-facing apps (proxied frontend)Authorization: Bearer <keycloak_token> + x-enriched-token: <wakastart_token>
API KeyBackend services, scripts, cron jobsx-api-key: sk_live_...

API keys entirely replace the Bearer+enriched pair: the public API rebuilds the user context from the key.

Communication flow (overview)

text
1. [PREAAUTH] Wakapp → API Discovery : POST /discover/start-login → URL Keycloak retournée Wakapp → Keycloak : redirect navigateur (PKCE) Keycloak → Wakapp : redirect avec code d'autorisation 2. [EXCHANGE] Wakapp → Keycloak : POST /token (code + verifier) Keycloak → Wakapp : access_token + refresh_token 3. [ENRICH] Wakapp → API publique : POST /api/auth/enrich (Bearer) → wakaToken enrichi retourné 4. [PROFILE] Wakapp → API publique : GET /api/me (Bearer + x-enriched-token) → profil + rôles + appRights 5. [API CALLS] Wakapp → API publique : GET|POST|PATCH|DELETE /api/... → données métier paginées

Best practices

  • Store tokens in HttpOnly cookies (never in localStorage).
  • Use WIDs in your URLs and logs — UUIDs are internal.
  • Never inspect or verify the signature of the x-enriched-token on the Wakapp side: delegate to POST /api/token/authorize for any authorization decision.
  • Respect the hierarchy in your requests: a CustomerAdmin cannot access another Customer's data.

Learn more