Reference
Structure of the code
The commands for development and checks and every directory and important file with its task.
Commands
npm run dev # http://localhost:3370, reads .env.local
npm run check # Prettier, ESLint, types, Vitest
npm run test:e2e # builds itself and starts on port 3371
npm run rename -- <Name> <Port> # name and port of a project from the template
All commands are listed under Commands.
Where things are
| Path | Content |
|---|---|
app/ | pages and routes after the App Router |
components/ | building blocks of the UI |
lib/ | the logic: environment, permissions, users, access, docs, version |
lib/i18n/ | the dictionaries en.ts and de.ts and the helpers for the language |
proxy.ts | public reading and the sign-in requirement in front of all routes |
instrumentation.ts | the setup at server start |
vendor/henni/ | copies of design tokens, UI and core from HenniDev, byte-identical to the source |
public/ | icons, manifest, images of the tiles |
docs/ | this documentation |
tests/, e2e/ | Vitest and Playwright |
docker/ | image, Compose, backup |
.github/workflows/ | Check, Browser tests, Image |
scripts/ | rename.mjs |
SPEC.md, spec/ | the specification |
AGENTS.md, CLAUDE.md, context/, Findings.md | the knowledge of the project for people and agents |
lib/
| File | Task | Important |
|---|---|---|
env.ts | reads the environment with Zod, knows the root directory and its subdirectories | ENV, DIRS, root(), usersDir(), ensureDirs(), mainUrl(), NotConfigured |
permissions.ts | roles and permissions, runs in the browser too | ROLES, Permission, can(), API_KEY_PREFIX, USERNAME, LIMITS |
users.ts | Better Auth, first admin, accounts, keys, who sends a request | auth(), identify(), createAccount(), createFirstAdmin(), listAccounts(), protectLastAdmin(), createApiKey() |
auth-client.ts | Better Auth in the browser | authClient |
access.ts | access to own routes, open paths | requirePermission(), openPath(), isPageRequest() |
page-access.ts | access to pages | pageRequires(), currentVisitor() |
startup.ts | setup at start, called from instrumentation.ts | start() |
version.ts | version, commit, build time | VERSION, buildInfo() |
docs.ts | the bundle docs/ as pages, links, images, table of contents | files(), page(), link(), imageLink(), docsToc() |
image-size.ts | width and height of an image from its file header | imageSize() |
ui.ts | the name of the application and the classes of the reading type | NAME, DOCS_PROSE |
i18n/en.ts, i18n/de.ts | the words of the UI; English is the source | en, de, Dictionary |
i18n/index.ts | languages, cookie name, format() | LOCALES, DEFAULT_LOCALE, LOCALE_COOKIE |
i18n/server.ts, i18n/client.tsx, i18n/actions.ts | the language on the server, in client components, and the switch | getDictionary(), useI18n(), setLocale() |
app/ and components/
| File | Task |
|---|---|
app/layout.tsx | the shell: header with menu and language switch, content, footer, metadata, <html lang> |
app/page.tsx | the start page |
app/sign-in/ | sign-in and first admin, with the server action createFirstAdminAction |
app/account/ | the own account |
app/settings/ | the tiles of the administration |
app/users/ | the user management, with its server actions in actions.ts |
app/status/ | the status page |
app/docs/, app/docs-image/ | the documentation and its images |
app/api/auth/ | the API of Better Auth |
components/menu.tsx | menu of the header, link "Status" in the footer |
components/locale-switch.tsx | the language switch in the header |
components/settings.tsx | the tiles (areas()) |
components/sign-in-form.tsx, account-manager.tsx, user-manager.tsx | the forms, as client components |
components/docs/markdown.tsx | Markdown of the docs as React elements |
How a request runs
proxy.tschecks whether the path is open. If not, whether the instance is configured and who sends the request. Without signing in it redirects a page to/sign-inand answers 401 otherwise.- The page checks its permission with
pageRequires(), a route of its own withrequirePermission(). - Server components read and render, with the dictionary of the request. Client components exist only for interaction.
Rules in the code
- Words of the UI are in
lib/i18n/en.ts, with the same keys inlib/i18n/de.ts. English is the source. Messages of the API and the logs stay English in the code. See Texts in two languages. - Permissions live only in
lib/permissions.ts, the environment only inlib/env.ts. - Language: identifiers, comments and documentation English, file names lowercase with hyphens.
vendor/stays byte-identical to the source. Adjustments happen from outside, for example inapp/globals.css. The origin is inHERKUNFT.mdper package.- Prettier with line width 96. Markdown is excluded and stays formatted by hand.
Next: Recipes for extending.