This repository contains the sources of our company website (adfinis.com). It is a monorepo with two independent apps:
| Folder | What | Node.js | Dev URL |
|---|---|---|---|
strapi/ |
Strapi 5 headless CMS (backend) | 24.15.0 |
http://localhost:1337 |
nextjs/ |
Next.js 16 / React 19 (frontend) | 24.15.0 |
http://localhost:3000 |
Content lives in PostgreSQL, is edited in Strapi and is fetched by Next.js over the Strapi REST API. Each app has its own package.json, .nvmrc and node_modules, so every command below is run from inside the respective folder.
You need three things: Docker (for PostgreSQL), a Node version manager (the two apps need different Node versions) and git.
# Docker Desktop (or any other Docker engine you prefer)
brew install --cask docker
# fnm: fast Node version manager, reads the .nvmrc files in this repo
brew install fnm
echo 'eval "$(fnm env --use-on-cd --shell zsh)"' >> ~/.zshrc
source ~/.zshrcWith --use-on-cd, entering strapi/ or nextjs/ automatically switches to the right Node version. Prefer nvm? That works too (nvm install / nvm use inside each folder).
Install Docker with your package manager (docker.io on Debian/Ubuntu, docker on Fedora/Arch), start the service and add yourself to the docker group (sudo usermod -aG docker $USER, then log out and in). Install fnm or nvm.
./scripts/setup.shThe script is safe to re-run and never overwrites existing files. It:
- checks that git, Docker (running) and a Node version manager (fnm or nvm) are available (
./scripts/setup.sh --checkdoes only this) and tells you how to install what is missing, - installs the Node versions pinned in
strapi/.nvmrcandnextjs/.nvmrc, - starts the PostgreSQL container (creating it on first run),
- creates
strapi/.envandnextjs/.env.localwith generated secrets, the database settings and a matchingDRAFT_MODE_SECRET, - runs
npm ciin both apps, - seeds Strapi (
npm run seedinstrapi/): the five locales, a local admin account (admin@adfinis.test/Adfinis-local-1, only if no admin exists yet; setDEFAULT_STRAPI_ADMIN_PASSto choose another password), a read-only API token (the seed prints it once;setup.shstores it innextjs/.env.local), a placeholder homepage, navigation menu and footer for every locale and a webhook named "Revalidate nextjs cache" (see Architecture). The seed lives instrapi/scripts/seed/, one file per step understeps/.
Then start the two apps in separate terminals:
cd strapi && npm run develop # http://localhost:1337/admin
cd nextjs && npm run dev # http://localhost:3000The seed refuses to run unless it looks like a local development setup: NODE_ENV must be unset or development, APP_URL must be unset and the database (DATABASE_HOST / DATABASE_URL) must be localhost. The seeded content is only placeholder text so the site renders; replace it in the Strapi admin. Seeded media points at a logo in nextjs/public, so no object storage is needed.
The rest of this section explains each step in case you want to do it by hand or something goes wrong.
docker run -d \
-p 5432:5432 \
--name adfinis-website-postgres \
-e POSTGRES_DB=postgres \
-e POSTGRES_PASSWORD=supersecret \
postgresCheck that it is running with docker ps. The data survives docker stop/docker start; only docker rm deletes it (see Database management).
cd strapi
fnm use # or `nvm use`
npm install
cp .env.example .envEdit strapi/.env:
- Secrets: replace every
toBeModified…/tobemodifiedvalue with a random string (openssl rand -base64 24).APP_KEYStakes several comma-separated keys. - Database: Strapi defaults to SQLite, so point it at the container from step 1. Add:
DATABASE_CLIENT=postgres DATABASE_HOST=localhost DATABASE_PORT=5432 DATABASE_NAME=postgres DATABASE_USERNAME=postgres DATABASE_PASSWORD=supersecret - Draft mode: set
DRAFT_MODE_SECRET(openssl rand -hex 32). It must be the same value as in the Next.js env (see step 3), and is what makes "Preview" in the Strapi admin work. - Uploads: media is stored in a DigitalOcean Space (
DO_SPACE_*). You can leave the keys empty; Strapi starts fine and everything except uploading media works. Ask a teammate for credentials if you need uploads, and setDO_SPACE_DIRECTORYto your own folder so you don't overwrite shared assets.
Then start it:
npm run developStrapi is now at http://localhost:1337/admin. On first visit it asks you to create an admin account (local only, pick anything).
The content-types (pages, sections, components, …) are part of this repository under
strapi/src. Strapi creates all tables on first start, so you do not need to create anything in the Content-Type Builder. Only content and settings are missing, see the next section.
A fresh database is empty. Seed it:
cd strapi && npm run seedRun on its own, the seed prints the API token once; copy it into nextjs/.env.local as STRAPI_API_TOKEN (./scripts/setup.sh does that for you, and nothing else writes env files). To do it by hand in the Strapi admin instead:
- Locales: Settings → Internationalization. The frontend supports exactly these five locales; add the missing ones (mind the upper-case region):
en(default),en-AU,nl,de-CH,de-DE. - API access: create an API token (Settings → API Tokens, type Read-only) and put it in
nextjs/.env.localasSTRAPI_API_TOKEN. Alternatively enablefindandfindOnefor every content type under Settings → Users & Permissions plugin → Roles → Public. - Content: create and publish a Homepage, Navigation menu and Footer entry per locale. The frontend only shows published entries (
status=published). It also expects every link URL in the menu and the footer social URLs (LinkedIn, GitHub, YouTube) to be filled in, even though Strapi marks them optional, otherwise the page fails with a < AC98 code>nullhreferror.
Open a second terminal:
cd nextjs
fnm use # or `nvm use`
npm install
npm run devThe site is at http://localhost:3000 (/ is the English homepage, other locales live under /nl, /de-ch, …).
nextjs/.env is committed and holds safe defaults, including STRAPI_API=http://localhost:1337/api. Put your own values in nextjs/.env.local (git-ignored, takes precedence). Things you may want there:
| Variable | Why |
|---|---|
STRAPI_API_TOKEN |
Alternative to opening up the Public role (see above) |
DRAFT_MODE_SECRET |
Same value as in strapi/.env; needed for previews |
ALTCHA_HMAC_KEY |
Needed to submit forms (openssl rand -hex 32) |
FORMSPARK_FORM_ID |
Form submissions; leave empty locally |
SENTRY_*, NEXT_PUBLIC_SENTRY_*, MATOMO_*, REDDIT_*, LINKEDIN_*, GOOGLE_ADS_* |
Monitoring/tracking; keep disabled (*_ENABLE_TRACKING=false) locally |
Optional: localias config in .localias.yaml serves the site as https://www.adfinis.test (brew install peterldowns/tap/localias, then localias start).
| Folder | Command | What |
|---|---|---|
strapi/ |
npm run develop |
Dev server with auto-reload and admin UI |
strapi/ |
npm run build |
Build the admin panel (run by CI) |
strapi/ |
npm run start |
Production server (no auto-reload) |
nextjs/ |
npm run dev |
Dev server |
nextjs/ |
npm run build |
Production build (run by CI) |
nextjs/ |
npx vitest run |
Run the unit tests once (npm test starts watch mode) |
nextjs/ |
npm run lint |
ESLint |
The repo ships .vscode/settings.json (works in VS Code and VSCodium): ESLint for both folders, Prettier on save and Tailwind class completion. Install the ESLint, Prettier and Tailwind CSS IntelliSense extensions.
- Branch from
developand open pull requests againstdevelop.mainis the release branch. - CI (
.github/workflows/ci.yml) runs the Next.js tests and build and the Strapi build on every pull request. Run the same locally before pushing. - Commit messages follow
type (AW-123): description; seeCHANGELOG.mdfor examples.
Every commit and every PR title follows Conventional Commits:
type(scope)!: description
| Type | Use it for | Version bump | Jira key as scope |
|---|---|---|---|
feat |
something new a visitor or editor can see or use | minor | required |
fix |
a bug fix, hotfixes included | patch | required |
perf |
faster or lighter, same behaviour | patch | required |
refactor |
code reorganised, same behaviour | patch | required |
style |
formatting only | patch | optional |
test |
tests only | patch | optional |
docs |
documentation only | patch | optional |
build |
dependencies, package.json, build setup |
patch | optional |
ci |
GitHub workflows | patch | optional |
chore |
other upkeep, e.g. the release commit | patch | optional |
revert |
undoing an earlier commit | patch | optional |
typeis lowercase and comes from the table. No space before(.scopeis one Jira key in capitals (AW-404) or one lowercase word (deps,release).!right before the colon marks a breaking change and makes the release a major one. So does a line startingBREAKING CHANGE:in the body.- A colon, then exactly one space.
- The description starts with a lowercase letter or a digit and doesn't end with a full stop.
- The whole first line is at most 100 characters.
- Messages starting with
Merge,Revert ",fixup!,squash!oramend!are not checked.
Examples: feat(AW-404): add google ads conversion api, fix(AW-406)!: move event dates to the new api, chore(deps): bump next.
npm install in nextjs/ or strapi/ switches on a git hook that refuses a commit in the wrong format. Pull requests into develop are checked the same way, title and every commit.
- Open Actions → Release → Run workflow on GitHub.
- Leave bump on
minor, or pickautoto take the version from the commits. A breaking commit always makes it a major. Tick dry run to see the result without changing anything. - The workflow adds a section to
CHANGELOG.mdwith every commit ondevelopsince the last release commit, raises the version in bothpackage.jsonfiles, commits that todevelopand opens a PR fromdeveloptomaincalledRelease x.y.z. - Read the PR and merge it with Squash and merge. The rules on
mainallow no merge commits.
Anything merged into develop while a release PR is open goes out with that release, but is missing from the changelog. The workflow stops if a release PR is already open, or if develop has a release commit that main doesn't have yet.
After a release PR is merged, the Back-merge workflow moves develop to the new commit on main. Commits merged into develop after the release PR are put back on top. So develop starts equal to main and the next release PR lists only new commits. This rewrites develop: run git fetch && git checkout develop && git reset --hard origin/develop before you branch from your local copy again.
After any other push to main, such as a hotfix, the Back-merge workflow merges main into develop. It stops without merging when main holds a revert, because that merge would undo the same work on develop. The Release workflow stops if develop lacks a commit from main; merge main into develop by hand when the Back-merge run failed.
- Strapi is the CMS and API. Content types are in
strapi/src/apiand reusable components instrapi/src/components. Schema changes that need data migrations go instrapi/database/migrations. - Next.js (App Router) renders the site from the Strapi API: routing under
nextjs/src/app/[locale], Strapi fetch helpers innextjs/src/lib/strapi.ts, page sections innextjs/src/components/sections. - PostgreSQL stores all content. Production and staging read their database settings from
strapi/config/env/. - Next.js caches Strapi responses by tag (see
TAGSinstrapi.ts). Strapi purges them by callingPOST /api/revalidate(protected byAuthorization: Bearer <REVALIDATE_SECRET>) from a webhook on every entry create, update, delete, publish and unpublish. The seed creates that webhook locally as "Revalidate nextjs cache" (Settings → Webhooks), pointing athttp://localhost:3000/api/revalidatewith the secret fromnextjs/.env; override the secret innextjs/.env.localand re-run./scripts/setup.shto sync it.
| Symptom | Fix |
|---|---|
Unsupported engine / weird build errors |
Wrong Node version. Run fnm use (or nvm use) in that folder. |
| Strapi starts with SQLite instead of Postgres | DATABASE_CLIENT=postgres missing in strapi/.env. |
Strapi: password authentication failed / ECONNREFUSED |
Container not running (docker ps), or the DATABASE_* values don't match the docker run flags. |
Site shows 404 everywhere; Strapi logs 403 |
STRAPI_API_TOKEN missing in nextjs/.env.local (re-run ./scripts/setup.sh), or nothing is published yet. |
Site shows a 500 mentioning href … null |
A menu URL or footer social URL is empty in Strapi (see Manual setup, step 3). Restart npm run dev afterwards, Next caches Strapi responses. |
| Site shows 404 for one locale | That locale is not created in Strapi or has no published content. Codes are case-sensitive: en-AU, not en-au. |
| Port 1337 / 3000 / 5432 already in use | Stop the other process, or the old container: docker ps. |
docker stop adfinis-website-postgres # stop (data is kept)
docker start adfinis-website-postgres # start again
docker rm -f adfinis-website-postgres # DELETE the container and all local contentAfter docker rm run ./scripts/setup.sh again; it recreates the container and re-seeds.
See LICENSE.