AI-Powered Legal Document Platform for Madagascar
Features β’ Tech Stack β’ Getting Started β’ Documentation β’ Contributing
Antoka is a decentralized platform that combines artificial intelligence and blockchain technology to democratize access to legal documents in Madagascar. We automate legal document generation, detect abusive clauses, enable blockchain-backed electronic signatures, and provide instant verificationβall while supporting offline functionality for low-connectivity areas.
Reduce fraud, accelerate administrative processes, and provide verifiable proof instantly to establish lasting trust between citizens, businesses, and administrations.
In Madagascar, document falsification, identity theft, and lack of reliable proofs slow down contracts, recruitment, and public procedures, costing time and money while increasing inequalities in access to rights.
- Generate legal documents compliant with Malagasy law from natural language input
- Dual AI strategy: Ollama (local) + Gemini API (cloud fallback)
- Response time target: <30 seconds
- Bilingual support: French & Malagasy
- TensorFlow.js-powered detection of abusive, ambiguous, or illegal clauses
- Risk scoring and detailed explanations
- Automatic correction suggestions
- Real-time document quality assessment
- Tamper-proof signatures anchored on Hedera Testnet
- Immutable hash generation with consensus timestamp
- Fallback to Polygon for high availability
- Verifiable proof generation
- Public verification via QR code or link
- Instant authenticity check without login
- Complete audit trail (who, what, when)
- Shareable proof with blockchain explorer link
- Multi-user document editing via Google Docs API
- WebSocket-powered live updates
- Version history and comments
- Participant notifications
- Full offline support with IndexedDB
- Automatic sync when connection restored
- Responsive design for mobile/tablet/desktop
- Installable as native app
- Document tracking (draft, in review, signed, archived)
- Risk metrics and statistics
- DuckDB-powered analytics
- Exportable reports (CSV/JSON)
- Runtime: Node.js 18+ with TypeScript
- Framework: Express.js
- Database: Supabase (PostgreSQL) with Row Level Security
- Authentication: Supabase Auth with MFA support
- Local Generation: Ollama (privacy-first, offline-capable)
- Cloud Fallback: Google Gemini API
- Clause Detection: TensorFlow.js with custom models
- Translation: Bilingual support (French/Malagasy)
- Primary: Hedera Testnet (Consensus Service)
- Fallback: Polygon Testnet
- SDKs: @hashgraph/sdk, ethers.js
- Framework: React 18 with TypeScript
- State: Redux Toolkit / Zustand
- UI: Material-UI / TailwindCSS
- PWA: Workbox for offline support
- Real-time: Socket.io for WebSocket
- Orchestration: Docker & Docker Compose
- Monitoring: Prometheus + Grafana
- Quality: SonarQube Community
- Analytics: DuckDB
- Deployment: Ubuntu/Linux with Nginx
- Node.js 18+ and npm/pnpm
- Docker & Docker Compose
- Git
- Supabase account (or self-hosted instance)
- API Keys:
- Gemini API key
- Google Cloud credentials (for Docs API)
- Hedera testnet account (operator ID & key)
- Clone the repository
git clone https://github.com/your-org/antoka-plateform.git
cd antoka-plateform
- Install dependencies
npm install
- Configure environment
# Copy example env file
cp infra/env/.env.example infra/env/.env.local
# Edit .env.local with your credentials
nano infra/env/.env.local
- Start services
# Bootstrap infrastructure
make bootstrap
# Start all services
make up
# View logs
make logs
- Access the application
- Frontend: http://localhost:3000
- API Gateway: http://localhost:3000/api/v1
- API Docs: http://localhost:3000/api-docs
- Prometheus: http://localhost:9090
- SonarQube: http://localhost:9000
# Start in development mode with hot reload
npm run dev
# Run specific service
npm run dev -w @antoka/docgen
# Run tests
npm test
# Run linting
npm run lint
# Build for production
npm run build
antoka/
βββ .github/ # GitHub Actions workflows
βββ assets/ # Images, logos, screenshots
βββ docs/ # Documentation
β βββ architecture/ # Architecture diagrams & ADRs
β βββ api/ # API documentation
β βββ guides/ # User & developer guides
βββ infra/ # Infrastructure configs
β βββ env/ # Environment templates
β βββ scripts/ # Deployment scripts
βββ services/ # Backend microservices
β βββ api-gateway/ # Main API entry point
β βββ auth/ # Authentication service
β βββ docgen/ # Document generation
β βββ clause-analyzer/ # Risk detection
β βββ collaboration/ # Real-time editing
β βββ blockchain/ # Signature anchoring
βββ web/ # React PWA frontend
βββ shared/ # Shared types & utils
β βββ types/ # TypeScript interfaces
β βββ utils/ # Common utilities
β βββ constants/ # Enums & configs
βββ monitoring/ # Prometheus configs
βββ analytics/ # DuckDB scripts
βββ tests/ # Integration & E2E tests
βββ docker-compose.yml
βββ Makefile
βββ README.md
# Supabase
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_ANON_KEY=your-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-key
# AI Services
OLLAMA_BASE_URL=http://ollama:11434
GEMINI_API_KEY=your-gemini-key
# Google Docs
GOOGLE_DOCS_API_CREDENTIALS_PATH=/path/to/credentials.json
# Hedera Blockchain
HEDERA_NETWORK=testnet
HEDERA_OPERATOR_ID=0.0.xxxxx
HEDERA_OPERATOR_KEY=your-private-key
# Security
JWT_SECRET=your-strong-secret
CORS_ORIGINS=http://localhost:3000
# Timeouts (milliseconds)
GENERATION_TIMEOUT_MS=30000
API_TIMEOUT_MS=10000
See infra/env/.env.example for complete list.
# Run all tests
npm test
# Run with coverage
npm test -- --coverage
# Run specific service tests
npm test -w @antoka/docgen
# Run integration tests
npm run test:integration
# Run E2E tests
npm run test:e2e
# Load testing
npm run test:load
Coverage Requirements:
- Critical services: 80%+
- All services: 70%+
Services expose /metrics endpoints with:
documents_generated_totalclauses_analyzed_totalsignatures_created_totalgeneration_duration_secondshttp_requests_total
Configured alerts for:
- Service downtime (>1min)
- High latency (p95 >5s)
- Error rate spike (>5%)
- Blockchain transaction failures
Structured JSON logs with:
- Request ID correlation
- User context
- Service name
- Timestamp
- Level (error, warn, info)
# Build production images
docker-compose -f docker-compose.prod.yml build
# Deploy to server
docker-compose -f docker-compose.prod.yml up -d
# Check health
curl https://api.antoka.app/health
We recommend using Caddy for automatic HTTPS:
# Install Caddy
sudo apt install caddy
# Configure reverse proxy
sudo nano /etc/caddy/Caddyfile
- Database: Daily Supabase backups (automatic)
- Documents: Versioned in Supabase with S3 integration
- Blockchain: Immutable records on Hedera (no backup needed)
- Logs: 30-day retention, archived to S3
We welcome contributions! Please read our Contributing Guide first.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit with conventional commits (
feat:,fix:,docs:) - Push to your fork
- Open a Pull Request
- TypeScript: Strict mode enabled
- Linting: ESLint + Prettier
- Testing: Jest with 80% coverage minimum
- Documentation: JSDoc for all public APIs
- π« Email: dev@antoka.app
- π¬ Discord: Join our community
- π Issues: GitHub Issues
This project is licensed under the MIT License - see the LICENSE file for details.
- Hedera Hashgraph for blockchain infrastructure
- Google Gemini for AI capabilities
- Supabase for database and authentication
- The open-source community
π§ Active Development - Currently in MVP phase
- β Core document generation
- β Clause analysis
- β Blockchain signatures
- β Offline support
- π§ Real-time collaboration (in progress)
- π KYC verification (planned Q1 2026)
If you find this project useful, please consider giving it a star β

