DEV Community

sharkflow ltd
sharkflow ltd

Posted on

SharkFlow Legal — devto

{
  "title": "Online Legal Advice Kenya Free: How SharkFlow Legal Works Under the Hood",
  "content": "# Online Legal Advice Kenya Free: How SharkFlow Legal Works Under the Hood\n\n## Why Online Legal Advice Matters in Kenya (And Why Your Tech Stack Matters More)\n\nLet's start with a fact: Kenya has over 3 million registered businesses, but fewer than 50,000 practicing lawyers. That's roughly 1 lawyer per 60 businesses. For SMEs in Nairobi's tech corridor, Kisumu's trading hubs, and Mombasa's port zones, accessing legal counsel has always meant choosing between expensive retainers or doing it yourself and hoping for the best.\n\nSharkFlow Legal exists to invert that equation. But building AI-powered legal assistance for Africa's mobile-first, low-bandwidth realities isn't just about training a good LLM—it's about rethinking every architectural decision from the ground up.\n\nThis article walks you through the actual tech: why we chose specific databases, how we optimized for 3G networks, and what we learned about serving 60M+ mobile money users in East Africa.\n\n---\n\n## Key Benefits of Online Legal Advice for Kenya's Businesses\n\n### Benefit 1: Cost-Effective Legal Guidance (The Real Numbers)\n\nA single legal consultation in Nairobi runs KES 5,000–15,000 ($40–120). For bootstrapped founders and small traders, that's prohibitive. SharkFlow's free tier provides instant templates, contract reviews, and guidance on Kenya's Business Registration Act, Employment Act, and Competition Act—without the retainer fees.\n\n**The infrastructure angle:** This means handling millions of requests on a tight margin. We use edge caching heavily and distribute document processing across regional nodes to keep latency under 2 seconds, even on slower networks.\n\n### Benefit 2: 24/7 Availability on Your Phone\n\nKenyan lawyers work 9–5 (if you're lucky). Your M-Pesa payment dispute happens at midnight. SharkFlow's API is always on, and our mobile UI works on 2G data.\n\n### Benefit 3: Localized Legal Knowledge Without Regional Travel\n\nA trader in Eldoret needs to understand Nairobi's County Business Licensing requirements. A Mombasa exporter needs KEBS certification guidance. Our training data includes Kenya's 47 county laws, the Central Bank's digital lending guidelines, and CBK's latest AML/KYC requirements.\n\n---\n\n## How SharkFlow Legal Works: The Technical Architecture\n\n### 1. API Design: Stateless, Async-First, Mobile-Optimized\n\nOur core API is built on gRPC with fallback REST endpoints (because not all African startups have gRPC clients yet). Here's why this matters:\n\n```

protobuf\n// legal_service.proto\nservice LegalAssistance {\n  rpc ReviewContract(ContractReviewRequest) returns (ContractReviewResponse);\n  rpc GetTemplate(TemplateRequest) returns (TemplateResponse);\n  rpc QueryLaw(LegalQueryRequest) returns (LegalQueryResponse);\n}\n\nmessage ContractReviewRequest {\n  string document_url = 1;  // S3 URI or base64 embedded for offline\n  string jurisdiction = 2;  // \"KE\", \"UG\", \"TZ\"\n  string business_type = 3; // \"tech\", \"trade\", \"healthcare\"\n  int32 timeout_seconds = 4; // Default: 30s for 3G\n}\n\nmessage ContractReviewResponse {\n  string analysis = 1;\n  repeated Risk risks = 2;\n  repeated Suggestion suggestions = 3;\n  int32 confidence_score = 4;\n}\n

```\n\nWhy async-first? Because a 2MB contract on a 2G connection takes time. We queue processing jobs and return a `job_id` immediately, with webhooks for completion.\n\n```

typescript\n// Example client: React Native (common in Kenya)\nimport { LegalClient } from '@sharkflow/legal-sdk';\n\nconst client = new LegalClient({\n  apiKey: process.env.SHARKFLOW_KEY,\n  region: 'east-africa', // Routes to Nairobi servers\n  timeout: 30000,\n});\n\nconst jobId = await client.reviewContract({\n  documentBase64: base64Document,\n  jurisdiction: 'KE',\n  businessType: 'tech_startup',\n});\n\n// Poll or webhook—works on patchy 3G\nclient.onJobComplete(jobId, (result) => {\n  console.log('Risks found:', result.risks);\n});\n

```\n\n### 2. Database Choices: Why We Use PostgreSQL + Vector Store\n\nSharkFlow Legal's backend uses:\n\n- **PostgreSQL** (primary): Transactional legal data, user profiles, templates. We run it on AWS RDS Multi-AZ (Lagos + N. Virginia) with read replicas in Nairobi (via EC2).\n- **Weaviate** (vector store): Embeddings for case law, templates, and legal reasoning. This powers semantic search—\"Am I liable if an employee is injured working from home?\" retrieves Kenya-specific precedent across hundreds of documents instantly.\n- **Redis** (cache layer): Template cache, API response caching, rate limiting (100 requests/min on free tier). Crucial for cutting database load by 70%.\n\n```

sql\n-- PostgreSQL schema\nCREATE TABLE legal_queries (\n  id UUID PRIMARY KEY,\n  user_id UUID NOT NULL,\n  query_text TEXT NOT NULL,\n  jurisdiction VARCHAR(2), -- \"KE\", \"UG\", \"TZ\"\n  business_category VARCHAR(50),\n  response_json JSONB,\n  processing_time_ms INT,\n  created_at TIMESTAMP DEFAULT NOW()\n);\n\nCREATE INDEX idx_jurisdiction_category ON legal
Enter fullscreen mode Exit fullscreen mode

Top comments (0)