@africode/core 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AFRICODE_FRAMEWORK_GUIDE.md +707 -0
- package/LICENSE +623 -0
- package/README.md +442 -0
- package/bin/africode.js +73 -0
- package/bin/africode.js.1758507140 +343 -0
- package/bin/cli.ts +83 -0
- package/bin/create-africode.js +158 -0
- package/bin/scaffold.ts +219 -0
- package/components/accordion.js +183 -0
- package/components/alert.js +131 -0
- package/components/auth.js +172 -0
- package/components/avatar.js +117 -0
- package/components/badge.js +104 -0
- package/components/base.d.ts +139 -0
- package/components/base.js +184 -0
- package/components/button.js +164 -0
- package/components/card.js +137 -0
- package/components/cultural-card.js +243 -0
- package/components/divider.js +83 -0
- package/components/dropdown.js +171 -0
- package/components/error-boundary.js +155 -0
- package/components/form.js +131 -0
- package/components/grid.js +273 -0
- package/components/hero.js +138 -0
- package/components/icon.js +36 -0
- package/components/index.js +57 -0
- package/components/input.js +256 -0
- package/components/kanga-card.js +185 -0
- package/components/language-switcher.js +108 -0
- package/components/loader.js +80 -0
- package/components/modal.js +262 -0
- package/components/motion.js +84 -0
- package/components/navbar.js +236 -0
- package/components/pattern-showcase.js +225 -0
- package/components/progress.js +134 -0
- package/components/react.js +111 -0
- package/components/section.js +54 -0
- package/components/select.js +322 -0
- package/components/sidebar.js +180 -0
- package/components/skeleton.js +85 -0
- package/components/table.js +181 -0
- package/components/tabs.js +202 -0
- package/components/theme-toggle.js +82 -0
- package/components/toast.js +139 -0
- package/components/tooltip.js +167 -0
- package/core/a2ui-schema-manager.js +344 -0
- package/core/a2ui.js +431 -0
- package/core/bun-runtime.js +799 -0
- package/core/cli/commands/add.js +23 -0
- package/core/cli/commands/audit.js +58 -0
- package/core/cli/commands/build.js +137 -0
- package/core/cli/commands/create-plugin.js +241 -0
- package/core/cli/commands/dev.js +228 -0
- package/core/cli/commands/lint.js +23 -0
- package/core/cli/commands/test.js +34 -0
- package/core/cli/migrator.js +71 -0
- package/core/cli/ui.js +46 -0
- package/core/compliance.js +628 -0
- package/core/config.js +263 -0
- package/core/db-advanced.js +481 -0
- package/core/db.js +284 -0
- package/core/enhanced-hmr.js +404 -0
- package/core/errors.js +222 -0
- package/core/file-router.js +290 -0
- package/core/heartbeat.js +64 -0
- package/core/hmr-client.js +204 -0
- package/core/hmr.js +196 -0
- package/core/html.d.ts +116 -0
- package/core/html.js +160 -0
- package/core/hydration.js +52 -0
- package/core/lipa-namba-journey.js +572 -0
- package/core/motion.js +106 -0
- package/core/nida-cig-middleware.js +455 -0
- package/core/patterns.d.ts +124 -0
- package/core/patterns.js +833 -0
- package/core/plugins/index.js +312 -0
- package/core/router.js +387 -0
- package/core/sdk-client.js +62 -0
- package/core/sdk.d.ts +133 -0
- package/core/sdk.js +123 -0
- package/core/seo.js +76 -0
- package/core/server/auth-endpoints.js +339 -0
- package/core/server/auth.js +180 -0
- package/core/server/csrf.js +206 -0
- package/core/server/db.js +39 -0
- package/core/server/middleware.js +324 -0
- package/core/server/rate-limit.js +238 -0
- package/core/server/render.js +69 -0
- package/core/server/router.js +120 -0
- package/core/shim.js +28 -0
- package/core/state.d.ts +86 -0
- package/core/state.js +242 -0
- package/core/store.d.ts +122 -0
- package/core/store.js +61 -0
- package/core/validation.d.ts +233 -0
- package/core/validation.js +590 -0
- package/core/websocket.js +639 -0
- package/dist/africode.js +2905 -0
- package/dist/africode.js.map +61 -0
- package/dist/build-info.json +23 -0
- package/dist/components.js +2888 -0
- package/dist/components.js.map +58 -0
- package/dist/styles/africanity.css +322 -0
- package/dist/styles/typography.css +141 -0
- package/docs/IDE-Guide.md +50 -0
- package/package.json +110 -0
- package/src/index.ts +196 -0
- package/styles/africanity.css +322 -0
- package/styles/typography.css +141 -0
- package/templates/starter/.env.example +15 -0
- package/templates/starter/africode.config.js +40 -0
- package/templates/starter/package.json +14 -0
- package/templates/starter/src/pages/index.html +46 -0
- package/templates/starter/src/pages/index.js +32 -0
- package/templates/starter/src/styles/main.css +4 -0
- package/templates/starter-3d/.env.example +7 -0
- package/templates/starter-3d/africode.config.js +29 -0
- package/templates/starter-3d/components/af-model-viewer.js +125 -0
- package/templates/starter-3d/package.json +15 -0
- package/templates/starter-3d/src/pages/index.html +46 -0
- package/templates/starter-3d/src/pages/index.js +50 -0
- package/templates/starter-3d/src/styles/main.css +4 -0
- package/templates/starter-react/.env.example +15 -0
- package/templates/starter-react/africode.config.js +40 -0
- package/templates/starter-react/package.json +16 -0
- package/templates/starter-react/src/pages/index.html +46 -0
- package/templates/starter-react/src/pages/index.js +68 -0
- package/templates/starter-react/src/styles/main.css +4 -0
- package/templates/starter-tailwind/.env.example +15 -0
- package/templates/starter-tailwind/africode.config.js +40 -0
- package/templates/starter-tailwind/package.json +20 -0
- package/templates/starter-tailwind/src/pages/index.html +46 -0
- package/templates/starter-tailwind/src/pages/index.js +37 -0
- package/templates/starter-tailwind/src/styles/main.css +4 -0
- package/templates/starter-tailwind/src/styles/tailwind.css +1 -0
- package/templates/starter-tailwind/src/tailwind-loader.js +30 -0
package/README.md
ADDED
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
# 🌍 AfriCode v5.0.0 — The Design System of Sovereignty
|
|
2
|
+
|
|
3
|
+
> **Autonomous Framework for African Digital Economy**
|
|
4
|
+
> Bridging AI safety, fintech compliance, and cultural heritage through high-performance web architecture.
|
|
5
|
+
|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
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.
|
|
15
|
+
|
|
16
|
+
### Strategic Vision: From Tanzania to the Continent
|
|
17
|
+
|
|
18
|
+
Following the rollout framework, AfriCode v5.0.0 implements a phased Pan-African expansion:
|
|
19
|
+
|
|
20
|
+
- **Phase 1 (Months 1-4)**: Silicon Dar foundation with TIPS integration
|
|
21
|
+
- **Phase 2 (Months 5-9)**: East African Corridor (Kenya, Uganda, Rwanda)
|
|
22
|
+
- **Phase 3 (Months 10-15)**: West African Hub (Nigeria, Ghana)
|
|
23
|
+
- **Phase 4 (Months 16-24)**: Continental governance and sustainability
|
|
24
|
+
|
|
25
|
+
## ✨ Autonomous Features
|
|
26
|
+
|
|
27
|
+
### 🤖 AI-Safe Architecture (A2UI Protocol)
|
|
28
|
+
- **Robot-First Manifest**: Machine-readable component catalog prevents hallucinations
|
|
29
|
+
- **Ethnomathematical Patterns**: Procedural generation of Kente, Ndebele, Shuka motifs
|
|
30
|
+
- **Schema Validation**: Pre-approved components with usage hints and constraints
|
|
31
|
+
|
|
32
|
+
### 🔐 Fintech Compliance "Hardening"
|
|
33
|
+
- **NIDA CIG Bridge**: VPN-tunneled identity verification with Ed25519 cryptography
|
|
34
|
+
- **TIPS Integration**: Bank of Tanzania-compliant payment flows
|
|
35
|
+
- **AML/FIU Reporting**: Automated regulatory compliance and transaction logging
|
|
36
|
+
|
|
37
|
+
### ⚡ Zero-Downtime Infrastructure
|
|
38
|
+
- **File-Based Routing**: Automatic `/pages` to URL mapping with dynamic routes
|
|
39
|
+
- **Enhanced HMR**: Session preservation during hot reloads
|
|
40
|
+
- **Bun-Native Runtime**: 5ms startup with WebSocket orchestration
|
|
41
|
+
|
|
42
|
+
### 🎨 Cultural Resonance
|
|
43
|
+
- **33+ Web Components**: African-themed UI elements with cultural semiotics
|
|
44
|
+
- **Procedural SVG Engine**: Fractal geometry for traditional patterns
|
|
45
|
+
- **Mobile-First Design**: Optimized for African connectivity constraints
|
|
46
|
+
|
|
47
|
+
## 🚀 Quick Start
|
|
48
|
+
|
|
49
|
+
### Create Autonomous Project
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Install globally via NPM
|
|
53
|
+
npm install -g @africode/core
|
|
54
|
+
|
|
55
|
+
# Create new project
|
|
56
|
+
create-africode my-app
|
|
57
|
+
cd my-app
|
|
58
|
+
|
|
59
|
+
# Install dependencies
|
|
60
|
+
bun install
|
|
61
|
+
|
|
62
|
+
# Start autonomous development server
|
|
63
|
+
bun run dev
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Project Structure (Autonomous)
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
my-app/
|
|
70
|
+
├── src/
|
|
71
|
+
│ ├── server.ts # Autonomous server entry
|
|
72
|
+
│ ├── pages/ # File-based routes
|
|
73
|
+
│ │ ├── index.ts # Home page
|
|
74
|
+
│ │ └── api/ # API routes
|
|
75
|
+
│ ├── components/ # Custom components
|
|
76
|
+
│ └── core/ # Framework extensions
|
|
77
|
+
├── public/ # Static assets
|
|
78
|
+
├── package.json # NPM configuration
|
|
79
|
+
├── tsconfig.json # TypeScript config
|
|
80
|
+
└── catalog.json # A2UI component manifest
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### AI-Safe Development
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
// pages/index.ts
|
|
87
|
+
import { html } from '@africode/core';
|
|
88
|
+
|
|
89
|
+
export default function Home() {
|
|
90
|
+
return html`
|
|
91
|
+
<af-app>
|
|
92
|
+
<af-navbar>
|
|
93
|
+
<h1 slot="brand">My AfriCode App</h1>
|
|
94
|
+
</af-navbar>
|
|
95
|
+
|
|
96
|
+
<main>
|
|
97
|
+
<af-hero>
|
|
98
|
+
<h1>AI-Safe Fintech</h1>
|
|
99
|
+
<p>Built with cultural patterns</p>
|
|
100
|
+
<af-kente-pattern complexity="3"></af-kente-pattern>
|
|
101
|
+
</af-hero>
|
|
102
|
+
</main>
|
|
103
|
+
</af-app>
|
|
104
|
+
`;
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## 🏗️ Architecture
|
|
109
|
+
|
|
110
|
+
### Core Modules
|
|
111
|
+
|
|
112
|
+
| Module | Purpose | Status |
|
|
113
|
+
|--------|---------|--------|
|
|
114
|
+
| `src/index.ts` | Main framework entry | ✅ Complete |
|
|
115
|
+
| `core/a2ui-schema-manager.js` | AI component catalog | ✅ Enhanced |
|
|
116
|
+
| `core/nida-cig-middleware.js` | Identity verification | ✅ VPN + Crypto |
|
|
117
|
+
| `core/lipa-namba-journey.js` | Payment primitives | ✅ BoT Compliant |
|
|
118
|
+
| `core/file-router.js` | File-based routing | ✅ Dynamic routes |
|
|
119
|
+
| `core/enhanced-hmr.js` | Zero-downtime HMR | ✅ Session preservation |
|
|
120
|
+
|
|
121
|
+
### Cloud Infrastructure
|
|
122
|
+
|
|
123
|
+
#### AMD AI Cloud (Intelligence Layer)
|
|
124
|
+
- **MI300X GPUs**: 192GB HBM3 for LLM inference
|
|
125
|
+
- **$100 Credits**: 200 hours on RunPod community cloud
|
|
126
|
+
- **AfriCode-Coder Model**: Fine-tuned for Tanzanian fintech law
|
|
127
|
+
|
|
128
|
+
#### Alibaba Cloud (Asset Layer)
|
|
129
|
+
- **Model Studio**: Qwen3-Max for complex reasoning
|
|
130
|
+
- **Free Tier**: 1M tokens for initial rollout
|
|
131
|
+
- **Batch Inference**: 50% cost reduction for production
|
|
132
|
+
|
|
133
|
+
## 🔧 CLI Commands
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
# Development
|
|
137
|
+
africode dev # Start dev server with HMR
|
|
138
|
+
africode build # Production build
|
|
139
|
+
africode lint # Code quality checks
|
|
140
|
+
|
|
141
|
+
# AI Integration
|
|
142
|
+
africode generate a2ui # Update component catalog
|
|
143
|
+
africode generate patterns # Regenerate cultural patterns
|
|
144
|
+
|
|
145
|
+
# Fintech
|
|
146
|
+
africode migrate # Run database migrations
|
|
147
|
+
africode audit # Security and compliance audit
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## 🎭 Ethnomathematical Patterns
|
|
151
|
+
|
|
152
|
+
AfriCode v5.0.0 incorporates traditional African geometric principles:
|
|
153
|
+
|
|
154
|
+
### Kente Weaving (Glide Reflection)
|
|
155
|
+
```javascript
|
|
156
|
+
import { generateKente } from '@africode/core';
|
|
157
|
+
|
|
158
|
+
const pattern = generateKente({
|
|
159
|
+
baseColor: '#8B4513',
|
|
160
|
+
accentColor: '#DAA520',
|
|
161
|
+
complexity: 3
|
|
162
|
+
});
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Ndebele Fractals (Recursive Geometry)
|
|
166
|
+
```javascript
|
|
167
|
+
const ndebele = generateNdebele({
|
|
168
|
+
recursionDepth: 4,
|
|
169
|
+
symmetry: 'rotational',
|
|
170
|
+
colors: ['#FF6B6B', '#4ECDC4', '#45B7D1']
|
|
171
|
+
});
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## 🔒 Fintech Compliance
|
|
175
|
+
|
|
176
|
+
### NIDA Identity Verification
|
|
177
|
+
```typescript
|
|
178
|
+
import { NIDAClient } from '@africode/core';
|
|
179
|
+
|
|
180
|
+
const nida = new NIDAClient({
|
|
181
|
+
vpnEnabled: true,
|
|
182
|
+
endpoint: 'https://api.nida.go.tz/cig'
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
const result = await nida.verifyNIN('12345678901234567890', 'PIN');
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### TIPS Payment Processing
|
|
189
|
+
```typescript
|
|
190
|
+
import { LipaNambaJourney } from '@africode/core';
|
|
191
|
+
|
|
192
|
+
const journey = new LipaNambaJourney();
|
|
193
|
+
const payment = await journey.executeFullJourney({
|
|
194
|
+
merchantId: 'MERCHANT_001',
|
|
195
|
+
customerPhone: '255712345678',
|
|
196
|
+
amount: 50000
|
|
197
|
+
}, customerIdentity, confirmationData);
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## 🌐 Pan-African Expansion
|
|
201
|
+
|
|
202
|
+
### Phase 1: Tanzania Foundation
|
|
203
|
+
- **TIPS Integration**: Real-time payment processing
|
|
204
|
+
- **NIDA Compliance**: Identity verification for KYC
|
|
205
|
+
- **Cultural Patterns**: Swahili language support
|
|
206
|
+
|
|
207
|
+
### Phase 2: East African Corridor
|
|
208
|
+
- **PAPSS Bridge**: Cross-border settlement
|
|
209
|
+
- **Regional Hubs**: Nairobi, Kampala, Kigali
|
|
210
|
+
- **Agri-Fintech**: Supply chain integration
|
|
211
|
+
|
|
212
|
+
### Phase 3: West African Powerhouse
|
|
213
|
+
- **NIBSS Integration**: Nigerian payment systems
|
|
214
|
+
- **Kente Patterns**: Ghanaian cultural motifs
|
|
215
|
+
- **Enterprise Adoption**: Large corporate clients
|
|
216
|
+
|
|
217
|
+
## 🤝 Community & Incentives
|
|
218
|
+
|
|
219
|
+
### AfriCode Pioneer Bounty Program
|
|
220
|
+
- **Bug Fixes**: $50-200 for confirmed issues
|
|
221
|
+
- **Features**: $300-1500 for new capabilities
|
|
222
|
+
- **Performance**: $100-500 for optimizations
|
|
223
|
+
- **Cultural Assets**: $50-300 for pattern designs
|
|
224
|
+
|
|
225
|
+
### Developer Hubs
|
|
226
|
+
- **Silicon Dar**: Dar es Salaam tech district
|
|
227
|
+
- **iHub Nairobi**: East African innovation
|
|
228
|
+
- **CcHUB Lagos**: West African powerhouse
|
|
229
|
+
- **GDG Network**: Google Developer Groups across Africa
|
|
230
|
+
|
|
231
|
+
## 📊 Performance Metrics
|
|
232
|
+
|
|
233
|
+
- **Startup Time**: <5ms (Bun-native)
|
|
234
|
+
- **Bundle Size**: <100KB (tree-shaken)
|
|
235
|
+
- **Lighthouse Score**: 95+ (mobile-first)
|
|
236
|
+
- **TIPS Transactions**: 490M+ annually supported
|
|
237
|
+
- **NIDA Verifications**: Real-time with VPN security
|
|
238
|
+
|
|
239
|
+
## 📚 Documentation
|
|
240
|
+
|
|
241
|
+
- [Framework Guide](docs/FRAMEWORK.md)
|
|
242
|
+
- [Component Catalog](catalog.json)
|
|
243
|
+
- [API Reference](docs/API.md)
|
|
244
|
+
- [Fintech Integration](docs/FINTECH.md)
|
|
245
|
+
- [Cultural Patterns](docs/PATTERNS.md)
|
|
246
|
+
|
|
247
|
+
## 🤝 Contributing
|
|
248
|
+
|
|
249
|
+
We welcome contributions that align with our Pan-African vision:
|
|
250
|
+
|
|
251
|
+
1. Fork the repository
|
|
252
|
+
2. Create a feature branch
|
|
253
|
+
3. Add tests for new functionality
|
|
254
|
+
4. Ensure AI-safety compliance
|
|
255
|
+
5. Submit a pull request
|
|
256
|
+
|
|
257
|
+
## 📄 License
|
|
258
|
+
|
|
259
|
+
**Dual License:**
|
|
260
|
+
- **Open Source**: AGPL v3.0 for community projects
|
|
261
|
+
- **Commercial**: Available for enterprise deployments
|
|
262
|
+
|
|
263
|
+
## 🌟 Acknowledgments
|
|
264
|
+
|
|
265
|
+
Built for the African developer community with support from:
|
|
266
|
+
- **Bank of Tanzania** (TIPS infrastructure)
|
|
267
|
+
- **National Identification Authority** (NIDA systems)
|
|
268
|
+
- **AMD AI Cloud** ($100 credits for AI development)
|
|
269
|
+
- **Alibaba Cloud** (Model Studio free tier)
|
|
270
|
+
- **African Export-Import Bank** (PAPSS coordination)
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
**"Designed for Tanzanians by Tanzanians, Built for Africans by Africans"**
|
|
275
|
+
|
|
276
|
+
🇹🇿🇰🇪🇺🇬🇷🇼🇳🇬🇬🇭🇿🇦🇲🇦
|
|
277
|
+
|
|
278
|
+
### Local Development (Framework Contributors)
|
|
279
|
+
|
|
280
|
+
If you are developing the framework itself:
|
|
281
|
+
|
|
282
|
+
1. Clone and navigate to the framework directory
|
|
283
|
+
2. Register the link: `bun link`
|
|
284
|
+
3. Use in another project: `bun link africode`
|
|
285
|
+
4. Run validation: `bun scripts/validate-fresh-install.js`
|
|
286
|
+
|
|
287
|
+
### Usage (SDK)
|
|
288
|
+
|
|
289
|
+
Import the core SDK to generate patterns, use the state engine, or handle routing:
|
|
290
|
+
|
|
291
|
+
```javascript
|
|
292
|
+
import { patterns, store, components } from 'africode';
|
|
293
|
+
import { FileSystemRouter } from 'africode/core/router.js';
|
|
294
|
+
|
|
295
|
+
// Generate a Maasai Shuka pattern
|
|
296
|
+
const shukaPattern = patterns.generateShuka();
|
|
297
|
+
document.body.style.backgroundImage = `url("${shukaPattern}")`;
|
|
298
|
+
|
|
299
|
+
// Use Global State
|
|
300
|
+
store.ui.theme = 'tanzania';
|
|
301
|
+
store.ui.theme; // 'tanzania' - triggers effects on change
|
|
302
|
+
|
|
303
|
+
// Use File-Based Routing
|
|
304
|
+
const router = new FileSystemRouter('./pages');
|
|
305
|
+
const route = await router.matchRoute('/users/123');
|
|
306
|
+
// { page, params: { id: '123' }, path: '/users/[id]' }
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
### Usage (Authentication)
|
|
310
|
+
|
|
311
|
+
AfriCode includes built-in session-based authentication:
|
|
312
|
+
|
|
313
|
+
```javascript
|
|
314
|
+
// API endpoints (automatically available)
|
|
315
|
+
POST / api / auth / register; // { email, username, password, fullname }
|
|
316
|
+
POST / api / auth / login; // { email/username, password }
|
|
317
|
+
POST / api / auth / logout; // Clears session
|
|
318
|
+
GET / api / auth / me; // Current user (requires session)
|
|
319
|
+
POST / api / auth / refresh; // Extend session expiry
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
Passwords are hashed with **Argon2id** (built into Bun), sessions use **HttpOnly** cookies with **SameSite=Strict** protection.
|
|
323
|
+
|
|
324
|
+
### Usage (UI Components)
|
|
325
|
+
|
|
326
|
+
Simply import the components to register them as Custom Elements:
|
|
327
|
+
|
|
328
|
+
```javascript
|
|
329
|
+
import 'africode/components';
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
Then use them in your HTML:
|
|
333
|
+
|
|
334
|
+
```html
|
|
335
|
+
<af-navbar theme="tanzania" logo="My App"></af-navbar>
|
|
336
|
+
|
|
337
|
+
<af-kanga-card proverb="Haraka haraka haina baraka.">
|
|
338
|
+
<h3>Project Title</h3>
|
|
339
|
+
<p>Content goes here...</p>
|
|
340
|
+
</af-kanga-card>
|
|
341
|
+
|
|
342
|
+
<af-button onclick="handleClick()">Click Me</af-button>
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
## ⚙️ Development
|
|
346
|
+
|
|
347
|
+
### Hot Module Replacement (HMR)
|
|
348
|
+
|
|
349
|
+
During `bun run dev`, any file changes trigger automatic browser refresh. This provides **5-10x faster iteration** compared to manual reloads:
|
|
350
|
+
|
|
351
|
+
```bash
|
|
352
|
+
bun run dev
|
|
353
|
+
# Edit a file → browser updates instantly
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
HMR is smart about what to reload:
|
|
357
|
+
|
|
358
|
+
- `.js` files: Full page reload
|
|
359
|
+
- `.css` files: Incremental style update
|
|
360
|
+
- `.html` files: DOM refresh
|
|
361
|
+
|
|
362
|
+
### File-Based Routing
|
|
363
|
+
|
|
364
|
+
Create files in `pages/` and they automatically become routes:
|
|
365
|
+
|
|
366
|
+
```
|
|
367
|
+
pages/
|
|
368
|
+
index.js → /
|
|
369
|
+
about.js → /about
|
|
370
|
+
users/
|
|
371
|
+
[id].js → /users/123
|
|
372
|
+
api/
|
|
373
|
+
users.js → POST /api/users
|
|
374
|
+
[...rest].js → Catch-all: /api/foo/bar/baz
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
Route parameters are automatically extracted: `params.id`, `params.rest`, etc.
|
|
378
|
+
|
|
379
|
+
## 🏗️ Architecture
|
|
380
|
+
|
|
381
|
+
```
|
|
382
|
+
core/
|
|
383
|
+
├── state.js → Proxy-based reactive state management
|
|
384
|
+
├── patterns.js → Cultural SVG generators (Kente, Shuka, Ndebele, Maasai)
|
|
385
|
+
├── html.js → XSS-safe tagged template literals
|
|
386
|
+
├── router.js → File-based routing with dynamic routes
|
|
387
|
+
├── db.js → SQLite ORM with migrations and transactions
|
|
388
|
+
├── auth.js → Argon2id password hashing and sessions
|
|
389
|
+
├── a2ui.js → Generative AI interface protocol (v5.0.0)
|
|
390
|
+
├── compliance.js → Tanzanian fintech regulations (v5.0.0)
|
|
391
|
+
├── bun-runtime.js → High-performance server engine (v5.0.0)
|
|
392
|
+
├── hydration.js → Component system and lifecycle
|
|
393
|
+
└── server/
|
|
394
|
+
├── auth-endpoints.js → Authentication API endpoints
|
|
395
|
+
├── router.js → Request routing and handler delegation
|
|
396
|
+
└── render.js → Server-side rendering with HTML injection
|
|
397
|
+
|
|
398
|
+
components/
|
|
399
|
+
├── base.js → Web Component base class
|
|
400
|
+
├── 33+ UI components → African-themed elements (buttons, cards, modals)
|
|
401
|
+
└── pattern-showcase.js → Cultural pattern gallery
|
|
402
|
+
|
|
403
|
+
patterns/
|
|
404
|
+
├── 8 Regional Generators → Procedurally generated SVG patterns
|
|
405
|
+
└── Cultural design system with African semiotics
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
## 📊 Test Coverage
|
|
409
|
+
|
|
410
|
+
All core systems have comprehensive test coverage:
|
|
411
|
+
|
|
412
|
+
- ✅ **HTML Templates** (`html.test.js`) - Nested rendering, escaping, arrays, XSS prevention
|
|
413
|
+
- ✅ **File-Based Routing** (`router.test.js`) - Dynamic routes, catch-all, parameter extraction
|
|
414
|
+
- ✅ **State Management** (`state.test.js`, `store.test.js`) - Reactivity, effects, signals, deep updates
|
|
415
|
+
- ✅ **HMR System** (`hmr.test.js`) - WebSocket server, client reconnection, file watching
|
|
416
|
+
- ✅ **Authentication** (`auth.test.js`) - Registration, login, session management, Argon2id hashing
|
|
417
|
+
- ✅ **Validation** (`validation.test.js`) - Zod schemas, email, phone, URL, AfriFieldBuilder
|
|
418
|
+
- ✅ **Advanced ORM** (`orm-advanced.test.js`) - QueryBuilder, transactions, migrations, WAL mode
|
|
419
|
+
- ✅ **WebSocket** (`websocket.test.js`) - Connections, rooms, presence, message queueing, heartbeats
|
|
420
|
+
- ✅ **Middleware** (`middleware.test.js`) - CORS, logging, rate limiting, auth, security headers
|
|
421
|
+
- ✅ **Security** (`security.test.js`) - CSRF, injection prevention, token validation
|
|
422
|
+
- ✅ **Plugin System** (`plugins.test.js`) - Hook execution, timeouts, isolation, safe/strict modes
|
|
423
|
+
- ✅ **Cultural Patterns** (`patterns.test.js`) - SVG output, Kente, Ndebele, Kuba, Masai, Zulu
|
|
424
|
+
- ✅ **Accessibility** (`a11y.test.js`) - ARIA roles, keyboard navigation, focus management
|
|
425
|
+
- ✅ **Framework Core** (`framework.test.js`) - SDK init, config, component lifecycle
|
|
426
|
+
|
|
427
|
+
**Total: 389 passing tests** with zero regressions
|
|
428
|
+
|
|
429
|
+
## 📜 Licensing
|
|
430
|
+
|
|
431
|
+
AfriCode is **Dual Licensed**:
|
|
432
|
+
|
|
433
|
+
1. **AGPL v3**: For open-source projects. You must open-source your code if you use AfriCode.
|
|
434
|
+
2. **Commercial**: For proprietary projects. Contact us for a commercial license to build closed-source apps.
|
|
435
|
+
|
|
436
|
+
## 🤝 Contribution
|
|
437
|
+
|
|
438
|
+
We welcome contributions! Please see `CONTRIBUTING.md` for details.
|
|
439
|
+
|
|
440
|
+
---
|
|
441
|
+
|
|
442
|
+
_Built with ❤️ by the AfriCode Team_
|
package/bin/africode.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* AfriCode CLI - Thin Wrapper
|
|
4
|
+
*/
|
|
5
|
+
import '../core/shim.js';
|
|
6
|
+
import { help } from '../core/cli/ui.js';
|
|
7
|
+
|
|
8
|
+
const args = process.argv.slice(2);
|
|
9
|
+
const command = args[0];
|
|
10
|
+
|
|
11
|
+
async function run() {
|
|
12
|
+
switch (command) {
|
|
13
|
+
case 'dev': {
|
|
14
|
+
const { dev } = await import('../core/cli/commands/dev.js');
|
|
15
|
+
await dev();
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
case 'build': {
|
|
19
|
+
const { build } = await import('../core/cli/commands/build.js');
|
|
20
|
+
await build();
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
case 'add': {
|
|
24
|
+
const { addComponent } = await import('../core/cli/commands/add.js');
|
|
25
|
+
await addComponent(args[1]);
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
case 'migrate': {
|
|
29
|
+
const { runMigrations } = await import('../core/cli/migrator.js');
|
|
30
|
+
await runMigrations();
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
case 'new':
|
|
34
|
+
case 'create':
|
|
35
|
+
case 'init': {
|
|
36
|
+
if (args[1] === 'plugin') {
|
|
37
|
+
const { createPlugin } = await import('../core/cli/commands/create-plugin.js');
|
|
38
|
+
await createPlugin(args[2], args.slice(3));
|
|
39
|
+
} else {
|
|
40
|
+
const { createProject } = await import('./create-africode.js');
|
|
41
|
+
await createProject(args[1]);
|
|
42
|
+
}
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
case 'lint': {
|
|
46
|
+
const { lint } = await import('../core/cli/commands/lint.js');
|
|
47
|
+
await lint();
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
case 'audit': {
|
|
51
|
+
const { audit } = await import('../core/cli/commands/audit.js');
|
|
52
|
+
await audit();
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
case 'test': {
|
|
56
|
+
const { test } = await import('../core/cli/commands/test.js');
|
|
57
|
+
await test();
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
case 'help':
|
|
61
|
+
case '--help':
|
|
62
|
+
case '-h':
|
|
63
|
+
help();
|
|
64
|
+
break;
|
|
65
|
+
default:
|
|
66
|
+
help();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
run().catch(err => {
|
|
71
|
+
console.error('Fatal Error:', err);
|
|
72
|
+
process.exit(1);
|
|
73
|
+
});
|