Skip to main content

Almafrica System Architecture — n8n Workflow Documentation

Use the n8n workflow docs as a guided map instead of reading them all in one pass.

If you are trying to...Start withThen continue to
Understand the whole platform quicklyCross-Domain Flow MapQuick Index
Understand authentication, sync, and platform behavior01 — Auth & Authorization02 — Data Sync Engine, 09 — Notifications & Communication, 10 — Integration Architecture
Follow field operations end to end03 — Farmer Management05 — Production Cycle, 08 — Quality Assessment, 06 — Warehouse & Stock
Understand buyer and commercial workflows04 — Client & Order Lifecycle06 — Warehouse & Stock, 09 — Notifications & Communication
Understand campaigns and data collection07 — Campaigns & Surveys02 — Data Sync Engine, 10 — Integration Architecture
Translate n8n concepts back into real coden8n Node Type → Almafrica Component MappingAppendix A, Appendix B

How to Read This Documentation​

This documentation describes the Almafrica platform's architecture using n8n workflow concepts. Each business process is represented as a workflow with:

  • Trigger nodes — what starts the process (user action, timer, event)
  • Function nodes — business logic steps (services, validations)
  • Decision nodes — conditional branching (IF/Switch)
  • Data nodes — database reads/writes, API calls
  • Output nodes — final results, notifications, state changes

Every workflow has an ID like WF-AUTH-01 for cross-referencing between sections.

Diagram Conventions​

[Square brackets]  = Action/Function nodes
{Curly braces} = Decision/IF nodes
((Double parens)) = Trigger nodes
[[Double square]] = Database nodes
>Asymmetric] = Output/Result nodes

Solid arrows (-->) indicate normal flow. Dotted arrows (-.->) indicate error/fallback paths.


Domain Groups​

To keep the documentation easier to scan, the workflow set is organized into four groups:

  • Start here: overview, system context, and workflow conventions
  • Platform flows: authentication, sync, notifications, and integrations
  • Operational domains: farmer, client/order, production, warehouse, and quality workflows
  • Reference: node mappings and entity relationships

If you are onboarding a new teammate, the best order is: overview -> auth -> sync -> the operational domain they work on most.


System Context Diagram​


Cross-Domain Flow Map​


Mobile Offline Architecture​


n8n Node Type → Almafrica Component Mapping​

n8n Node TypeAlmafrica ComponentExample
Webhook TriggerAPI Controller endpointAuthController.Login → POST /api/auth/login
Schedule TriggerTimer-based serviceOfflineQueueProcessor (10s interval), Auto-pull heartbeat
Manual TriggerUser-initiated actionTap "Sync Now", Submit form
HTTP RequestMobile Dio HTTP callFarmerRemoteDataSource.createFarmer()
FunctionApplication Service methodAuthService.LoginAsync(), FarmerService.CreateFarmerAsync()
IFConditional checkConnectivityService.isConnected, user.requiresTwoFactor
SwitchMulti-branch routingSyncRunMode.toStrategy(), ActiveRoleManager.dashboardFor(roles)
SetDTO/Model transformationFarmer.toJson(), FarmerDto.FromEntity()
MergeParallel joinSyncCoordinator merging farmer + client + demand results
WaitDelay/backoffExponentialBackoffService.calculateDelay() (30s→5h)
LoopIterative processingMaster data sync (26 entity types), batch queue processing (5 items)
Error TriggerException handlerGlobalExceptionHandler, Result pattern failure path
Database (Read)SQLite SELECT / EF Core queryDatabaseHelper.query(), _context.Farmers.Where()
Database (Write)SQLite INSERT/UPDATE / EF Core saveDatabaseHelper.insert(), _context.SaveChangesAsync()
S3 UploadDigitalOcean SpacesDigitalOceanSpacesService.UploadAsync()
S3 (Chunked)Chunked upload serviceChunkedUploadService.uploadFile()
SignalRReal-time hubPermissionHub.SendPermissionsUpdated()
SMS SendAfrica's TalkingOtpService.SendOtpAsync()
Push NotificationFCM (stub)PushNotificationService (no-op placeholder)
NoOpSkip/passthroughStrategy paths that skip certain sync phases
CodeComplex inline logicConflict resolution field diff, permission matrix evaluation

Technology Stack​

LayerTechnologyPurpose
Backend APIASP.NET Core (.NET 8)REST API, business logic, auth
Backend DBPostgreSQLPrimary relational store
CacheRedisPerformance caching, session data
File StorageDigitalOcean Spaces (S3)Images, documents, attachments
Real-timeSignalRPermission broadcast WebSocket
SMS/OTPAfrica's Talking2FA, notifications
PushFirebase Cloud MessagingMobile push (stub)
MobileFlutter (Dart)Offline-first field app
Mobile DBSQLite (sqflite)Local storage, 80+ tables
Mobile StateProviderState management
WebNext.js (React/TypeScript)Admin dashboard
DeploymentDocker + CoolifyContainer orchestration

Quick Index​

I want to understand...Go to
Platform login, permissions, and role routing01 — Auth & Authorization
Offline-first synchronization and retries02 — Data Sync Engine
Farmer capture, draft handling, and approvals03 — Farmer Management
Client onboarding, demand capture, and orders04 — Client & Order Lifecycle
Production tracking from planting to harvest05 — Production Cycle
Warehouse intake, transfer, loss, and stock history06 — Warehouse & Stock
Campaign publishing, surveys, and response collection07 — Campaigns & Surveys
Quality checks and stock-in assessment flows08 — Quality Assessment
OTP, push notifications, and SignalR communication09 — Notifications & Communication
External providers, storage, and operational integrations10 — Integration Architecture
How n8n node types map back to codeAppendix A
Cross-system entities and schema relationshipsAppendix B

Workflow ID Reference​

PrefixDomainCount
WF-AUTHAuthentication & Authorization7
WF-SYNCData Sync Engine17
WF-FARMFarmer Management6
WF-CLIClient & Order Lifecycle6
WF-PRODProduction Cycle5
WF-STOCKWarehouse & Stock7
WF-CAMPCampaigns & Surveys5
WF-QAQuality Assessment4
WF-NOTIFNotifications & Communication4
Total61 workflows