# MIT-Licensed Wayland-to-HTML5 Compositor — Architecture & Build Plan
> **Purpose.** This bundle documents the architecture, components, and
> implementation plan for building a **fully proprietary** Wayland-to-HTML5
> compositor that integrates with an Odoo 20 fork. It is the alternative to
> the AGPL-licensed Greenfield codebase (`../greenfield-analysis/`).
>
> **Goal.** Run real Linux applications (GTK3/4, Qt, xterm, X11 via XWayland)
> **natively inside the Odoo web client**, as if they were Odoo-native apps —
> while a real Linux machine under the hood actually executes them.
>
> **License strategy.** Use every MIT/Apache-2.0/BSD-licensed Greenfield
> library as a building block. Replace the AGPL-licensed packages
> (`@gfld/compositor`, `@gfld/compositor-proxy`, `@gfld/compositor-shell`,
> `@gfld/compositor-proxy-cli`) with **clean-room reimplementations** in
> TypeScript (browser) and Python (Linux host). Ship the result as a
> proprietary addon for the Odoo fork.
## How to read this bundle
The bundle is split into 13 Markdown files mirroring the Greenfield
analysis structure (so you can compare them side-by-side). Files are
ordered from the highest-level view down to implementation details,
then pitfalls, then appendix.
| # | File | What you'll find inside |
|---|------|-------------------------|
| 0 | `00-overview.md` | The MIT approach at a glance, component inventory, license summary, architecture diagram |
| 1 | `01-architecture.md` | Layered map of the proposed architecture, side-by-side with Greenfield's layers |
| 2 | `02-wayland-protocol.md` | How to handle the Wayland protocol layer with MIT libs only (pywayland + Greenfield's MIT @gfld libs) |
| 3 | `03-html5-rendering.md` | Custom WebGL2 + Web Workers + OffscreenCanvas browser compositor (replacing @gfld/compositor) |
| 4 | `04-transport.md` | Python aiohttp WebSocket + KCP, replacing Node's ws + KCP TS |
| 5 | `05-input-handling.md` | Python xkbcommon for keymap compilation, browser-side xkbcommon WASM for state |
| 6 | `06-data-clipboard.md` | Clipboard + DnD bridge, with primary selection (which Greenfield lacks) |
| 7 | `07-native-app-bridge.md` | pywayland + bubblewrap + seccomp + systemd-run, with proper sandboxing (Greenfield has none) |
| 8 | `08-app-lifecycle.md` | xdg-shell state machine — what to implement, with a clean-room spec |
| 9 | `09-hardware-accel.md` | GStreamer Python + WebCodecs (no GPL x264, no GPL FFmpeg WASM) |
| 10 | `10-odoo-integration.md` | Odoo 20 OWL shell + backend addon, JWT auth, multi-tenancy |
| 11 | `11-pitfalls.md` | Pitfalls of the MIT approach + risk analysis + the 3 GPL contaminants found |
| 12 | `12-appendix.md` | Glossary, file index, references |
| — | `../Greenfield-vs-MIT-Comparison.md` | Top-level comparison document with person-week estimates and strong recommendation |
## TL;DR — can we really do this?
**YES — with three mandatory substitutions.**
The 9 MIT/Apache/BSD Greenfield libraries are reusable as-is, with
**zero AGPL contamination** (verified by grep'ing every `import` statement
in `libs/`). But the audit found three GPL contaminants that must be
replaced:
1. **`@gfld/compositor-ffmpeg-h264` is GPL-3.0, not Apache-2.0** as its
`package.json` claims. The TypeScript wrapper is Apache-2.0, but the
compiled FFmpeg WASM binary is GPL-3.0 (built with `--enable-gpl
--enable-version3 --enable-nonfree`). **Replace with WebCodecs
`VideoDecoder` API** (browser-native, MIT/W3C standard).
2. **`x264enc` GStreamer plugin is GPL-2.0+**. Using it in a proprietary
product forces GPL on the entire combined work. **Replace with
`vaapih264enc` (Intel/AMD), `nvh264enc` (NVIDIA), or `openh264enc`
(BSD libopenh264, CPU fallback)**.
3. **`gstreamer1.0-libav` on Debian is GPL** — the source is LGPL-2.1+,
but Debian's `libavcodec.so.61` is built with `--enable-gpl` and
directly links `libx264.so.164` + `libx265.so.215`. **Don't install
this package** — use only gst-plugins-base + gst-plugins-good +
gst-vaapi + BSD subset of gst-plugins-bad.
With these substitutions, **the proprietary strategy is unambiguously
viable**. See `11-pitfalls.md` for the full audit table and
`../Greenfield-vs-MIT-Comparison.md` for the final recommendation.
## Architecture in one diagram
```
┌──────────────────────────────────────────────────────────────────────────────────┐
│ BROWSER (Odoo 20 web client) │
│ │
│ ┌────────────────────────────────────────────────────────────────────────────┐ │
│ │ Odoo 20 OWL Shell addon (PROPRIETARY — your code) │ │
│ │ - Application launcher, window manager, keyboard picker │ │
│ │ - Per-output