Architecture¶
The system is one Go program (package main, module github.com/nazimbistamamsiru/network-business-system) that renders HTML on the server. It uses no web framework and no JavaScript build step.
Layout¶
main.go: template functions,render(), the login and signup handlers, and route registration on anet/httpServeMux.- One file per area (
contacts.go,items.go,journals.go,payroll.go,crm_deals.go, …). Each file has the area's HTTP handlers first, then itsStoremethods, SQL and types under a// ---------- <Area> ----------marker. db.go: theStore, which wraps apgxpool.Pool. Every query method takes acontext.Contextfirst.schema.sql: the whole schema and its migrations, written so they can be run again (CREATE TABLE IF NOT EXISTS,ADD COLUMN IF NOT EXISTS). There's no migration tool, so add changes to the end of the file.templates/: each file defines one template by its file name.navbar.htmlholds the shared page shell, styles and scripts.locales/: translations keyed by their English text.packages.go: the list of packages (Core, extensions, modules) and what each owns: its URL paths, pages, permissions and journal types.
A request's path¶
withSessionlooks up the session cookie.withPackagesanswers "not found" for the paths of a package that's switched off.withActivityLogrecords each POST.- The route's guards run:
pageGuard(the page is switched on),requirePermissionoradminOnly,accessGuard(record scope, field rules, limits), andapprovalGate(the entry may need a verifier or approver first). - The handler runs. A POST redirects back with
?success=or?error=, and a GET callsrender().
Conventions¶
- Post, then redirect, then get. Errors go back to the page as
?error=. - Every logged-in route is registered through
pageRoutes, which adds the guards. - Pages use the shared components and colour tokens in
navbar.htmlandbase-styles.html.go run ./tools/uichecklists template lines that skip them.
CLAUDE.md in the repository root describes every area in detail.