KTC energy platform
A B2B SaaS energy‑management platform for large property owners, run by the Swedish building‑automation company KTC.
- Role
- Senior Frontend Engineer
- When
- Sep 2021 – Oct 2024
- Team
- 6 engineers
- Work format
- Via N‑iX, remote
- Client
- KTC, Sweden
- Stack
- Angular
- TypeScript
- RxJS
- NgRx
- Nx
- Angular Material
- Jest
Results
Meter calculations
No release needed
Before, a new meter calculation needed a developer and a release. Now an admin adds it in the editor.
Shared UI update
1 PR
Before, a shared UI update took a library release, then a pull request in each app. Now it takes one pull request, tested against both apps.
Unscheduled export
3 steps to 1
Before, a one-off export took three steps: set up a scheduled job, run it, and find the file in its history. Now it takes one dialog, and the file downloads directly.
Extended calculated meters beyond sum, min and max with a self‑service formula editor
- Meter calculations
- No release neededinstead of a developer and a release
- My part
- Built the editor solo
- Duration
- About 2 months
- Scope
- Calculated meters in the admin console
The problem
A calculated meter gets its readings from other meters, not from a device. In the admin console, calculated meters supported only sum, min and max. Anything else, such as a building’s main meter minus its tenants’ submeters, needed a developer and a release.
What I did
Built the editor
In a dialog, an admin picks meters, joins them with +, −, × or ÷, and groups them in brackets, one level deep. The same meter can’t be picked twice, and saved formulas can be edited. The backend team built the API and the evaluation.
Rebuilt the form around a tree
The first version saved a formula as one string of meters and operators, so reopening it meant parsing that string back into the form. We then moved the saved format to an expression tree, and I rebuilt the form around it: each operand is a meter or a bracketed group.
Added circular-reference checks
A formula can use another calculated meter, so cycles are possible. The editor hides meters that already reference the one being edited. The API rejects deeper cycles, and the editor shows that error.
First version: the formula main meter minus tenant A minus tenant B, saved as one string. Reopening it meant parsing the string back into rows. Final: the same formula as an expression tree. It holds the main meter, a minus, and a bracketed group of tenant A plus tenant B, and maps directly onto the form.
What made it hard
Keeping the form and the tree in step
As admins add and remove meters, operators and groups, the nested form has to keep every operand matched with an operator.
Cycles the editor can’t see
The editor knows only which meters reference the one being edited, so a cycle through several meters reaches the API. The editor then has to turn the API’s rejection into an error the admin can act on.
What it gave me
Nested reactive forms
Editing a formula tree in an Angular form, with a nested FormArray for each bracketed group, saved in the shape the form shows.
Designing a UI around an API’s rules
Splitting the checks: the editor blocks duplicates and direct cycles, and the API has the final say.
Consolidated two apps and their UI library in Nx, ending separate library releases
- Shared UI update
- 1 PRinstead of a library release, then a PR in each app
- My part
- Workspace setup, moving both apps and the library in
- Duration
- About 2 months
- Scope
- Admin console, customer portal, UI library
The problem
The admin console and the customer portal used a shared UI library published as an npm package. A shared UI change meant a library PR, a version bump and an npm publish, then a PR in each app.
What I did
Set up one workspace for both apps
I set up the Nx workspace and moved both production apps and the UI library into it.
Swapped the published package for its source
Both apps now build against the library’s source instead of a published package. That ended separate library releases: a shared UI change is one PR, tested against both apps. The team lead set up CI/CD and per-app releases.
Reused a feature across both apps
With shared code in place, I moved building and apartment management out of the admin console into shared libraries and shipped it in the customer portal.
Before: the UI library was published as an npm package. A shared change took a pull request, a version bump and a publish, then a pull request in each app, the admin console and the customer portal. After: the library’s source sits in one Nx workspace with both apps, and both import it from source, so a shared change is one pull request.
What made it hard
Colliding path aliases
The two apps used the same alias names for different code, so their imports broke in one workspace. I wrote a codemod to rewrite them instead of fixing them by hand.
One library version for both apps
Each app had used its own published version of the library. On source, both had to work with the same, current library code at once.
What it gave me
Setting up Nx for two live apps
Bringing two live apps and their library into one workspace, and swapping a published package for its source.
Codemods for large refactors
Writing a codemod for a change too big to make by hand, and checking it against two live apps.
Also at KTC
On-demand export
Built an on-demand export, so a one-off file takes one step instead of three. Every export used to be a scheduled job. Now users pick a format, period, meter types and resolution, and the meter data downloads directly in the customer’s property-management system format. The backend team built the formats.
Promotion, interviews and talks
Promoted to Senior in Mar 2023. Conducted 10+ technical interviews for Angular roles and presented at five internal knowledge-sharing meetups.