Backend System

The backend system is the foundation of your Akan.js application. Built on Nest.js, it provides a robust, scalable architecture for handling data storage, business logic, and API endpoints.
🏗️ Architecture Highlights
Each function has one Nest module, and these modules combine to form a server. Multiple servers form a cluster that provides high availability and scalability for your services.

Backend Module Structure

Each data model in Akan.js has its own dedicated module. This modular approach ensures clean separation of concerns and makes your codebase easy to maintain and extend.
image
Each module contains four key components that work together:
1Constant
Defines the data model schema, types, enums, and validation rules. This is the single source of truth shared between backend and frontend.
2Document
Handles MongoDB operations including CRUD, queries, filters, and document methods. Includes middleware hooks for pre/post operations.
3Service
Contains business logic and orchestrates operations. Supports dependency injection to access other services and external APIs.
4Signal
Exposes GraphQL endpoints (Slices and Endpoints) with automatic type generation, authentication guards, and rate limiting.

Server Cluster Structure

Akan.js servers operate in a cluster configuration with two distinct modes, each optimized for different workloads:
Federation Mode
Handles incoming requests from the frontend with horizontal scaling capability. Multiple containers can be deployed to distribute the load, ensuring high availability and responsiveness.
🔄Batch Mode
Runs as a single container in the cluster for scheduled tasks, queue processing, and security operations. Ensures consistent execution without race conditions.
image
Both server modes connect to shared infrastructure:
🗄️ MongoDB
Primary database for persistent data storage. Supports 1-3 database connections for sharding and replication.
⚡ Redis
In-memory cache for session management, real-time subscriptions, and shared state between server instances.

Request Handling

Understanding how requests flow through the backend helps you build efficient applications:
1
Query/Mutation Operations: Standard CRUD and custom operations are handled by Federation mode servers for optimal load distribution.
2
Queue/Batch Operations: Scheduled jobs, background processing, and queue tasks are handled by Batch mode for consistent execution.
3
Real-time Subscriptions: GraphQL subscriptions use Redis pub/sub to sync data across all Federation instances in real-time.
Released under the MIT License
Official Akan.js Consulting onAkansoft
Copyright © 2025 Akan.js. All rights reserved.
System managed bybassman