← Back
Home › Systems › Consumer applications

super-app

Hosts chat, a wallet, search and a store of third-party mini-programs inside one installed app, running each mini-program in a sandbox without an app-store install.

WeChat, Alipay, Grab, Gojek, Paytm

Open the super-app pagesuper-app CDN and edgecloud: CDNs cache content in hundreds of PoPs near users, cutting latency and egress bills; edge compute runs small code there. Bandwidth price spreads 10x between providers.›Javascript event loopcompilers: Task and microtask queues, rendering steps, timers and promise job ordering in JS hostsHdr histogramdata-structures: Log-linear bucketed histograms with bounded relative error for latency percentilesConsistent hashingdistributed: Hash nodes and keys onto a ring; each key belongs to the next node clockwise, so membership changes move only about 1/n of keys.›Deterministic simulationtestingdistributed: Run the whole system in one thread under a seeded scheduler with simulated network, disk and clock, so every failure replays from its seed.›Distributed ID generationdistributed: Mint unique, roughly time-sorted IDs on many nodes with no per-ID coordination: Snowflake (time, worker, sequence) or UUIDv7 (time, random).›Incremental sync cursorsdistributed: The client keeps one opaque token; each pull returns only the changes after it plus the next token, so sync cost scales with what changed, not with the dataset.›Message sequence numbersdistributed: A per-stream counter on every message lets the receiver detect loss, duplicates and reordering, ack cheaply and resume after reconnect with "send from N".›Presence trackingdistributed: Heartbeats refresh per-connection TTLs; a user is online while any connection lives, with a grace period that hides reconnect flaps.›Primary-backup replicationdistributed: One node orders all writes and ships them to standbys; the acknowledgement rule (none, one, all) sets what a crash loses, and an external arbiter decides who takes over.›Pub/sub fan-outdistributed: Deliver one published message to every subscriber of a topic by sharing one encoded payload and giving each connection a bounded queue with an explicit slow-consumer policy.›Double-entry ledgerfinance: Append-only journal of transactions whose postings sum to zero per currency; balances are derived, so money can only move, never appear or vanish.›Idempotency keysfinance: Client-chosen unique key per logical operation, stored with a request fingerprint and the final response, so retries replay the first result instead of acting twice.›Payment state machinefinance: Persisted state machine for a payment lifecycle (authorize, capture, void, refund) that treats timeouts as unknown, retries with the same key and applies webhooks idempotently.›Process supervisionhardware-os: A parent process starts services, reaps their exits and restarts them under a delay and burst-limit policy, then stops them with SIGTERM before SIGKILL.›Learning to rankmachine-learning: Train a scorer on query-grouped data so that the order it induces maximizes NDCG; LambdaMART (boosted trees with NDCG-weighted pair gradients) is the production default.›Mobile push deliverynetworking: Sending notifications through APNs and FCM: HTTP/2 requests, token hygiene, collapse keys, TTL and priority, and the retry rules that keep you un-throttled.›WebSocketsnetworking: Full-duplex message framing over one upgraded HTTP connection; the standard way to push real-time data to browsers.›Aho-Corasick multi-patternmatchingsearch-sort: Find all occurrences of many fixed patterns in one pass over the text, in time independent of the pattern count, using a trie with failure links.›BM25 rankingsearch-sort: The standard lexical relevance score: IDF-weighted term frequency with saturation (k1) and length normalization (b); default in Lucene, Elasticsearch and SQLite FTS5.›Coverage-guided fuzzingsecurity: Mutate inputs, run an instrumented target, and keep any input that reaches a new code edge; feedback turns blind guessing into incremental search.›Cryptographic hashes (SHA-2,BLAKE3)security: Collision-resistant fingerprints of data; SHA-256 for interoperability, BLAKE3 for speed, HMAC/HKDF for keyed uses.›Digital signatures (Ed25519)security: Small, fast, deterministic public-key signatures that prove who produced a message; the default for tokens, releases and protocols.›Mutual TLSsecurity: TLS where the client also proves a certificate key, so every connection carries a verified, rotatable machine identity.›OAuth 2 and OpenID Connectsecurity: Delegated authorization (OAuth 2) and login on top of it (OIDC); use authorization code + PKCE for every user-facing client.›Process sandboxingsecurity: Run risky work in a separate, deliberately powerless process and let a small privileged broker do the few things it needs, over a narrow pipe.›Inverted indexstorage: Map each term to a sorted, compressed list of the documents containing it; the core of full-text search and other fast set queries.›Point-in-time recoverystorage: Periodic base backups plus a continuously archived change log let you rebuild the state as of any instant, then branch from there.›Deterministic bucketingsystems: Hash a stable unit id with a per-purpose salt into a bucket; "in" means bucket below the percentage, so assignment is stateless, repeatable and only grows on ramp-up.›Graceful drainingsystems: On a termination signal, stop taking new work, finish in-flight work until a deadline, tell clients to reconnect elsewhere, then exit; clients resume from a token.›HTTP caching semanticsnetworking: The rules (RFC 9111) that decide whether a stored response is still fresh, and how a cheap conditional request revalidates it when it is not.›TLS 1.3security: The standard encrypted, authenticated transport; one round trip, only forward-secret AEAD suites, and little left to misconfigure.›epoll event loopnetworking: One thread waits on thousands of non-blocking sockets with epoll_wait and handles only ready ones; the core of nginx, Redis and tokio.›Cooperative schedulingconcurrency: Green threads/coroutines yielding at await points on a user-space schedulerFault injectiondistributed: Inject latency, errors, kills and partitions via proxies, netem or hooksRecord replaydistributed: Record every nondeterministic input (time, randomness, I/O, model and tool outputs, per-tick player input) and re-execute deterministically for debugging, replays and state rebuildHierarchical timing wheelsystems: Timers bucketed by expiry into wheels of slots, coarser wheels for far deadlines: O(1) insert and cancel for millions of timeouts.›Cursor paginationnetworking: Keyset/opaque-cursor pagination for stable incremental reads from APIs and tablesLeasesdistributed: A lock that expires on its own: bounded-time ownership that survives crashes and partitions, given bounded clock drift and fencing tokens on writes.›Health checkingsystems: Decide per backend whether to route to it using probes and real-traffic errors, with consecutive-count hysteresis, capped ejection and a panic fallback.›SPSC ring bufferdata-structures: Bounded wait-free queue for exactly one producer and one consumer thread, built from an array and two indices with acquire/release ordering.›Topic matching triedata-structures: Trie over topic levels with + and # wildcards for subscription matching+ 32 moreAEAD (AES-GCM,ChaCha20-Poly1305)security: Authenticated encryption that encrypts and detects tampering in one call; the only kind of symmetric encryption you should use.›ECDH key exchange (X25519,P-256)security: Each side multiplies the other's public curve point by its own scalar and both get the same point; always validate the peer key and run the result through a KDF.›HKDF key derivation(extract-and-expand)security: HMAC-based two-step key derivation: extract a uniform pseudorandom key from any secret, then expand it into as many context-bound keys as you need.›X509 certificatessecurity: Certificate chains, path validation, SANs, revocation and short-lived issuanceTransparent interceptionnetworking: Redirect traffic to a local proxy (iptables TPROXY/REDIRECT, eBPF) without app changesSyscall interceptionsecurity: Intercept syscalls via ptrace, seccomp user notify or a user-space kernelSlab allocatorsystems: Pre-carve pages into equal-size slots per size class with an in-place free list: O(1) alloc and free, no external fragmentation, cache-warm reuse.›Fencing tokensdistributed: A number that grows with every lock grant and is checked by the protected resource, so a paused ex-holder's late write is rejected.›False sharingconcurrency: Independent variables written by different cores on one cache line force the line to bounce between cores; pad or regroup hot data to fix it.›Memory orderingconcurrency: What Relaxed, Acquire, Release and SeqCst atomics actually guarantee, what they cost on x86 and ARM, and which one each pattern needs.›+ 15 moreConstant time codesecurity: Writing secret-dependent code without branches or memory lookups on secrets; constant-time compare and selectEbpfhardware-os: Verified in-kernel programs on hooks (kprobes, XDP, tc) with mapsPtrace process controlhardware-os: Ptrace: attach, read and write registers and memory, single-step, intercept signalsCPU caches and the memoryhierarchyhardware-os: Sizes, line widths and latencies of L1/L2/L3/DRAM on modern x86 and Apple M-series, and the data-layout rules that follow from them.›+ 4 more+ 1 more

How it is built

Architecture overview

A super-app is one installed app that acts as a platform: inside it live chat, a wallet, search and a store of mini-programs, small apps written by third parties, loaded in seconds without an app-store install, and run inside a sandbox the host controls. WeChat and Alipay are the reference examples; Grab, Gojek and Paytm built the same shape around rides, delivery and payments. The host owns three things that third parties cannot: the identity of the user, the payment rail and the distribution channel. The one idea that makes the design work is the contract between host and mini-program: the mini-program runs in a restricted runtime and may only reach the phone, the network, the user's identity and the wallet through host APIs that ask permission, log the call and can be revoked remotely. Everything else (the chat service, the search, the package delivery, the rollout system) exists to make that contract fast and safe at the scale of hundreds of millions of users and many thousands of developers.

Parts:

 developer ──upload package──► review + scan ──► sign (Ed25519) ──► package store ──► CDN / edge
                                    │ hash                                              │
                                    ▼                                                   ▼
 user device ───────────────────────────────────────────────────────────────── host app (native)
   ┌─────────────────────────────────────────────────────────────────────┐
   │ mini-program sandbox            host bridge (permissions, logging)  │
   │  logic (JS, event loop) ◄─────► view (render) ◄── host APIs: login, pay, location, scan
   └────────────────────────────┬────────────────────────────────────────┘
                                │ HTTPS / WebSocket
        ┌───────────────┬───────┴────────┬───────────────┬──────────────┐
      identity        messaging        search         wallet          rollout (buckets)
     (OAuth-like     (fan-out,       (index, rank,   (ledger, payment   config + kill switch
      per-app ids)    seq numbers)    moderation)     state machine)

How the parts fit together

Mini-program runtime

A mini-program is a package: pages, styles, scripts and a manifest. The WeChat framework documentation splits it into two parts, the App Service (the logic layer, JavaScript) and the View layer, and describes a data-binding system between them: the logic layer changes data with setData and the view layer updates itself (source: WeChat Mini Program documentation, framework). The two layers run apart, the logic in a sandboxed JavaScript engine and the view in a renderer, and every call to the phone or the network goes through the host's bridge. This separation is the sandbox in practice (Process sandboxing): the logic code has no DOM, no direct file or socket access, and no way to touch the host's memory. The logic layer is single-threaded and event-driven (javascript-event-loop, no page yet), so a long computation freezes its own page but not the host; the framework offers a separate worker for heavy work.

The host decides the lifecycle. WeChat's documentation describes cold start, running in the background, and destruction by the system at any time, and gives a mini-program an exit-state hook: the page can save a small JSON state with an expiry (default one day) that is restored on the next cold start, if the host manages to call it at all (source: WeChat Mini Program documentation, operating mechanism). Design consequence: a mini-program must be restartable from storage and server state, and the host must keep memory in check by killing backgrounded programs.

Why a standard exists but has little weight: the W3C MiniApps Working Group published a packaging specification, defining a single-file container with a manifest, page templates, stylesheets and scripts, but it now carries the status "Discontinued Draft" (source: W3C, MiniApp Packaging, dated 11 August 2026). Each super-app still has its own package format and API set, so cross-platform frameworks such as Taro and uni-app compile one source to several platforms' mini-program formats instead.

Platform rules apply from outside, too. Apple's App Store guidelines allow HTML5 and JavaScript mini apps inside an app, make the host app responsible for their compliance, and forbid exposing native platform APIs to them without Apple's permission (source: Apple, App Store Review Guidelines, 4.7). The host bridge is therefore also a policy boundary, not only a technical one.

Distribution and rollout

A package is fetched on first open and cached. Integrity and origin matter more than in a web page, because the package runs inside a trusted app with access to payments. The build pipeline computes a content hash of the package and signs it with a platform key (Digital signatures (Ed25519)); the host verifies the signature before it runs the code, so a compromised CDN or a man in the middle can serve bytes but not a valid program. (The sources checked here do not document WeChat's or Alipay's signing scheme; this is the standard design the blocks describe.) Delivery goes through a CDN and edge with the package addressed by hash, so versions are immutable and cacheable. WeChat's documentation also lists sub-package loading and pre-download of sub-packages, which keeps the first download small and fetches the rest when needed (source: WeChat Mini Program documentation, index of framework topics).

Rollout is staged and reversible. Deterministic bucketing hashes a user or device identifier with the experiment name into a bucket, so the same user always sees the same version, and a release can go to 1 %, 10 %, 100 % by moving a threshold. A kill switch on a mini-program version (the host refuses to run a version ID) is the emergency lever; it is delivered through the same config channel. Which users see which mini-programs and which config version they have is synchronised with Incremental sync cursors: the client asks "changes since cursor N" and never refetches the whole list. Consistent hashing spreads sessions, mini-program state and cache across servers so that adding a node moves only a fraction of the keys.

Identity and authorisation

The user logs in once to the host. A mini-program should not learn who the user is just because the user opened it, so the host issues a different identifier per mini-program and an authorisation step for anything more. WeChat's documentation lists a login flow, a UnionID mechanism (an identifier shared across a developer's apps), user authorisation and verified phone-number components (source: WeChat Mini Program documentation, index of open capabilities). Mechanically this is OAuth 2 and OpenID Connect in a closed ecosystem: the mini-program asks the host for a short-lived code, sends it to its own server, the server exchanges it with the host's backend for the user's per-app identifier and a session key, and any sensitive scope (phone number, location, payment) needs an explicit consent shown by the host, recorded and revocable. Identifiers are minted by Distributed ID generation: time-ordered, unique across many generators without a central counter, and not guessable.

Messaging

Chat is the entry point and the reason people keep the app open. Clients keep a WebSocket to a gateway; messages go to a conversation, and each conversation fans out to its members through Pub/sub fan-out: small groups write the message to every member's inbox, huge groups store once and let members pull. Order and gaps are handled with Message sequence numbers per conversation: the client sees 41, 42, 44 and asks for 43; reconnecting clients say "I have up to 44". Presence tracking shows who is online and typing, with a lease that expires when a heartbeat stops. When the app is not running, Mobile push delivery wakes the phone through the platform's push service; the push is a hint, and the message itself is synced when the app opens.

One search box covers contacts, chat history, public content, mini-programs and services. Documents go into an Inverted index per corpus; first-stage retrieval ranks by BM25 ranking; a Learning to rank model reorders the top candidates using features such as freshness, popularity, personal affinity and click history. Aho-Corasick matches thousands of patterns in one pass, and the platform uses it where many strings must be found at once: spotting a mini-program or brand name inside a query, and screening content and queries against blocked-term lists. Search is also where the platform's rules show up: delisted mini-programs must vanish from the index within minutes.

Wallet and payments

The wallet is a Double-entry ledger of user balances, merchant balances, fees, and holding accounts for money in transit to and from banks. A payment inside a mini-program is a three-party flow: the mini-program's server creates an order with the host's payment API, the host app shows a native confirmation (the mini-program never sees the PIN), and the wallet debits the user and credits the merchant. The order follows a Payment state machine, and every mutating call carries an Idempotency key because the merchant's server and the host's callbacks both retry. The merchant is told of the result by a signed callback, and must treat the host's query API as the source of truth, not the callback alone.

Platform operations

The wallet and identity stores run on Primary-backup replication with Point-in-time recovery. Process supervision restarts failed services; Graceful draining lets connections and in-flight payments finish before a deploy, and matters in particular for long-lived WebSockets, where a naive restart disconnects millions of clients at once. Service-to-service traffic uses Mutual TLS. Deterministic simulation testing covers the stateful services (wallet, message ordering, sync), and Coverage-guided fuzzing covers the parsers that touch untrusted input: package manifests, message formats, query strings. Latency is tracked as full distributions (hdr-histogram, no page yet), per API and per mini-program, because a slow third-party mini-program is blamed on the host.

Data and control flow

Opening a mini-program and paying in it:

  1. The user taps a mini-program. The host resolves the identifier and the current version for this user (bucketing, kill-switch check) from its cached config.
  2. If the package is not cached, the host downloads it from the edge by hash, verifies the signature, and starts the sandbox. A small main package loads first; further sub-packages load on demand.
  3. The mini-program calls the host's login API; the host returns a short-lived code. The mini-program's server exchanges it for the per-app user identifier and a session.
  4. The user taps pay. The mini-program's server creates an order at the host with an idempotency key; the host shows the native payment sheet with merchant, amount and currency.
  5. The user confirms with a PIN or biometric. The wallet engine reserves the balance, posts the entries, marks the order paid, and queues the callback and the receipt message through an outbox.
  6. The mini-program shows success after it queries the order status on its server, which has received the signed callback and verified it against the host's query API.

Sending a chat message:

  1. The client sends the message with a client-generated id over its WebSocket.
  2. The gateway assigns the next sequence number in the conversation, stores the message, and publishes it.
  3. Online members receive it on their sockets; offline members get a push and sync by cursor on opening.

Scaling

  1. Package delivery and cold start. First-open latency is mostly download. Lever: small main package plus sub-packages, content-addressed packages on the CDN, preload of likely next mini-programs.
  2. Connections. One live socket per active user. Lever: gateways that hold only connections and are stateless otherwise, consistent hashing of sessions, draining on deploy.
  3. Fan-out of big groups. Writing to every member's inbox is too expensive for a large group. Lever: store once, fan out on read for large groups, write-fan-out for small ones.
  4. Search index size and ranking cost. Lever: shard the inverted index, cheap first stage, a learned ranker on a few hundred candidates only.
  5. Payment peaks (a holiday campaign). Lever: partition wallets by user, hot merchant accounts split into sub-accounts, queue non-critical work (receipts, analytics).
  6. Developer ecosystem. The number of mini-programs and their versions. Lever: automated review and scanning, rate limits per developer, per-mini-program quotas for storage and API calls.

Failure modes

FailureSymptomCauseFix
Sandbox escapea mini-program reads data or calls APIs it should notan API exposed natively without a check, engine bugminimal API surface, permission check in the bridge, per-API logging, process isolation, quick kill switch
Tampered packageusers run code the developer did not publishcompromised CDN, no verificationsignature check on device, content-addressed delivery
Bad releasecrash or wrong behaviour across a versionno staged rolloutbucketed rollout, kill switch by version, fast rollback
Double chargemerchant order paid twiceretry without idempotency, callback replayidempotency key on the order, order state machine, query as source of truth
Forged payment callbackmerchant ships goods without paymentunsigned or unverified callbacksignature check plus status query
Out-of-order or lost messagesgaps or reordering in a conversationreconnects, multiple serversper-conversation sequence numbers, cursor sync
Thundering reconnectall clients reconnect after a gateway restartrestart without draininggraceful draining, jittered reconnect, connection limits
Presence flappingusers appear online and offline repeatedlyheartbeat timeouts too tight on bad networkslease with grace period, debounce
Identifier leakagea developer can track a user across mini-programsone global identifierper-app identifiers, cross-app identifier only with consent
Search shows removed contentdelisted mini-program still foundslow index updatetombstone path with a short propagation target
Platform-rule violationapp store rejects the hostnative APIs exposed to mini-programs without approvalfollow the store's mini-app rules, review process

Real implementations

namewhat it isrepolicencenotes
WeChat mini programsthe reference platform: logic layer plus view layer, sub-packages, login, UnionIDdevelopers.weixin.qq.comproprietarypublic developer documentation; platform internals not published
Alipay mini programsAlipay's mini-program platform for third-party developersopendocs.alipay.com/miniproprietarypublic developer documentation
Grab, Gojek, Paytmregional super-apps with mini-app programsnone publicproprietarynamed without link: no public architecture documents checked
W3C MiniApp packagingattempted standard for the package containerw3.org/TR/miniapp-packagingW3C document licencestatus: Discontinued Draft
Taroopen-source framework compiling one codebase to several mini-program platformsNervJS/taroMITauthor-side tool, not a host runtime
uni-appopen-source Vue-based framework targeting several mini-program platformsdcloudio/uni-appApache-2.0author-side tool

There is no widely used open-source host runtime to cite from the sources checked; the host side of a super-app is proprietary at every large operator.

Sources

  • Tencent, Weixin Mini Program developer documentation: framework, framework introduction, operating mechanism. English pages are machine-translated; the Chinese text prevails.
  • Alipay, Mini Program documentation. docs
  • W3C MiniApps Working Group, MiniApp Packaging (Discontinued Draft, 11 August 2026). spec
  • Apple, App Store Review Guidelines, section 4.7 (mini apps, mini games, plug-ins). guidelines
  • Taro. repo; uni-app. repo

Similar systems

Share the most building blocks with this one.