0%
balqalam Logo
balqalam
FeaturesCommunityPricingDocumentation
Login
  • Introduction
  • Pitch
  • Hogwarts
  • Live Demo
  • MVP
  • Roadmap
  • Launch Sprint
  • PRD
  • Get Started
  • Localhost
  • Architecture
  • Structure
  • Pattern
  • Page
  • Layout
  • Content
  • Types
  • Config
  • Actions
  • Queries
  • Authorization
  • Validation
  • Form
  • Table
  • Detail
  • Card
  • Util
  • Hooks
  • List Params
  • Views
  • README.md
  • ISSUE.md
  • Technology Stack
  • Database
  • File
  • CDN Assets
  • Entry Points
  • Dashboard
  • Authentication
  • Credentials
  • OAuth
  • Flow Diagrams
  • Multi-Tenancy
  • Offline
  • Onboarding
  • Onboarding Videos
  • Add Values
  • Admission
  • Application
  • Attendance
  • Compliance
  • Profile
  • Exams
  • Exam Wizard
  • Timetable
  • Classrooms
  • Notifications
  • Conference
  • LMS (Lumos)
Finance
  • Finance
  • Fee Management
  • Invoice
  • Wallet
  • Salary
  • Payroll
  • Timesheet
  • Expenses
  • Budget
  • Receipt
  • Accounts
  • Banking
  • Reports
  • Dashboard
  • Permissions
  • Messages
  • Integration Flow
  • Provision
  • AI Document Processing
  • Document Intelligence
  • Internationalization
  • Translation
  • Translation Guide
  • Icons
  • Docs Factory
  • Inspiration
  • Listings
  • Teachers
  • Students
  • Catalog
  • Library
  • Contributing
  • Code of conduct
  • GitHub Workflow
  • Database Seeds
  • Database Safety
  • Test Accounts
  • Playwright
  • Prettier
  • Block Rebound
Sales & GTM
  • Marketing Brief
  • Sales
  • Go-to-market
  • Marketing
  • Admission — Feature Spotlight
  • Pilot Program
  • Leads
  • Proposal
  • Outreach Templates
  • Case Study
  • Competitors
  • Landing-page teardown
  • Competitor FAQ
  • Business model
  • Shared economy
  • Traction
Fundraising & Ecosystem
  • Get Support
  • Investor Deck
  • Data Room
  • Investors
  • Accelerators
  • Incubators
  • Grants
  • Sponsors
  • Partners
  • Competitions & Hackathons
  • Universities & Training Centers

Pattern

PreviousNext

Naming, file conventions, mirror pattern, and code shapes used across the Hogwarts codebase.

Consistency is the foundation. Every feature follows the same shape; every file has a canonical role. New code that matches these patterns is reviewable in minutes; new code that doesn't is friction.

Naming

Files and folders

  • Components, files — kebab-case (button.tsx, user-profile.tsx).
  • Routes — kebab-case segments (/user-profile, /sign-in).
  • Hooks — use- prefix (use-leads.ts).
  • Types — PascalCase identifiers (interfaces, type aliases, enums).
  • Constants — UPPER_SNAKE_CASE for primitives, camelCase for object literals.

Identifiers in code

  • Components — PascalCase (export function UserCard()).
  • Functions — camelCase (formatCurrency).
  • Variables — camelCase (const userData = ...).
  • Constants — UPPER_SNAKE_CASE (const API_BASE_URL = "...").
  • Types and interfaces — PascalCase (interface UserData, type ApiResponse).

Database and API

  • Tables — snake_case (user_profiles).
  • API routes — kebab-case (/api/user-profile).
  • Environment variables — SCREAMING_SNAKE_CASE (DATABASE_URL).

Function patterns

Use function declarations for components, API route handlers, and exported functions — they hoist and produce better stack traces. Use arrow functions for short utility callbacks.

// utility — arrow is fine
const formatPrice = (amount: number) =>
  new Intl.NumberFormat("en-US", { style: "currency", currency: "USD" }).format(amount)
 
// component — function declaration
export function UserProfile({ userId }: Props) {
  const { user, loading } = useUser(userId)
  if (loading) return <Skeleton />
  return <Card>{user.name}</Card>
}

Server actions and data fetching

  • Mutations live in actions.ts with "use server" at the top.
  • Reads live in queries.ts. Pure server functions, no "use server" needed unless called from client.
  • Every server action runs the 5-step flow: auth → tenant → permission → validate → execute + revalidate.
  • Server actions return ActionResponse<T> from @/lib/action-response.
  • Server components fetch via queries.ts and pass data to client components as props.

Component hierarchy

LevelNameDescriptionExample
1UIRadix primitivesDialog, Tabs
2Atom2+ primitives composedLabeledInput
3TemplateFull-page layoutWizardLayout
4BlockUI + business logicStudentsTable
5MicroMini service / standalone widgetBellIcon

Mirror pattern

Every URL produces two directories — one in app/ (routing, layouts, page.tsx), one in components/<feature>/ (everything else). Read the architecture doc for the full mapping.

src/app/[lang]/s/[subdomain]/(school-dashboard)/students/page.tsx
  → imports from src/components/school-dashboard/listings/students/content.tsx

Standard file patterns per feature

FilePurposeDoc
page.tsxRoute entry. Auth + tenant + render <XxxContent />. Thin.page
content.tsxServer (data fetching) or client (interaction) — composes the feature.content
client.tsxSingle "use client" boundary; receives server data as props.content
actions.tsServer actions — mutations only.actions
queries.tsServer-side database reads.queries
authorization.tsRBAC permission checks (canCreate, canRead, …).authorization
validation.tsZod schemas + z.infer types.validation
types.tsDomain and UI types.types
config.tsEnum option arrays, labels, defaults.config
form.tsxClient. Renders inputs, runs RHF + Zod, submits to a server action.form
table.tsxClient. Wraps the DataTable atom with feature columns.table
columns.tsxClient. Column definitions; uses useMemo if hooks are involved.table
card.tsxKPI / summary cards.card
detail.tsxDetail page composition.detail
views.tsxView toggles (grid / list / kanban).views
list-params.tsURL search-param cache (nuqs).list-params
util.tsPure feature helpers.util
hooks.ts / use-<x>.tsFeature hooks.hooks
README.mdBlock-level context (decisions, danger zones).readme
ISSUE.mdOpen issues, completed log.issue

The full canonical content per file lives in the linked doc — this page is the index.

Multi-tenant rules

  • Every business model carries schoolId.
  • Every database query is scoped by schoolId. Missing schoolId = data leak.
  • getTenantContext() is the source of truth for the current schoolId.
  • Subdomain detection happens in middleware; tenant context resolves it.

See Multi-Tenancy for the full architecture.

TypeScript

  • Strict mode on. No any, no as any.
  • import type for type-only imports.
  • Derive types from Zod via z.infer. Derive Prisma row types via Prisma.XxxGetPayload.
  • Discriminated unions for state machines (ActionResponse<T>, wizard step state).
  • enum only when the values cross runtime boundaries; otherwise prefer string literal unions.

Styling

  • Tailwind 4 with OKLCH tokens.
  • Semantic HTML — no hardcoded text-* / font-* in feature code; trust the renderer.
  • Theme-aware tokens only — text-foreground, bg-card, border-border. No hex.
  • Logical properties for RTL — ms-, me-, ps-, pe-, start-, end-. Never ml-, pl-, left-, right-.

Error handling

  • Server actions return errorCode, never English strings. The dictionary maps them on the client.
  • Never throw to the client. Catch in the action and return a structured response.
  • error.tsx boundaries handle component-tree exceptions.
  • console.error for server-side diagnostics; never console.log in shipped code.

Performance

  • Server components by default; "use client" only when needed.
  • Parallelise independent awaits with Promise.all.
  • revalidatePath after mutations.
  • Wrap expensive computations in useMemo; wrap stable callbacks in useCallback only when measured.
  • Lumos where possible — Suspense boundaries inside server components.

Adoption

When adding new code:

  1. Pick the closest existing feature directory and copy its shape.
  2. Match the naming and file set exactly.
  3. Resist the urge to invent a new file (utils.ts, helpers.ts); use the canonical names.
  4. If something genuinely doesn't fit, add a note in README.md so the next person knows why.
StructurePage

On This Page

NamingFiles and foldersIdentifiers in codeDatabase and APIFunction patternsServer actions and data fetchingComponent hierarchyMirror patternStandard file patterns per featureMulti-tenant rulesTypeScriptStylingError handlingPerformanceAdoption

Built by Databayt ·

Welcome to balqalam.

A great journey is about to begin.