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

Types

PreviousNext

Single source of truth for a feature's TypeScript types.

types.ts holds DTOs, row shapes, form-step props, and component contracts for a feature. Never duplicated in content.tsx, columns.tsx, or actions.ts.

Categories

CategoryShapeReference
DTO + Row + FormPropsCompact listing types from Zod schemas (20–60 lines)listings/teachers/types.ts
Prisma extensionExtends Prisma models with relations using &finance/payroll/types.ts
Comprehensive domainFull coverage — data, filters, sort, props, responsessaas-dashboard/tenants/types.ts
Component propsPure React contracts (no DB, no Prisma)atom/<name>/types.ts

Rules

#Rule
1Single source of truth — share via src/lib/types.ts if cross-feature
2PascalCase for types, interfaces, enums
3Derive from Zod with z.infer — never hand-write a schema mirror
4Extend Prisma with Prisma.XxxGetPayload<{ include }>, never retype 90 fields
5Prisma.XxxWhereInput stays in queries.ts / actions.ts
6Stay under ~300 lines — split into types/student.ts etc.
7Import canonical ActionResponse from @/lib/action-response

Canonical example — DTO + Row + FormProps

import type { Teacher } from "@prisma/client"
import { z } from "zod"
 
import { teacherCreateSchema, teacherUpdateSchema } from "./validation"
 
export type TeacherDto = Pick<
  Teacher,
  "id" | "firstName" | "lastName" | "email" | "phone"
>
 
export type TeacherRow = TeacherDto & {
  classCount: number
  subjects: string[]
}
 
export type TeacherCreateInput = z.infer<typeof teacherCreateSchema>
export type TeacherUpdateInput = z.infer<typeof teacherUpdateSchema>
 
export interface TeacherFormProps {
  initialData?: TeacherDto
  onSuccess?: () => void
}

Prisma extension

import type { Prisma } from "@prisma/client"
 
export type PayrollWithRuns = Prisma.PayrollGetPayload<{
  include: {
    runs: { include: { lines: true } }
    school: { select: { id: true; name: true; currency: true } }
  }
}>

Anti-patterns

  • Duplicate ActionResponse (38+ files) — import from @/lib/action-response.
  • ExtendedUser redefined (5 files) — canonical is src/components/auth/user.ts.
  • PaginationParams redefined (10+ files) — lift to src/lib/types.ts.
  • Hand-written Prisma replicas — registration/types.ts had 486 lines retyping a Student. Use Prisma.StudentGetPayload<...>.
  • Row types diverging from columns — update types.ts, not columns.tsx.
  • any in types.ts (26 occurrences) — replace with inferred Zod or Prisma payload.
  • Inline type defs in content.tsx (268), columns.tsx (80), actions.ts (110) — move to types.ts.
  • Identical type files in different features — extract to src/lib/types.ts.

Naming

  • File: types.ts.
  • Suffix-coded: <Name>Dto, <Name>Row, <Name>Input, <Name>Props, <Name>Response, <Name>Filters.
  • One concept per name.

See also

  • Pattern
  • Validation
  • Queries
  • Actions
ContentConfig

On This Page

CategoriesRulesCanonical example — DTO + Row + FormPropsPrisma extensionAnti-patternsNamingSee also

Built by Databayt ·

Welcome to balqalam.

A great journey is about to begin.