Architecture
Overview of the Wakapp architecture: multi-tenant hierarchy, services, communication flows and access modes.
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:
textPartner └── App ←── the Wakapp connects here └── Network (1 realm Keycloak) └── Customer ├── User └── Team
| Entity | Role | Short identifier (WID) |
|---|---|---|
| Partner | Platform owner (e.g. Wakastellar) | PTR001 |
| App | Wakapp application, attached directly to a Partner | APP001 |
| Network | Grouping of Customers for a given App, 1 dedicated Keycloak realm | NET001 |
| Customer | End tenant (a client company), attached to a Network | ACM001 |
| User | Human user, member of a Customer | WKST05 |
| Team | Group of users within a Customer | TEAM01 |
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/enrichendpoint is publicly exposed: any Wakapp can call it after receiving a Keycloakaccess_tokento obtain an enrichedwakaToken. - The public API is the single entry point for all business operations post-auth.
The two public APIs consumed by a Wakapp
| API | When | Endpoint examples |
|---|---|---|
| Discovery API | Before authentication | POST /discover/start-login, GET /discover/subdomain, GET /discover/email |
| Public API | After authentication | GET /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
| Aspect | WakaStart platform | Your WakaApp |
|---|---|---|
| Auth | Keycloak OAuth2 PKCE | Implement the PKCE flow (see chapter 3) |
| Enriched token | Managed by WakaStart, to be forwarded as x-enriched-token | Store in an HttpOnly cookie, do not inspect locally |
| Rights verification | POST /api/token/authorize endpoint | Delegate the verification — never decode/validate the wakaToken locally |
| Identifiers | WID (6 chars) + UUID | Prefer using WIDs in URLs |
Two access modes
| Mode | Usage | Required header(s) |
|---|---|---|
| JWT Bearer + enriched | User-facing apps (proxied frontend) | Authorization: Bearer <keycloak_token> + x-enriched-token: <wakastart_token> |
| API Key | Backend services, scripts, cron jobs | x-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)
text1. [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-tokenon the Wakapp side: delegate toPOST /api/token/authorizefor any authorization decision. - Respect the hierarchy in your requests: a CustomerAdmin cannot access another Customer's data.
Learn more
- Discovery — Identifying the user: the first call before auth
- Authentication — OAuth2 PKCE: the full flow
- Using the API: headers, pagination, multi-tenant