Skip to content

Tomefy5/antoka-plateform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

πŸ” Antoka

System Architecture Diagram

AI-Powered Legal Document Platform for Madagascar

License TypeScript Node.js React PRs Welcome

Features β€’ Tech Stack β€’ Getting Started β€’ Documentation β€’ Contributing


πŸ“– About

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.

🎯 Mission

Reduce fraud, accelerate administrative processes, and provide verifiable proof instantly to establish lasting trust between citizens, businesses, and administrations.

🌍 Context

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.


✨ Features

πŸ€– AI-Powered Document Generation

  • 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

βš–οΈ Automated Clause Analysis

  • TensorFlow.js-powered detection of abusive, ambiguous, or illegal clauses
  • Risk scoring and detailed explanations
  • Automatic correction suggestions
  • Real-time document quality assessment

⛓️ Blockchain-Backed Signatures

  • Tamper-proof signatures anchored on Hedera Testnet
  • Immutable hash generation with consensus timestamp
  • Fallback to Polygon for high availability
  • Verifiable proof generation

πŸ” One-Click Verification

  • Public verification via QR code or link
  • Instant authenticity check without login
  • Complete audit trail (who, what, when)
  • Shareable proof with blockchain explorer link

🀝 Real-Time Collaboration

  • Multi-user document editing via Google Docs API
  • WebSocket-powered live updates
  • Version history and comments
  • Participant notifications

πŸ“± Progressive Web App

  • Full offline support with IndexedDB
  • Automatic sync when connection restored
  • Responsive design for mobile/tablet/desktop
  • Installable as native app

πŸ“Š Analytics & Dashboard

  • Document tracking (draft, in review, signed, archived)
  • Risk metrics and statistics
  • DuckDB-powered analytics
  • Exportable reports (CSV/JSON)

πŸ—οΈ Architecture

System Architecture Diagram


πŸ› οΈ Tech Stack

Backend Services

  • Runtime: Node.js 18+ with TypeScript
  • Framework: Express.js
  • Database: Supabase (PostgreSQL) with Row Level Security
  • Authentication: Supabase Auth with MFA support

AI & ML

  • Local Generation: Ollama (privacy-first, offline-capable)
  • Cloud Fallback: Google Gemini API
  • Clause Detection: TensorFlow.js with custom models
  • Translation: Bilingual support (French/Malagasy)

Blockchain

  • Primary: Hedera Testnet (Consensus Service)
  • Fallback: Polygon Testnet
  • SDKs: @hashgraph/sdk, ethers.js

Frontend

  • Framework: React 18 with TypeScript
  • State: Redux Toolkit / Zustand
  • UI: Material-UI / TailwindCSS
  • PWA: Workbox for offline support
  • Real-time: Socket.io for WebSocket

Infrastructure

  • Orchestration: Docker & Docker Compose
  • Monitoring: Prometheus + Grafana
  • Quality: SonarQube Community
  • Analytics: DuckDB
  • Deployment: Ubuntu/Linux with Nginx

πŸš€ Getting Started

Prerequisites

  • 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)

Installation

  1. Clone the repository
git clone https://github.com/your-org/antoka-plateform.git
cd antoka-plateform
  1. Install dependencies
npm install
  1. 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
  1. Start services
# Bootstrap infrastructure
make bootstrap

# Start all services
make up

# View logs
make logs
  1. Access the application

Quick Development Setup

# 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

πŸ“ Project Structure

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

πŸ”§ Configuration

Required Environment Variables

# 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.


πŸ§ͺ Testing

# 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%+

πŸ“ˆ Monitoring & Observability

Prometheus Metrics

Services expose /metrics endpoints with:

  • documents_generated_total
  • clauses_analyzed_total
  • signatures_created_total
  • generation_duration_seconds
  • http_requests_total

Alerts

Configured alerts for:

  • Service downtime (>1min)
  • High latency (p95 >5s)
  • Error rate spike (>5%)
  • Blockchain transaction failures

Logs

Structured JSON logs with:

  • Request ID correlation
  • User context
  • Service name
  • Timestamp
  • Level (error, warn, info)

🚒 Deployment

Production Deployment

# 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

SSL/TLS Setup

We recommend using Caddy for automatic HTTPS:

# Install Caddy
sudo apt install caddy

# Configure reverse proxy
sudo nano /etc/caddy/Caddyfile

Backup Strategy

  • 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

🀝 Contributing

We welcome contributions! Please read our Contributing Guide first.

Development Workflow

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit with conventional commits (feat:, fix:, docs:)
  4. Push to your fork
  5. Open a Pull Request

Code Standards

  • TypeScript: Strict mode enabled
  • Linting: ESLint + Prettier
  • Testing: Jest with 80% coverage minimum
  • Documentation: JSDoc for all public APIs

Getting Help


πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments

  • Hedera Hashgraph for blockchain infrastructure
  • Google Gemini for AI capabilities
  • Supabase for database and authentication
  • The open-source community

πŸ“Š Project Status

🚧 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)

🌟 Star History

If you find this project useful, please consider giving it a star ⭐


Built with ❀️ in Madagascar

Website β€’ Docs β€’ API β€’ Status

About

AI-powered Legal Document Platform for Madagascar

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published