thiago-menezes/ career.fig
PTArticlesRésumé

Articles · October 23, 2026 · 4 min read · Leia em português

One codebase for several universities, and where multi-brand breaks

What changes per brand and what stays the same on the course platform I run at Grupo Ser, and the four places where one codebase for six universities ran into trouble.

The article title next to the real output of an ls in the project's themes folder, with one theme file per Grupo Ser brand.

Grupo Ser is a Brazilian education group with several universities, and each one used to have its own website to sell courses. In 2025 the platform I run started as an MVP, one site to advertise the courses that six of the group's schools sell, and today every school in the group is on it.

It's a single repository, and I'm the only product developer on it, from the front end to the back office. A coworker on the infrastructure side takes care of domains and deploys, and an outside company builds the pricing and offers APIs.

A lot of people think of multi-brand as a color problem, like swapping one school's green for another school's blue. The color part I solved quickly, with one file per brand, and the hard part was the four things I go through below.

What changes per brand

Every brand ships with the same code and one variable that says which brand it is. Simplified for this article:

const BUILD_BRAND = isValidBrand(process.env.NEXT_PUBLIC_INSTITUTION)
  ? process.env.NEXT_PUBLIC_INSTITUTION
  : "grupo-ser";

export const getBrand = () => BUILD_BRAND;

From that variable we change the domain, the colors, the menu, each brand's tag container (in other words, the thing that loads the tracking scripts), the lead forms and the content. The colors live in one theme file per brand, with nothing but the design system's CSS variables:

[data-rs-theme="marca-a"] {
  --rs-color-brand: #04753e;
  --rs-color-background-secondary: #ebb90c;
}

The menu comes from the back office, built per brand. Everything else is the same for everyone: the components, the API layer that pulls together the CMS, courses and leads, and the 17 sections of the site, from course search to the ENEM calculator (ENEM is Brazil's national college entrance exam).

Where it breaks

None of these problems showed up on day one. They all showed up when one brand needed something the others didn't.

The brand switcher and static pages. For testing, I wanted to pick a brand from a switcher and see the server render that brand. The obvious way is to read a cookie in the root layout, but in Next.js reading a cookie there takes every route out of static rendering, so no page comes out of the build ready to serve. So here's how it ended up: in production the brand is fixed at build time and the cookie is never read. The switcher only works in test builds, and there the page goes out with Cache-Control: private, no-store, because the same URL shows a different brand to each person.

The wrong brand in analytics. The online and hybrid courses are the same across several brands. The purchase event grabbed the first school listed on the course record, so one brand's page was reporting a different brand in analytics, and this was in production. The fix was to change where the brand comes from: the event now sends the brand the page was resolved for, and no longer the one on the course record.

The city picker on a big brand. The city picker read the first page of the list, which is sorted by state. On a brand with more than 100 cities, someone in a state near the end of the alphabet couldn't find their own city. Now, when the brand is big, the picker fetches the cities for the state the person picked.

The same slug on several brands. The blog can show articles that other brands share. When content is shared, looking up an article by its URL has to filter by brand, or a page opens on the wrong site. That filter has its own test now, so nobody removes it by accident.

Tests and releases

I think bugs like these will always show up, and what I can control is how long they stay in production. That's what the tests are for, and it's boring, automated work. The front end has 117 unit test files and 9 end-to-end tests in Playwright, in other words, tests that open the site in a browser and click around the way a person would. We shipped 226 releases in 34 weeks, almost seven a week, and every one goes through the tests first.

I wrote 93% of the front-end commits and 80% of the back-office ones, and I build the back end with help from AI. But AI wasn't going to notice on its own that the big brand broke the small brand's rule. That only shows up when someone looks at the site the way each brand's students do.

If I were starting another multi-brand project today, I'd decide early where the brand gets resolved (at build time, by domain or per request) and I'd write down why in the code, because each choice changes what the cache can store. For every piece of shared data I ask which brand it belongs to on that page, and the answer is almost never in the data itself. And I'd always test with the biggest brand and the smallest one, because the one in the middle hides both problems.

Shortcuts

Tab, arrows
Move between frames
Enter
Open a case
Esc
Back to the canvas
L
List view
D
Dev Mode
C
Show or hide comments
R
Résumé
+ / −
Zoom
Shift 1 / 2
Fit all / fit selection