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

Architecture

PreviousNext

Feature-based mirror pattern, multi-tenant by default, type-safe end-to-end. Serverless on Vercel + Neon.

Principles

  1. Component-driven — Radix primitives at the base, shadcn/ui atoms above, feature blocks at the top.
  2. Feature-based — every feature is a self-contained directory; routes mirror components 1:1.
  3. Serverless-first — Vercel + Neon Postgres, Edge runtime where Prisma isn't needed.
  4. Type-safe end-to-end — Prisma → Zod → TypeScript with no manual handoffs.
  5. Async-first — small PRs, documented decisions, steady progress.

Composition layers

  • Foundation: Radix UI → shadcn/ui → shadcn ecosystem.
  • Building blocks: UI → atoms → templates → blocks → micros → apps.

Mirror pattern

Every URL route produces two directories — one in app/ for routing and layouts, one in components/ for all feature logic. The 1:1 mapping means if you know the URL, you know where the code lives.

For route /abc:

  • app/[lang]/abc/ — page.tsx, layout.tsx
  • components/abc/ — content.tsx, actions.ts, form.tsx, validation.ts, types.ts, use-abc.ts, README.md
src/— Source code directory
app/— Next.js App Router (Routing & Layouts)
[lang]/— i18n support
abc/— URL route: /abc
page.tsx— Route entry point
layout.tsx— Route layout
components/— Component Logic (Mirrors app structure)
abc/— Mirrors app/[lang]/abc/
content.tsx— Page UI: headings, sections, layout
actions.ts— Server actions: validate, mutate
config.ts— Enums, option lists, defaults
validation.ts— Zod schemas & refinements
types.ts— Domain and UI types
form.tsx— Typed forms (RHF)
card.tsx— KPIs, summaries, quick actions
all.tsx— List view with table, filters
detail.tsx— Detail view with sections
column.tsx— Table column builders
use-abc.ts— Feature hooks
README.md— Feature purpose, APIs, decisions
ISSUE.md— Known issues and follow-ups
atom/— Atomic UI components
template/— Reusable layout templates
ui/— Base UI components (shadcn/ui)

Tech Stack

See /docs/stack for the canonical version table.

Standardized File Patterns

See /docs/pattern for the per-file canonical contract.

Decision Framework

  1. Mirror-Pattern First: Every new route in app/[lang]/ must have a mirrored directory in components/
  2. Component Reusability: Start with shadcn/ui components, extend only when necessary
  3. File Pattern Adherence: Use standardized file names (content.tsx, action.ts, etc.)
  4. Type-Safety Chain: Zod schemas → TypeScript types → Prisma models
  5. Serverless Compatibility: Default to Edge runtime unless Prisma/bcrypt required
  6. Feature Isolation: Each feature should be independently deployable and testable
  7. Progressive Enhancement: UI → Atoms → Templates → Blocks → Micro → Apps
  8. Developer Experience: Predictable structure, clear naming, documented decisions

Naming Conventions

See /docs/pattern for the canonical naming reference.

Critical Files Reference

FilePurpose
src/proxy.tsEdge middleware: subdomain detection, RBAC, URL rewriting, custom domains
src/auth.tsNextAuth: JWT callbacks, session management, redirect logic
src/auth.config.tsOAuth providers: Google, Facebook, Credentials
src/routes.tsRBAC matrix: role-based route protection
src/lib/rate-limit.tsRate limiting configs across routes
src/lib/tenant-context.tsTenant resolution with two-tier cache (Redis 5 min → in-memory Map 1 min)
src/components/catalog/setup.tsCatalog bridge: academic structure provisioning
src/lib/dns-service.tsDNS verification: multi-provider custom domains
src/lib/security-headers.tsCSP, HSTS, XSS protection
prisma/models/Prisma multi-file schema (see /docs/database)
CLAUDE.mdProject-wide architectural guidelines

Anti-patterns

  • Components not following mirror-pattern structure.
  • Monolithic components that should be decomposed.
  • Missing type-safety chain (Zod → TypeScript → Prisma).
  • Files not following standardized naming conventions.
  • Tight coupling between features.
  • Hardcoded values that belong in config.ts.
  • Direct database queries outside actions.ts / queries.ts.

Request lifecycle

  1. User interacts with form.tsx; submit triggers a server action from actions.ts.
  2. Payload is validated by the Zod schema in validation.ts.
  3. The action calls queries.ts or actions.ts, which use Prisma against Neon with the types from types.ts.
  4. Result streams back; a hook from use-abc.ts updates the UI.
LocalhostStructure

On This Page

PrinciplesComposition layersMirror patternTech StackStandardized File PatternsDecision FrameworkNaming ConventionsCritical Files ReferenceAnti-patternsRequest lifecycle

Built by Databayt ·

Welcome to balqalam.

A great journey is about to begin.