HenniOKF
Documentation

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

PathContent
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.tspublic reading and the sign-in requirement in front of all routes
instrumentation.tsthe 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.mdthe knowledge of the project for people and agents

lib/

FileTaskImportant
env.tsreads the environment with Zod, knows the root directory and its subdirectoriesENV, DIRS, root(), usersDir(), ensureDirs(), mainUrl(), NotConfigured
permissions.tsroles and permissions, runs in the browser tooROLES, Permission, can(), API_KEY_PREFIX, USERNAME, LIMITS
users.tsBetter Auth, first admin, accounts, keys, who sends a requestauth(), identify(), createAccount(), createFirstAdmin(), listAccounts(), protectLastAdmin(), createApiKey()
auth-client.tsBetter Auth in the browserauthClient
access.tsaccess to own routes, open pathsrequirePermission(), openPath(), isPageRequest()
page-access.tsaccess to pagespageRequires(), currentVisitor()
startup.tssetup at start, called from instrumentation.tsstart()
version.tsversion, commit, build timeVERSION, buildInfo()
docs.tsthe bundle docs/ as pages, links, images, table of contentsfiles(), page(), link(), imageLink(), docsToc()
image-size.tswidth and height of an image from its file headerimageSize()
ui.tsthe name of the application and the classes of the reading typeNAME, DOCS_PROSE
i18n/en.ts, i18n/de.tsthe words of the UI; English is the sourceen, de, Dictionary
i18n/index.tslanguages, cookie name, format()LOCALES, DEFAULT_LOCALE, LOCALE_COOKIE
i18n/server.ts, i18n/client.tsx, i18n/actions.tsthe language on the server, in client components, and the switchgetDictionary(), useI18n(), setLocale()

app/ and components/

FileTask
app/layout.tsxthe shell: header with menu and language switch, content, footer, metadata, <html lang>
app/page.tsxthe 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.tsxmenu of the header, link "Status" in the footer
components/locale-switch.tsxthe language switch in the header
components/settings.tsxthe tiles (areas())
components/sign-in-form.tsx, account-manager.tsx, user-manager.tsxthe forms, as client components
components/docs/markdown.tsxMarkdown of the docs as React elements

How a request runs

  1. proxy.ts checks 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-in and answers 401 otherwise.
  2. The page checks its permission with pageRequires(), a route of its own with requirePermission().
  3. 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 in lib/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 in lib/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 in app/globals.css. The origin is in HERKUNFT.md per package.
  • Prettier with line width 96. Markdown is excluded and stays formatted by hand.

Next: Recipes for extending.