@africode/core
v5.0.8
Published
Bun-native full-stack framework with generative AI, fintech compliance, and real-time performance - built for Tanzanian digital economy
Maintainers
Readme
🌍 AfriCode v5.0.0 — The Design System of Sovereignty
Autonomous Framework for African Digital Economy
Bridging AI safety, fintech compliance, and cultural heritage through high-performance web architecture.
Overview
AfriCode v5.0.0 is an autonomous full-stack framework that "owns" the application lifecycle. Built on Bun runtime with TypeScript-first architecture, it provides AI-safe component generation, comprehensive fintech compliance, and zero-downtime infrastructure for the African digital economy.
Strategic Vision: From Tanzania to the Continent
Following the rollout framework, AfriCode v5.0.0 implements a phased Pan-African expansion:
- Phase 1 (Months 1-4): Silicon Dar foundation with TIPS integration
- Phase 2 (Months 5-9): East African Corridor (Kenya, Uganda, Rwanda)
- Phase 3 (Months 10-15): West African Hub (Nigeria, Ghana)
- Phase 4 (Months 16-24): Continental governance and sustainability
✨ Autonomous Features
🤖 AI-Safe Architecture (A2UI Protocol)
- Robot-First Manifest: Machine-readable component catalog prevents hallucinations
- Ethnomathematical Patterns: Procedural generation of Kente, Ndebele, Shuka motifs
- Schema Validation: Pre-approved components with usage hints and constraints
🔐 Fintech Compliance "Hardening"
- NIDA CIG Bridge: VPN-tunneled identity verification with Ed25519 cryptography
- TIPS Integration: Bank of Tanzania-compliant payment flows
- AML/FIU Reporting: Automated regulatory compliance and transaction logging
⚡ Zero-Downtime Infrastructure
- File-Based Routing: Automatic
/pagesto URL mapping with dynamic routes - Enhanced HMR: Session preservation during hot reloads
- Bun-Native Runtime: 5ms startup with WebSocket orchestration
🎨 Cultural Resonance
- 33+ Web Components: African-themed UI elements with cultural semiotics
- Procedural SVG Engine: Fractal geometry for traditional patterns
- Mobile-First Design: Optimized for African connectivity constraints
- Native UI Kit: Shadcn-style Web Components like
af-ui-button,af-ui-card, andaf-ui-inputfor consistent app UI
🚀 Quick Start
Create Autonomous Project
# Install globally via NPM
npm install -g @africode/core
# Create new project
create-africode my-app
cd my-app
# Install dependencies
bun install
# Start autonomous development server
bun run devProject Structure (Autonomous)
my-app/
├── src/
│ ├── server.ts # Autonomous server entry
│ ├── pages/ # File-based routes
│ │ ├── index.ts # Home page
│ │ └── api/ # API routes
│ ├── components/ # Custom components
│ └── core/ # Framework extensions
├── public/ # Static assets
├── package.json # NPM configuration
├── tsconfig.json # TypeScript config
└── catalog.json # A2UI component manifestAI-Safe Development
The published package includes the agent guidance files so AI assistants can discover the framework rules when the package is installed. These files are bundled as AGENTS.md and AGENT_INSTRUCTIONS.md.
// pages/index.ts
import { html } from '@africode/core';
export default function Home() {
return html`
<af-app>
<af-navbar>
<h1 slot="brand">My AfriCode App</h1>
</af-navbar>
<main>
<af-hero>
<h1>AI-Safe Fintech</h1>
<p>Built with cultural patterns</p>
<af-kente-pattern complexity="3"></af-kente-pattern>
</af-hero>
</main>
</af-app>
`;
}🏗️ Architecture
Core Modules
| Module | Purpose | Status |
|--------|---------|--------|
| src/index.ts | Main framework entry | ✅ Complete |
| core/a2ui-schema-manager.js | AI component catalog | ✅ Enhanced |
| core/nida-cig-middleware.js | Identity verification | ✅ VPN + Crypto |
| core/lipa-namba-journey.js | Payment primitives | ✅ BoT Compliant |
| core/file-router.js | File-based routing | ✅ Dynamic routes |
| core/enhanced-hmr.js | Zero-downtime HMR | ✅ Session preservation |
Cloud Infrastructure
AMD AI Cloud (Intelligence Layer)
- MI300X GPUs: 192GB HBM3 for LLM inference
- $100 Credits: 200 hours on RunPod community cloud
- AfriCode-Coder Model: Fine-tuned for Tanzanian fintech law
Alibaba Cloud (Asset Layer)
- Model Studio: Qwen3-Max for complex reasoning
- Free Tier: 1M tokens for initial rollout
- Batch Inference: 50% cost reduction for production
🔧 CLI Commands
# Development
africode dev # Start dev server with HMR
africode build # Production build
africode lint # Code quality checks
# AI Integration
africode generate a2ui # Update component catalog
africode generate patterns # Regenerate cultural patterns
# Fintech
africode migrate # Run database migrations
africode audit # Security and compliance audit🎭 Ethnomathematical Patterns
AfriCode v5.0.0 incorporates traditional African geometric principles:
Kente Weaving (Glide Reflection)
import { generateKente } from '@africode/core';
const pattern = generateKente({
baseColor: '#8B4513',
accentColor: '#DAA520',
complexity: 3
});Ndebele Fractals (Recursive Geometry)
const ndebele = generateNdebele({
recursionDepth: 4,
symmetry: 'rotational',
colors: ['#FF6B6B', '#4ECDC4', '#45B7D1']
});🔒 Fintech Compliance
NIDA Identity Verification
import { NIDAClient } from '@africode/core';
const nida = new NIDAClient({
vpnEnabled: true,
endpoint: 'https://api.nida.go.tz/cig'
});
const result = await nida.verifyNIN('12345678901234567890', 'PIN');TIPS Payment Processing
import { LipaNambaJourney } from '@africode/core';
const journey = new LipaNambaJourney();
const payment = await journey.executeFullJourney({
merchantId: 'MERCHANT_001',
customerPhone: '255712345678',
amount: 50000
}, customerIdentity, confirmationData);🌐 Pan-African Expansion
Phase 1: Tanzania Foundation
- TIPS Integration: Real-time payment processing
- NIDA Compliance: Identity verification for KYC
- Cultural Patterns: Swahili language support
Phase 2: East African Corridor
- PAPSS Bridge: Cross-border settlement
- Regional Hubs: Nairobi, Kampala, Kigali
- Agri-Fintech: Supply chain integration
Phase 3: West African Powerhouse
- NIBSS Integration: Nigerian payment systems
- Kente Patterns: Ghanaian cultural motifs
- Enterprise Adoption: Large corporate clients
🤝 Community & Incentives
AfriCode Pioneer Bounty Program
- Bug Fixes: $50-200 for confirmed issues
- Features: $300-1500 for new capabilities
- Performance: $100-500 for optimizations
- Cultural Assets: $50-300 for pattern designs
Developer Hubs
- Silicon Dar: Dar es Salaam tech district
- iHub Nairobi: East African innovation
- CcHUB Lagos: West African powerhouse
- GDG Network: Google Developer Groups across Africa
📊 Performance Metrics
- Startup Time: <5ms (Bun-native)
- Bundle Size: <100KB (tree-shaken)
- Lighthouse Score: 95+ (mobile-first)
- TIPS Transactions: 490M+ annually supported
- NIDA Verifications: Real-time with VPN security
📚 Documentation
🤝 Contributing
We welcome contributions that align with our Pan-African vision:
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure AI-safety compliance
- Submit a pull request
📄 License
Dual License:
- Open Source: AGPL v3.0 for community projects
- Commercial: Available for enterprise deployments
🌟 Acknowledgments
Built for the African developer community with support from:
- Bank of Tanzania (TIPS infrastructure)
- National Identification Authority (NIDA systems)
- AMD AI Cloud ($100 credits for AI development)
- Alibaba Cloud (Model Studio free tier)
- African Export-Import Bank (PAPSS coordination)
"Designed for Tanzanians by Tanzanians, Built for Africans by Africans"
🇹🇿🇰🇪🇺🇬🇷🇼🇳🇬🇬🇭🇿🇦🇲🇦
Local Development (Framework Contributors)
If you are developing the framework itself:
- Clone and navigate to the framework directory
- Register the link:
bun link - Use in another project:
bun link africode - Run validation:
bun scripts/validate-fresh-install.js
Usage (SDK)
Import the core SDK to generate patterns, use the state engine, or handle routing:
import { patterns, store, components } from 'africode';
import { FileSystemRouter } from 'africode/core/router.js';
// Generate a Maasai Shuka pattern
const shukaPattern = patterns.generateShuka();
document.body.style.backgroundImage = `url("${shukaPattern}")`;
// Use Global State
store.ui.theme = 'tanzania';
store.ui.theme; // 'tanzania' - triggers effects on change
// Use File-Based Routing
const router = new FileSystemRouter('./pages');
const route = await router.matchRoute('/users/123');
// { page, params: { id: '123' }, path: '/users/[id]' }Usage (Authentication)
AfriCode includes built-in session-based authentication:
// API endpoints (automatically available)
POST / api / auth / register; // { email, username, password, fullname }
POST / api / auth / login; // { email/username, password }
POST / api / auth / logout; // Clears session
GET / api / auth / me; // Current user (requires session)
POST / api / auth / refresh; // Extend session expiryPasswords are hashed with Argon2id (built into Bun), sessions use HttpOnly cookies with SameSite=Strict protection.
Usage (UI Components)
Simply import the components to register them as Custom Elements:
import 'africode/components';Then use them in your HTML:
<af-navbar theme="tanzania" logo="My App"></af-navbar>
<af-kanga-card proverb="Haraka haraka haina baraka.">
<h3>Project Title</h3>
<p>Content goes here...</p>
</af-kanga-card>
<af-button onclick="handleClick()">Click Me</af-button>Native AfriCode UI Kit
AfriCode now includes a native UI kit with shadcn-inspired Web Components for rapid interface design. The Tailwind starter demonstrates the new UI kit using components like af-ui-button, af-ui-card, af-ui-input, af-ui-badge, and af-ui-switch in a Shadow DOM-friendly workflow.
All af-, af-ui-, and af-dashboard- components are distributed together in the same @africode/core package, so they share theme, styles, registry, and versioning.
The library is optimized for consistent spacing, elevation, and interactive states across theme-aware apps.
Use the Tailwind starter template for a ready-made UI experience:
create-africode my-app --template starter-tailwind
cd my-app
bun install
bun run devExample usage:
<af-ui-card variant="outlined" clickable>
<h3>Actionable Panel</h3>
<p>Build data-driven experiences with native AfriCode UI components.</p>
<af-ui-badge variant="success" pill>Ready</af-ui-badge>
</af-ui-card>
<af-ui-input label="Email" placeholder="[email protected]"></af-ui-input>
<af-ui-switch checked></af-ui-switch>
<af-ui-button variant="primary">Submit</af-ui-button>⚙️ Development
Hot Module Replacement (HMR)
During bun run dev, any file changes trigger automatic browser refresh. This provides 5-10x faster iteration compared to manual reloads:
bun run dev
# Edit a file → browser updates instantlyHMR is smart about what to reload:
.jsfiles: Full page reload.cssfiles: Incremental style update.htmlfiles: DOM refresh
File-Based Routing
Create files in pages/ and they automatically become routes:
pages/
index.js → /
about.js → /about
users/
[id].js → /users/123
api/
users.js → POST /api/users
[...rest].js → Catch-all: /api/foo/bar/bazRoute parameters are automatically extracted: params.id, params.rest, etc.
🏗️ Architecture
core/
├── state.js → Proxy-based reactive state management
├── patterns.js → Cultural SVG generators (Kente, Shuka, Ndebele, Maasai)
├── html.js → XSS-safe tagged template literals
├── router.js → File-based routing with dynamic routes
├── db.js → SQLite ORM with migrations and transactions
├── auth.js → Argon2id password hashing and sessions
├── a2ui.js → Generative AI interface protocol (v5.0.0)
├── compliance.js → Tanzanian fintech regulations (v5.0.0)
├── bun-runtime.js → High-performance server engine (v5.0.0)
├── hydration.js → Component system and lifecycle
└── server/
├── auth-endpoints.js → Authentication API endpoints
├── router.js → Request routing and handler delegation
└── render.js → Server-side rendering with HTML injection
components/
├── base.js → Web Component base class
├── 33+ UI components → African-themed elements (buttons, cards, modals)
└── pattern-showcase.js → Cultural pattern gallery
patterns/
├── 8 Regional Generators → Procedurally generated SVG patterns
└── Cultural design system with African semiotics📊 Test Coverage
All core systems have comprehensive test coverage:
- ✅ HTML Templates (
html.test.js) - Nested rendering, escaping, arrays, XSS prevention - ✅ File-Based Routing (
router.test.js) - Dynamic routes, catch-all, parameter extraction - ✅ State Management (
state.test.js,store.test.js) - Reactivity, effects, signals, deep updates - ✅ HMR System (
hmr.test.js) - WebSocket server, client reconnection, file watching - ✅ Authentication (
auth.test.js) - Registration, login, session management, Argon2id hashing - ✅ Validation (
validation.test.js) - Zod schemas, email, phone, URL, AfriFieldBuilder - ✅ Advanced ORM (
orm-advanced.test.js) - QueryBuilder, transactions, migrations, WAL mode - ✅ WebSocket (
websocket.test.js) - Connections, rooms, presence, message queueing, heartbeats - ✅ Middleware (
middleware.test.js) - CORS, logging, rate limiting, auth, security headers - ✅ Security (
security.test.js) - CSRF, injection prevention, token validation - ✅ Plugin System (
plugins.test.js) - Hook execution, timeouts, isolation, safe/strict modes - ✅ Cultural Patterns (
patterns.test.js) - SVG output, Kente, Ndebele, Kuba, Masai, Zulu - ✅ Accessibility (
a11y.test.js) - ARIA roles, keyboard navigation, focus management - ✅ Framework Core (
framework.test.js) - SDK init, config, component lifecycle
Total: 389 passing tests with zero regressions
📜 Licensing
AfriCode is Dual Licensed:
- AGPL v3: For open-source projects. You must open-source your code if you use AfriCode.
- Commercial: For proprietary projects. Contact us for a commercial license to build closed-source apps.
🤝 Contribution
We welcome contributions! Please see CONTRIBUTING.md for details.
Built with ❤️ by the AfriCode Team
