Sergi Jajanidze
Selected Work

Bank of Georgia internal multi-locale content management system, 4 min read

Polymer to React/TS CMS migration

Migrated a daily-use editorial CMS off Polymer 3, running old and new apps side by side so editors could keep working. Most of the work was rewriting the form engine that generates the whole editing UI at runtime from user-defined content types, including multi-locale editing.

The problem

An internal CMS used daily by editorial teams was built on Polymer 3, a framework in maintenance mode. It has no hand-written forms: content types are schemas fetched at runtime, and the whole editing UI is generated from them. So the migration was really a rewrite of that form engine, where every record exists per locale and fields nest arbitrarily deep.

The architecture

DiagramHow the form engine turns a schema into an editing UI
server-owned schema ──▶ form engine ──▶ field registry ──▶ components
                              │
                              ▼
   per-locale tabs · the form owns the values of every locale
                              │
                              ▼
   shared form state · validation per form and locale · children save first

Key decisions

Migrating incrementally behind a reverse proxy

Both apps ran under separate path prefixes on one origin, sharing the REST API and the session. Modules moved one at a time while the legacy app kept working, and the backend stayed untouched, so each module could be reverted by routing. The migration needed no long-lived branch or content freeze.

Choosing React over Lit 3

Lit 3 was a real contender as Polymer's successor. This internal tool had no designer, though, and React's component libraries supplied trees, drawers, tables and date pickers out of the box.

A declarative field registry

Polymer built fields imperatively. The React version maps each schema type to a component, so a new field type is a new row in the map and the renderer stays the same.

Before · Polymer
// A locale field patched its
// siblings through the DOM
_onValueChange(event) {
  const fields = this.parentNode
    .querySelectorAll("cms-text-field");

  for (const field of fields) {
    if (field.locale === this.locale) continue;
    if (!field.touched) {
      field.value = event.detail.value;
    }
  }
}
After · React
// A field type is one row;
// the renderer never changes
export const FIELDS: FieldRegistry = {
  text: TextField,
  richText: RichTextField,
  date: DateField,
  media: MediaPicker,
  reference: ReferenceSelect,
  // Nested groups re-enter the engine
  group: NestedForm,
};
Polymer fields kept locales in sync by writing to each other through the DOM. The React engine looks fields up in a map, and the form owns the values.

Multi-locale and nested forms

Polymer kept locales in sync by having fields mutate their siblings through the DOM. Here the form owns the values of every locale, and complex fields edit all locales at once through an explicit contract. Nested fields re-enter the engine, and one save commits every open form, children before parents, only if all locales are valid.

Proving each module matched

Before a module's route switched over, the same records were opened and saved in both apps against a staging API, and a script diffed the two JSON payloads field by field, per locale. A module moved only at zero diffs, after its editors signed off on staging.

Impact

  • Five product teams migrated to the new CMS, which serves 200+ content pages across 10+ products.

    MeasuredTeams from the API's audit log at the end of the migration; pages and products from the published records in the CMS database, grouped by product.

  • 10 modules moved over three months, each verified by payload diff. None needed a revert.

    MeasuredOne Jira ticket per module, closed when its route switched. A revert would have meant a reopened ticket and a rolled-back proxy rule; there were none.

  • Editors kept working throughout, and each module could be reverted on its own.
  • New field types ship as a registry entry, with no renderer changes.

Trade-offs

What it cost

  • Three months of two apps in production: a bug in a shared flow such as login or media upload had two places to live.
  • The explicit multi-locale contract dropped a few legacy behaviours editors relied on, such as copying a title into empty locales. We agreed which ones with the editors before each module moved.
  • React and a component library ship more JavaScript than Polymer did. Fine for an internal tool on office networks; it wouldn't be for a public one.

What I’d change

  • Write the payload-diff script on day one. It arrived after the second module, which we checked by hand.
  • Generate TypeScript types from the server's schema definitions instead of maintaining them by hand.

Connected work

These case studies are parts of one platform. This one connects to: