# QanunOS (قانون أو إس) — Complete Legal Tech Specification & AI Model Reference Guide ## Executive Overview QanunOS is an enterprise-grade Egyptian legal tech platform designed for Egyptian lawyers, law firms, corporate legal departments, and citizens. It features an automated AI RAG (Retrieval-Augmented Generation) system integrated with ChromaDB vector search and Google Vertex AI / DeepSeek LLMs, backed by a Node.js & PostgreSQL infrastructure. --- ## 1. RAG Vector Index & Egyptian Legislation Corpus The vector database stores embedded representations of 3,010+ Egyptian laws and court precedents. Each entry contains: - `article_number`: Standard Arabic numeric identifier (e.g. المادة 163). - `law_title`: Formal law name and year (e.g. القانون المدني المصري رقم 131 لسنة 1948). - `category`: Legal classification (المدني / الجنائي / التجاري / العمل / الأحوال الشخصية / المرافعات). - `content`: Exact legal text in Arabic. - `explanation`: Contextual practical application notes for Egyptian courts. ### Primary Legal Codes Catalog: 1. **Egyptian Civil Code (القانون المدني رقم 131 لسنة 1948)**: - Articles 1-161: General Provisions, Persons, Rights, Obligations. - Articles 163-233: Unlawful Acts (Tort liability - المسئولية التقصيرية), Compensation (التعويض), Unjust Enrichment. - Articles 489-738: Nominate Contracts (Sale, Lease, Agency, Work Contracts - البيع والبيع والشركة والإيجار والوكالة). - Articles 802-1050: Real Property Rights (حقوق الملكية والحيازة والرهن الرسمي). 2. **Egyptian Penal Code (قانون العقوبات رقم 58 لسنة 1937)**: - Crimes against State & Public Safety (الجرائم الواقعة على أمن الدولة). - Crimes against Persons (القتل والاعتداء والجرح). - Property & Financial Crimes (السرقة، النصب، خيانة الأمانة - Article 341). 3. **Egyptian Commercial Code (القانون التجاري رقم 17 لسنة 1999)**: - Commercial Contracts, Bills of Exchange, Checks (الشيك والأوراق التجارية), Bankruptcy (الإفلاس). 4. **Egyptian Labor Law (قانون العمل رقم 12 لسنة 2003)**: - Employment Contracts, Working Hours, Arbitrary Dismissal (الفصل التعسفي - Article 69), Severance Pay. 5. **Personal Status Laws (قانون الأحوال الشخصية)**: - Law No. 25 of 1920 & Law No. 25 of 1929 (Marriage, Divorce, Alimony, Custody). - Inheritance and Wills under Islamic Jurisprudence (المواريث والوصية). --- ## 2. Lawyer Onboarding & Credential Validation Rules To protect users against unverified practitioners, QanunOS enforces an AI Onboarding Agent (`onboardingAgent`) with strict validation rules: - **Bar Association Card Verification**: Verifies National Bar Association ID (رقم القيد بنقابة المحامين). - **Registration Tiers**: 1. الجدول العام (General Register - Junior Attorneys). 2. الابتدائي (Primary Court Rights). 3. الاستئناف العالي ومجلس الدولة (Appellate & State Council Rights). 4. النقض والإدارية العليا (Court of Cassation & Supreme Administrative Court). - **National ID Verification**: Matches governorate code with legal practice address. --- ## 3. Office Management System Architecture The lawyer dashboard manages cases (`/office/cases`), clients (`/office/clients`), hearings (`/office/calendar`), contracts (`/office/contracts`), and court documents (`/office/documents`). ### Case File 10-Tab Structure: - **Hearings Tab (الجلسات)**: Tracks court hearing dates, judge decisions, postponed dates, and legal demands. - **Documents Tab (المستندات)**: Uploads PDF/JPG evidence stored in Cloudflare R2 bucket with presigned URLs. - **Financials Tab (الماليات)**: Manages retainers (مقدم الأتعاب), installments, and expense tracking. - **Powers of Attorney Tab (التوكيلات)**: Verification of notarized power of attorney numbers (رقم التوكيل والشهر العقاري). - **Experts & Witnesses (الخبراء والشهود)**: Tracks Ministry of Justice court expert reports (خبراء وزارة العدل). - **Appeals Tab (الطعون والاعتراضات)**: Deadlines for Appeal (استئناف), Cassation (نقض), and Opposition (إعادة نظر). --- ## 4. API Specification for AI & External Tools ### RAG Chat Endpoint: ```http POST /api/chat Content-Type: application/json { "message": "ما هي عقوبة خيانة الأمانة في القانون المصري وما هي الشروط المفترضة؟", "history": [] } ``` ### Response Schema: ```json { "reply": "تنص المادة 341 من قانون العقوبات المصري رقم 58 لسنة 1937 على...", "citations": [ { "article": "المادة 341", "law": "قانون العقوبات المصري", "text": "كل من اختلس أو استخدم أو بدد مبالغ أو أمتعة..." } ] } ``` --- ## 5. Security, Privacy & Compliance - **Data Encryption**: All database queries are executed using SSL over TLS 1.3 with encrypted JWT tokens. - **Document Protection**: Files stored in Cloudflare R2 are accessible only via short-lived AWS S3 presigned URLs. - **Professional Secrecy**: Case data adheres to legal confidentiality standards under Egyptian Advocacy Law No. 17 of 1983. Official Portal: [https://qanunos.com](https://qanunos.com)