Documentation Index
Fetch the complete documentation index at: https://grantmaster.dev/llms.txt
Use this file to discover all available pages before exploring further.
Engineering Standards and Style Guide
To maintain a high-velocity, high-quality codebase, all contributors to GrantMaster must follow these standards.
Canonical reference: CLAUDE.md at the project root is the single source of truth for conventions. This document summarizes the key points for onboarding.
Tech Stack (Current)
- Frontend: React 19, TypeScript, Vite 6.2
- Styling: Tailwind CSS 4, shadcn/ui (Radix UI primitives)
- State/Data: React Query (@tanstack/react-query), React Context, tRPC
- Forms: react-hook-form + Zod validation via
useZodForm - Backend: Firebase (Auth, Firestore, Storage, Functions)
- AI: Google Gemini via Genkit
- Testing: Vitest (unit), Playwright (E2E)
๐ป Clean Code Principles
- Self-Documenting Code: Variable and function names should explain why they exist and what they do.
- Bad:
c(g) - Good:
calculateGrantRemainingBudget(grantId)
- Bad:
- Small Functions: Functions should do one thing. If a function is longer than 30 lines, consider breaking it down.
- Early Returns: Avoid deeply nested
if/elseblocks. Return early wherever possible.
TypeScript & Types
- No
any: The use ofanyis strictly prohibited. Useunknownor a proper Interface/Type. - Interfaces vs Types:
- Use Interfaces for public APIs and data models (they are extendable).
- Use Types for unions, aliases, and complex conditional mappings.
- Discriminated Unions: Use these for managing complex states (e.g.,
type Status = 'loading' | 'success' | 'error').
โ๏ธ React Best Practices
- Functional Components: Class components are deprecated. Always use Functional Components with Hooks.
- Prop Destructuring: Always destructure props in the function signature.
- Key usage: Never use
indexas akeyfor list rendering if the list can be reordered or filtered. Use a unique ID.
๐ File Structure & Naming
- Components: PascalCase (
ProjectCard.tsx) - Hooks: camelCase with
useprefix (useProjects.ts) - Services: camelCase (
projectService.ts) - Types: PascalCase (
Project,Employee) - Feature-First Organization: Group code by feature, not by type.
- Good:
src/features/billing/components,src/features/billing/hooks. - Avoid:
src/components/billing,src/hooks/billing.
- Good:
๐งช Testing
- Test Behavior, Not implementation: Your tests should check that the user can do X, not that function Y was called with Z.
- Coverage: Target 80% coverage for core business logic (Services). 100% for utility functions.
๐ Commit Messages
We use Conventional Commits:feat:: A new feature.fix:: A bug fix.docs:: Documentation changes.style:: Changes that do not affect the meaning of the code (white-space, formatting).refactor:: A code change that neither fixes a bug nor adds a feature.test:: Adding missing tests or correcting existing tests.chore:: Changes to the build process or auxiliary tools.
๐ UI Conventions (Mandatory)
These rules ensure visual consistency. See CLAUDE.md for the full reference.Page Structure
- Always wrap page content in
<PageLayout>(@/components/ui/PageLayout) - Always use
<PageHeader>for page titles โ never manual<h1> - Tabs: Use
<PageTabs>โ render content externally, not via tabcontentprop - Organization context:
useTenant()from@/contexts/TenantContextโ notuseOrganization - Secondary navigation: Use
<SecondarySidebar>from@/components/ui/SecondarySidebar
Colors
- Neutral palette:
slate-*only โ nevergray-* - Primary actions:
primary-*tokens โ never hardcodeblue-* - Success:
emerald-*โ nevergreen-* - Error:
rose-*โ neverred-* - Warning:
amber-*
Components
- Buttons: Always use
<Button>from@/components/ui/buttonwithisLoading/loadingTextprops - Status indicators: Use
<StatusBadge>from@/components/ui/StatusBadgewithmapDomainStatus() - Non-status labels: Use
<Badge>from@/components/ui/badge - Cards: Use shadcn
Cardcomponents orCardVariants/StatCardโ never inline card styling - Tooltips: Use custom
Tooltipfrom@/components/ui/Tooltipwithcontentandsideprops - Icons:
lucide-reactonly
Forms
- Always use
useZodFormfrom@/hooks/useZodFormfor form handling (provides schema validation, toast notifications, error handling,handleSubmit/isSubmitting/isDirty) - Do NOT use
useValidatedForm(deprecated) - Use
<Input>,<Textarea>,<Select>from@/components/ui/โ never raw HTML inputs - Use
<FormField>,<FormSection>,<FormActions>,<FormGrid>for form layout
Typography
- Page title (h1):
text-3xl font-bold(via<PageHeader>) - Section heading (h2):
text-xl font-semibold text-slate-900 dark:text-white - Body:
text-sm text-slate-600 dark:text-slate-400