image
Akan.js
English
Docs (V1)
image
Akan.js
You are viewing the Akan.js v1 docs.Go to the latest v2 docs
Docs (V1)
Released under the MIT License
Official Akan.js Consulting onAkansoft
Copyright © 2026 Akan.js All rights reserved.
System managed bybassman
Introduction
• Quick Start
• How it works
• Practice a Workflow
Tutorials
• Show Details
• Modifying Status
• Interact in Service
• Displaying with Slice
• UX with Pages
• Using Scalar
• Using Insight
• Relate Data
System Architecture
• Overview
• Backend System
• Frontend System
• Environment Variables
• Primitive Scalar Types
• Domain Based Modules
• CSS
Module Convention
• Overview
• model.constant.ts
• model.dictionary.ts
• model.document.ts
• model.service.ts
• model.signal.ts
• model.store.ts
• Model.Template.tsx
• Model.Unit.tsx
• Model.Util.tsx
• Model.View.tsx
• Model.Zone.tsx
Scalar Convention
• Overview
• scalar.constant.ts
• scalar.dictionary.ts
• scalar.document.ts
Introduction
• Quick Start
• How it works
• Practice a Workflow
Tutorials
• Show Details
• Modifying Status
• Interact in Service
• Displaying with Slice
• UX with Pages
• Using Scalar
• Using Insight
• Relate Data
System Architecture
• Overview
• Backend System
• Frontend System
• Environment Variables
• Primitive Scalar Types
• Domain Based Modules
• CSS
Module Convention
• Overview
• model.constant.ts
• model.dictionary.ts
• model.document.ts
• model.service.ts
• model.signal.ts
• model.store.ts
• Model.Template.tsx
• Model.Unit.tsx
• Model.Util.tsx
• Model.View.tsx
• Model.Zone.tsx
Scalar Convention
• Overview
• scalar.constant.ts
• scalar.dictionary.ts
• scalar.document.ts
Next
Quick Start

Domain Module

A Domain Module is a standardized folder structure that encapsulates all code related to a single domain (e.g., User, Product, Order). It follows Domain-Driven Design principles to organize code around business domains rather than technical concerns.
Domain Module Structure
🎯Goal
The goal is to produce reusable UI components and business logic that can be used in Nest.js backend modules and Next.js frontend pages.

Module Architecture

Domain modules are divided into three categories: Common files (shared), Backend files, and Frontend files. This separation eliminates duplicate code declarations.
Data Flow
Common + Backend → MongoDB Model, Service Logic, Endpoint → Nest.js Module
Common + Frontend → Fetch Client, Flux Store, UI Components → Next.js Component
CategoryFilesOutput
Commonconstant, dictionary, signalType definitions, translations, API contracts
Backenddocument, serviceMongoDB models, business logic
Frontendstore, Template, Unit, View, Zone, UtilState management, UI components

Common Files

Common files are shared between backend and frontend. They must be written in pure JavaScript/TypeScript without platform-specific dependencies.
FileDescription
constant.tsDefines data schemas (Input, Object, Light, Full, Insight) and enums using the via() builder pattern.
dictionary.tsProvides multi-language translations for model names, field labels, enum values, API descriptions, and error messages.
signal.tsDefines API endpoints (queries, mutations, subscriptions) and their type contracts between frontend and backend.
Common files cannot import backend-only (mongoose, fs) or frontend-only (window, document) dependencies. Only @akanjs/base and @akanjs/common are allowed. Type imports are safe as they disappear during transpilation.

Backend Files

Backend files create MongoDB models, implement business logic, and are combined to create a Nest.js module.
FileDescription
document.tsCreates MongoDB Document/Model from constant schema. Defines database queries, filters, and data processing logic (Redis cache, text search, etc.).
service.tsImplements domain-specific business logic. Handles complex operations, validations, and interactions with other services.
Backend Data Flow

Frontend Files

Frontend files define state management, data fetching, and UI components for the domain.
FileTypeDescription
store.tsClientGlobal state management with Zustand. Defines domain-related state and actions.
Template.tsxClientForm components for Create/Update operations with integrated state management.
Unit.tsxServerCard/list item components for displaying multiple items. Uses LightModel for efficient rendering.
View.tsxServerDetail view components for single item display. Uses full Model with all properties.
Zone.tsxClientPage container components that compose Template, Unit, View into complete UI sections.
Util.tsxClientSpecialized utility components for domain-specific features (buttons, badges, etc.).
State Management
store.ts handles domain state and business logic on client.
UI Components
Template, Unit, View provide reusable UI patterns.
Container
Zone composes components into complete pages.

File Naming Convention

Akan.js follows a consistent naming convention to distinguish between different file types:
PatternExampleDescription
model.*.tsproduct.constant.tsLogic files (lowercase)
Model.*.tsxProduct.View.tsxReact components (PascalCase)
Complete Module Example

Domain Module Best Practices

1️⃣Keep Common Files Pure
Never import platform-specific code in constant.ts, dictionary.ts, or signal.ts. These files must work in both Node.js and browser environments.
2️⃣Use Appropriate Model Types
Unit.tsx uses LightModel (fewer fields, better performance). View.tsx uses full Model (all fields for detail display).
3️⃣Server vs Client Components
Unit.tsx and View.tsx are Server Components (no 'use client'). Template.tsx, Zone.tsx, and Util.tsx are Client Components (with 'use client').
4️⃣Organize by Domain
Keep all related files in the same folder. This makes it easy to understand and maintain the domain as a whole.
🎉 What You've Learned:
  • ✓ Domain module structure with 11 standardized files
  • ✓ Three categories: Common (shared), Backend, Frontend
  • ✓ Data flow from constant → document → service → signal
  • ✓ Frontend component hierarchy: Zone → Template/Unit/View
  • ✓ Naming conventions: lowercase.ts for logic, PascalCase.tsx for components
Domain Module
Module Architecture
Common Files
Backend Files
Frontend Files
File Naming Convention
Domain Module Best Practices