Skip to main content
Every GatoJS project starts with five features in src/features/. Together they cover sign-in, organizations, user management, the account page and an empty dashboard for your own content. This page lists what each one contains, so you know where to look before you change it.

Overview

Pages live in src/app/[locale]/, not in the feature folders, because the App Router owns routing. No core feature imports another feature’s code. They meet only in a few composition points: The services/ folders of auth, organizations and users are security code (sign-up, organizations, roles, invitations). They are listed as critical in mutation-gate.json, so a surviving mutant there blocks the mutation gate. See Testing.

Server actions and the service-mode contract

A command on organization data follows a fixed contract: signature (input: unknown, confirmation?: unknown), a call to assertServiceModeConfirmed(context, confirmation) right after getOrgContext() or requireModuleAccess() and before Prisma, and a call from the UI through useServiceModeAction().run. This makes a superadmin confirm every change in an organization they do not belong to. See Superadmin and service mode. The core has five server actions. One of them falls under the contract:
New commands you write on organization data should follow the contract. The architecture test enforces assertServiceModeConfirmed before Prisma in every "use server" function that calls getOrgContext or requireModuleAccess. See Code patterns.

auth

Sign-in, sign-up and passwords: the forms of the (auth) pages, the change-password form, the change-password action and the sign-up gate called from a better-auth hook. Flows are described in Auth and roles. Module definition: key: "auth", nav: [], public: true. No page calls requireModuleAccess("auth"), so the definition has no runtime effect. The (auth) pages work without a session because they call no guard, not because of public.

Pages

The (auth) layout only centers the content. These pages do not check the session, so a signed-in user also sees the forms.

Components

All are client components in src/features/auth/components/ that call better-auth through authClient.

Contracts and services

Zod schemas in contracts/auth.schemas.ts (signInSchema, signUpSchema, forgotPasswordSchema, resetPasswordSchema, changePasswordSchema) validate forms in the browser. On the server, better-auth validates the data, including the minimum password length of 8.

organizations

The organization switcher, the invitation page, the no-organization page, the members view for organization roles, and the membership created at sign-up. The data model and active organization are covered in Organizations. Module definition: key: "organizations", nav: [], public: true. Like auth, no page reads it.

Pages

Both pages sit outside (app), so they do not require an active organization and have no sidebar.
/accept-invitation/<id> is the only core page that changes data in page.tsx, on page load. New code should do this in a server action instead. See Code patterns.

Components

CreateOrganizationForm and OrganizationMembers change data through better-auth endpoints (authClient.organization.*), not kit commands, so they show no service-mode dialog.

Commands, queries and services

users

Accounts seen through the global role: the list of all accounts, Invite user and impersonation. The same /users page shows the Members view from organizations to accounts with the global role user.
src/features/users/module.ts
Global admin and superadmin always have access. Organization roles get access only with MULTI_ORG=true, and only owner and admin; for them the menu label switches to Members. A member never gets this page.

Page

/users calls requireModuleAccess("users"), then picks a view by global role:
  • admin or superadmin: getUserAccountsQuery() and UsersManager.
  • Everyone else (organization owners and admins in multi-org mode): getOrganizationMembersQuery() and OrganizationMembers.

Components

The role badge for superadmin reads “Service (Web Amigos)” in the kit’s translations. Rename it in src/features/users/i18n/*.json (role-superadmin) to the name of your own team.

Actions and queries

getUserAccountsQuery does not filter by organizationId: an account belongs to the whole app, not to an organization, and only global admins see this list.
The impersonation log entry is written only when the UI calls the log action. Impersonating through the better-auth endpoint directly, bypassing the UI, leaves no entry.

account

The signed-in user’s account page. AccountDetails({ name, email }) is a server component showing the name and email; the change-password form comes from auth. There is no form to change the name or email. Module definition: key: "account", one nav item (/account, icon user-cog, order 90). No role restrictions, so every account with an active organization can open it. The sidebar’s user menu also links to /account.

dashboard

The start page after sign-in. DashboardPlaceholder({ userName }) shows a heading, “Welcome, <name>” and “Your application content will appear here.” Replace it with your own content. Module definition: key: "dashboard", one nav item (/dashboard, icon layout-dashboard, order 10). No role restrictions.
/dashboard is hard-coded as the destination in six places. If you change the start page, update all of them: SignInForm, the accept-invitation page (APP_HOME_PATH), the no-organization page, EnterOrganizationList, CreateOrganizationForm and UsersManager.

Shared parts

Code in src/shared/ and src/components/ui/ belongs to the core module but is not a feature: every feature uses it. src/shared/components/app-sidebar.tsx (client component) exports SidebarProvider, useSidebar(), MobileHeader and AppSidebar({ accessContext, userName, userEmail }). Menu entries come from module definitions, not from this file: you add one with a nav item in module.ts. The layout passes the roles from the organization context and MULTI_ORG, so the menu shows exactly what requireModuleAccess allows.

Service mode UI

src/shared/components/service-mode/:

Project name

src/shared/config/project.ts
create fills this in. name is used for the page title, the sidebar header, email templates and the default first organization name in admin:create. slug names the logger and the default OpenTelemetry service.name. The email sender is separate, in EMAIL_FROM.

Types and utilities

UI components

src/components/ui/ holds shadcn/ui-style components built on @base-ui/react primitives (style base-nova in components.json), plus DataTable on TanStack Table, Toaster on sonner and a cmdk command menu. Two behaviors that are easy to assume otherwise:
  • form.tsx is not bound to react-hook-form. It provides layout pieces (FormField, FormLabel, FormError, FormHint). Forms wire fields to useForm themselves with register or Controller.
  • DataTable does not paginate on its own. Without pagination it shows all rows and sorts them client-side. With pagination, sorting and paging belong to the caller (manualSorting, manualPagination). Column visibility is remembered in localStorage only if you pass storageKey.