Packages - shared repository for things like Authentication Adapter, and some re-usable components like pagination, etc
  • TypeScript 57.7%
  • Go 37.3%
  • CSS 4.8%
Find a file
arcanedemesne 99dd211618
Some checks are pending
Go test / test (push) Waiting to run
Add dev/stage/prod env support
2026-07-15 00:09:40 -04:00
.forgejo/workflows add new @arcanedemesne/ui package for reusable frontend components 2026-07-06 03:20:37 -04:00
api-client add/fix node_modules/sym_links 2026-07-14 16:30:41 -04:00
apibootstrap Consolidate API and UI components for re-use accross applications 2026-07-14 13:39:39 -04:00
authentication Add dev/stage/prod env support 2026-07-15 00:09:40 -04:00
dbpool entity sql helpers, dbpool wrapNotfound, httpx error mapping 2026-06-24 01:36:54 -04:00
entity entity sql helpers, dbpool wrapNotfound, httpx error mapping 2026-06-24 01:36:54 -04:00
forms Consolidate API and UI components for re-use accross applications 2026-07-14 13:39:39 -04:00
httpx Consolidate API and UI components for re-use accross applications 2026-07-14 13:39:39 -04:00
ide-deps Consolidate API and UI components for re-use accross applications 2026-07-14 13:39:39 -04:00
identityadmin Consolidate API and UI components for re-use accross applications 2026-07-14 13:39:39 -04:00
mail Consolidate API and UI components for re-use accross applications 2026-07-14 13:39:39 -04:00
pagination add dbpool, entity, httpx, pagination for api crud code re-use patterns 2026-06-23 09:50:56 -04:00
session add/fix node_modules/sym_links 2026-07-14 16:30:41 -04:00
shell add/fix node_modules/sym_links 2026-07-14 16:30:41 -04:00
types Consolidate API and UI components for re-use accross applications 2026-07-14 13:39:39 -04:00
ui Consolidate API and UI components for re-use accross applications 2026-07-14 13:39:39 -04:00
userprofile Consolidate API and UI components for re-use accross applications 2026-07-14 13:39:39 -04:00
.gitignore Consolidate API and UI components for re-use accross applications 2026-07-14 13:39:39 -04:00
.golangci.yml Consolidate API and UI components for re-use accross applications 2026-07-14 13:39:39 -04:00
go.work Consolidate API and UI components for re-use accross applications 2026-07-14 13:39:39 -04:00
Makefile Update Authentication for Admin, add IdentityAdmin Package fro interfacing with Idp (Authentik) and saving user info via API user, add UserProfile Package for reading user data from session for display 2026-06-27 22:06:16 -04:00
README.md Consolidate API and UI components for re-use accross applications 2026-07-14 13:39:39 -04:00
tsconfig.base.json Consolidate API and UI components for re-use accross applications 2026-07-14 13:39:39 -04:00

Local development

Use the monorepo go.work (HomeLab repo root):

cd ArcaneDemesne/HomeLab
go work sync
cd backend && make run

go.mod keeps replace for local packages until Forgejo serves correct go-import meta tags. Public deps use the module proxy; no vendor/.

Extraction bar

Shared Package only when ≥2 apps use nearly identical code. Domain stays in apps. Prefer thin app wrappers over forking Packages.

Go modules

Module Purpose
authentication/ OIDC BFF, session middleware, chi mount helpers, RequireActor for audit context
entity/ Embeddable AuditableEntity (UUID id, UTC audit fields, soft delete); NotDeletedFilter, DefaultListOrder; WithActor / NowUTC
pagination/ Page, Result[T], in-memory slice helper (tests/dev only); chi middleware in pagination/chi/
httpx/ JSON responses, StatusError, MapError, MapDomainErrors, ParseUUIDParam, DecodeJSON
dbpool/ pgx pool Open; generic helpers ListPage, GetOne, InsertReturning, ExecOne, WrapNotFound — entity SQL stays in app repos
userprofile/ Shared profile API types, PATCH validation, session identity merge; store layer when extracted; per-app user_profiles table
identityadmin/ IdP directory Admin API interface; identityadmin/authentik/ Authentik adapter
mail/ Transactional SMTP (SMTP_* env), NoopMailer when host unset
apibootstrap/ Shared health, migrate CLI helpers, standard chi middleware (when present)

Frontend packages

Source-only where noted; install peer deps in the consuming app. Docker builds copy Packages from monorepo root.

Package Purpose
@arcanedemesne/ui Components, tokens, ApiErrorStack, avatars, test/setup-domsource-only
@arcanedemesne/forms Zod field builders
@arcanedemesne/api-client Shared BFF HTTP (tls, client, cookies, errors, auth/profile helpers)
@arcanedemesne/session Session store, auth handlers, expiry monitor/modal/seed
@arcanedemesne/shell AppHeader / HeaderNavLink chrome slots

Fourth app checklist (e.g. SeedSlinger)

  1. Depend on ui, forms, api-client, session, shell (file: or workspace).
  2. Thin BaseLayout + header slots; internal apps: base.css + theme-surfaces.css (shared themes via tokens). Brand apps (Cup): base.css + themes/<app>.css.
  3. Go (if applicable): authentication + httpx + dbpool + entity; replace Packages; health via apibootstrap.
  4. Do not copy session/api-client/ui helpers into the app.

New Go API feature scaffold

Per entity under internal/{entity}/:

internal/{entity}/
  {entity}.go       # embed entity.AuditableEntity + domain fields
  repository.go     # CRUD interface using pagination.Page / Result[T]
  service.go        # use cases; validation; page.Normalize(...)
  handler.go        # chi routes + pagination/chi middleware + httpx
  postgres.go       # dbpool helpers + entity SQL + entity.NowUTC()
  memory.go         # in-memory repo (tests/dev)

Embed entity.AuditableEntity for UUID ids and UTC audit columns. Use entity.WithActor(ctx, userUUID) when auth is available; nil actor is safe for public routes.

Reference: HomeLab internal/article/.

Scale thresholds (sqlc, postgres Base embed): HomeLab/backend/REFACTOR.md.

Container builds

Compose builds from ArcaneDemesne/ context. The Dockerfile copies all Packages/* modules used by the app and runs go mod download for public modules.

When Forgejo module resolution works, remove replace from app go.mod, tag releases, and bump require versions.

Releases

Tag format: {module}/v0.x.y on Forgejo packages.

Examples: authentication/v0.1.2, entity/v0.1.1, pagination/v0.1.0, httpx/v0.1.1, dbpool/v0.2.1.