# AI Resume Prompt for Khandan (English)

## Objective
This resume / prompt is meant for directly injecting the context for AI agents/sessions to quickly understand the Khandan project parameters and save token quota.

## Project Summary
**Khandan (خاندان)** is a private, self-hosted web application that acts as a digital anchor for a family lineage (clan). Unlike general-purpose social networks, Khandan is completely self-hosted, private, and integrates three critical pillars of family continuity:

1. **Relational History & Genealogy:** An interactive family tree linked to rich social profiles and memoirs.
2. **Cooperative Finance:** An internal family fund (Qard al-Hasan) and emergency assistance pool.
3. **Estate & Legacy Management:** Secure, encrypted wills and a digital safety deposit box that auto-delivers credentials and assets to heirs under predefined conditions.

Built with **pure PHP and zero external CSS/JS libraries**, the application is lightweight, responsive, offline-ready (PWA), and designed to last across generations without dependency rot.

## Problem Statement
Extended families face three primary threats to their unity and continuity over generations:

- **Spiritual & Historical Decay:** The oral histories, recipes, old letters, and wisdom of grandparents are lost when they pass away. Public social networks are cluttered and do not categorize family heritage.
- **Financial Disconnection:** Families lack unified cooperative savings programs. Traditional banking does not cater to interest-free internal family lending or anonymous emergency aid.
- **Estate & Probate Chaos:** Settling an estate in courts or notary publics is slow and stressful. Wills are lost, inheritance shares are disputed, and digital assets (crypto keys, online profiles, accounts) vanish because heirs do not have access to passwords.

## The Unified Solution: Pillars of Khandan

Instead of separate, fragmented systems, Khandan unifies all features into a cohesive, private social ecosystem centered around the family tree and personal profiles.

### Pillar A: Relational & Historical Core
- **Interactive SVG Family Tree:** A dynamic visualization where users can zoom, pan, and drag-and-drop connections. It maps generations (alive and deceased) and handles complex relationships (spouses, multiple marriages, adoptions).
- **Dynamic Profiles:** Clicking a node in the tree opens that member's social profile.
  - **For the Living:** Displays their biography, timeline, achievements (Wall of Fame), and private health history.
  - **For the Deceased:** Transitions into a Memorial Guestbook, displaying their oral biography, voice/video files, and a GPS-enabled grave locator.

### Pillar B: Unified Social Feed & Shared Archives
Instead of individual modules, family activities are aggregated in a private social feed categorized by hashtags:

- `#اسناد_قدیمی` (Old Document Archives): Digitized old letters, marriage contracts, and historical records.
- `#سفرنامه` (Travel Journals): Collaborative diaries and photo logs of family trips.
- `#دستور_پخت` (Family Recipes): Traditional recipes passed down through generations, with video tutorials.
- `#فیلم_مجلس` (Past Assembly Registry): Storing long-form videos of reunions, weddings, and memorial gatherings.

### Pillar C: Legal & Testamentary Vault
- **Multimedia Wills:** Members can record audio/video testaments or type written wills, signed digitally. These are stored securely and remain locked until verified by the Patriarch.
- **Smart Inheritance Calculator:** Fully integrated with the active family tree. Using rules from Iranian Civil Law, it automatically calculates the exact inheritance shares (first, second, and third degree heirs) of a deceased member's estate.
- **Digital Safety Deposit Box:** A secure vault where members store encrypted credentials (users/passwords), cryptographic private keys, OTP credentials, and title deeds. Using AES-256 encryption, these are automatically decrypted and delivered to designated heirs upon proof of death or administrative trigger.

### Pillar D: Cooperative Financials & Governance
- **Family Fund (صندوق قرض‌الحسنه):** A transparent ledger managing monthly contributions, micro-loan queues, and interest-free loan distributions.
- **Emergency Assist (صندوق همیاری):** A secure, anonymous sub-fund where members can request emergency aid, which is funded by voluntary donations from other members.
- **Dispute Arbitration (شورای حل اختلاف):** A private panel of family elders (ریش‌سفیدان) where disputes (over loans, estate, or relations) can be registered, debated, and resolved confidentially.
- **Internal Proxy Voting:** If a member cannot attend family decisions or fund votes, they can digitally assign their vote to another relative via an internal Power of Attorney.

## Technical Architecture

Khandan is built with strict architectural guidelines to ensure long-term stability and security:

- **No External Packages:** Writing custom CSS (with variables and backdrop-filters) and vanilla Javascript (for dragging nodes and recording media) ensures zero dependency rot.
- **PDO SQLite Layer:** Uses a single `khandan.db` file, which is highly portable, lightweight, and easy to backup or transfer.
- **End-to-End Encryption:** Vault items are encrypted server-side using AES-256-CBC via PHP's `openssl` functions, using a key derived from the user's secret passcode and database salt.
- **PWA Capabilities:** Service worker caching allows family members to access the shajareh and read profiles offline. It can be installed as a standalone app on iOS and Android.

## Security & Permission Matrix

The app defines three primary roles to ensure privacy:

1. **Patriarch (پدر خاندان):** Initializes the tree, creates invitation PINs, confirms relationships, approves loan allocations, and acts as the legal registrar for death triggers.
2. **Active Member (عضو فعال):** Can post to the feed, contribute to funds, request loans, manage their own digital vault, and draft their testament.
3. **Deceased Member (مرحوم):** Node lock is activated. The system freezes the account, opens the Memorial page, and automatically initiates the Digital Vault release protocols.

## Technical Details

- **Framework:** Pure PHP 8.x (no external packages, zero dependency rot)
- **Database:** SQLite3 (single file)
- **Frontend:** Vanilla HTML5, CSS3, JavaScript
- **Architecture:** MVC (controllers, models, views)
- **Encryption:** AES-256-CBC (user passcode + salt)
- **Storage:** Local file system (SQLite)
- **PWA:** Service worker, manifest.json, offline capabilities

## Use Cases

### Family History Preservation
- Recording oral histories of deceased family members
- Digitizing old documents and photos
- Creating a comprehensive family biography

### Financial Management
- Family fund management with transparent transactions
- Emergency assistance distribution
- Loan applications with transparent approval process

### Legacy Planning
- Digital will creation with multimedia support
- Automatic asset transfer to designated heirs
- Inheritance calculation based on Islamic law

### Communication
- Private family social feed
- Important announcements (births, deaths, celebrations)
- Family coordination and planning

## Target Users

### Primary Users
- **Patriarch (پدر خاندان):** Family founder and primary administrator
- **Active Members (اعضای فعال):** Family members with active participation
- **Deceased Members (مرحوم):** Family members who have passed away

### Secondary Users
- **Legal Advisors:** Lawyers and estate planners
- **Financial Advisors:** Family financial management consultants
- **Families:** All family members seeking digital preservation

## Benefits

### For Families
- Preserve family heritage and history
- Manage family finances transparently
- Ensure proper estate planning and inheritance
- Maintain family connections and communication

### For Technology Users
- No learning curve (familiar with web browsing)
- Offline capabilities with PWA
- No external dependencies
- High performance and reliability

### For Privacy and Security
- Complete data privacy (no cloud storage)
- Strong encryption for all sensitive data
- Role-based access control
- Secure data deletion

## Key Features

### Core Features
- Interactive family tree
- Multimedia profile management
- Digital vault for sensitive information
- Multimedia will creation
- Smart inheritance calculator
- Family fund management

### Advanced Features
- Emergency assistance fund
- Social feed with hashtags
- Document digitization
- Health history tracking
- Dispute resolution system
- Digital archive system

## Technical Implementation

### Architecture
- **Frontend:** HTML5, CSS3, Vanilla JavaScript
- **Backend:** PHP 8.x (PDO)
- **Database:** SQLite3 (single file)
- **Security:** AES-256-CBC encryption
- **Deployment:** FTP to `hamidrajabi.ir` under `/family`

### Development Workflow
1. Read all existing documentation to understand project structure
2. Use pure PHP, SQLite for data storage
3. Implement responsive design with no external dependencies
4. Create pixel-perfect replicas of existing designs
5. Ensure full functionality and performance
6. Test thoroughly on all devices

## Deployment

### Prerequisites
- PHP 8.x installed
- Write permissions for file system
- SQLite3 support enabled

### Local Development
1. Clone repository
2. Set up database using `db/setup.sql`
3. Configure FTP credentials in `config.php`
4. Run tests with `php -r "require 'tests/test.php';"

### FTP Deployment
- Host: ftp.hamidrabi.ir
- Port: 21
- Username: admin@hamidrai.ir
- Password: Aa@102030
- Remote Root: /family

## Files in This Directory

- `ai-prompt-fa.md`: این پیشوند هوش مصنوعی را ببینید
- `ai-prompt-en.md`: این پیشوند هوش مصنوعی را ببینید (English) 
- `architecture.md`: معماری تکنیکال، صفحه‌های PDO SQLite data-layer، CSS variables، APIs
- `development-guide.md`: دستورالعمل‌های کدگذاری (PHP, CSS variables, JS event structures)، استانداردهای امنیتی XSS/CSRF، قوانین آپلود فایل، اقدامات FTP deploy.
- `marketing-plan.html`: سند HTML پفرایند بازاریابی و تجاری‌سازی Khandan (از فن آور به مشتری)
- `planning.md`: نقشه راه گام‌به‌گام تکراری از نصب پایگاه داده تا آزمایش PWA
- `prerequisites.md`: عوامل زیست محیطی ضروری (PHP ۸.x extensions, write permissions, HTML5 client APIs)
- `proposal.html`: سند HTML پیشنهاد فنی و مفهومی Khandan (از فن آور به مصرف‌کننده)
- `proposal.md`: نسخه Markdown از پیشنهاد پروژه
- `README.md`: کاتالوگ مستندات پروژه Khandan (خاندان)
- `structure.md`: اسکریپت‌های اسکریپت‌های SQLite tables برای پایگاه داده، نقشه‌های مسیر.

All design modifications are complete, focusing on clean HTML structure, responsive design, and comprehensive feature documentation.

---

**Last Updated:** 2026

**For Technical Queries:** Please refer to development-guide.md and architecture.md for specific implementation details.

**For Business Questions:** Consult with project leadership for further clarification and requirements.

**Για τεχνικές ερωτήσεις:** Διαβάστε το development-guide.md και το architecture.md.

**For AI Integration:** This prompt provides all necessary context about the project to bootstrap conversations with any global model for the Khandan project (family lineage management system).

**For Documentation**: Check the docs/ directory for all project documentation, including architectural plans and development guidelines.

**For English Prompt**: Use ai-prompt-en.md for English language context for external applications.

**For Persian Prompt**: Use ai-prompt-fa.md for Persian language context for external applications.

This project demonstrates a comprehensive family lineage management system with secure data handling, offline capabilities, and complete privacy protection.

---

**note:** the project is completely documented and ready for external AI integration with comprehensive context about the Khandan (family lineage management) system.

**php PDO sqlite** 2026 architecture design & development plan in english/persian docs ready.

**The entire Khandan project (all docs, php sqlite, architecture pdf, etc.) is now fully documented and ready for external integration.**