# ravija-pasalkar/team_mitrix architecture

> Architecture diagram of the GitHub repository ravija-pasalkar/team_mitrix, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ravija-pasalkar/team_mitrix
- Repository: https://github.com/ravija-pasalkar/team_mitrix

## Overview

##### Project Type and Purpose
- This is a full-stack, AI-powered Digital KYC (Know Your Customer) system with two web front-ends (user flow + admin portal) backed by a Python/Flask server, AI modules for OCR, face matching and liveness, and a MySQL database.

##### File Structure
- Root directory
- app.py        → main Flask backend serving user KYC endpoints
- OCR.py        → OCR and tamper-detection logic
- first.html, second.html  → standalone HTML pages for user onboarding flow
- templates/    → Flask templates (third.html, fourth.html)
- admin_portal/
- app.py        → Flask app for admin UI
- detect.py     → admin’s AI-driven analysis module
- index.html, script.js, styles.css → static assets for the admin portal
- requirements.txt, .vscode/ → environment & editor setup

##### Extract Key Architecture Insights from README
- User frontend collects documents, captures video+audio for liveness.
- Python back end orchestrates:
- OCR.py for document forgery detection (OCR + image comparison)
- Gemini GenAI API to generate dynamic spoken prompts
- Speech-to-text to verify the prompt was read correctly
- Face-matching module to compare live video frames with uploaded document photo
- Admin portal provides oversight and GenAI-driven analytics.
- MySQL used for persisting user data and KYC results.

##### Main Components & Their Interactions
a. User Browser (first.html → Flask app.py)
b. Flask Backend (app.py)
- Routes: `/upload-documents`, `/start-liveness`, `/submit-consent`
- Modules: OCR.py, AI-liveness, face matcher, Gemini API client
c. MySQL Database (kyc_verification)
d. External Service: Google Gemini API
e. Admin Portal (admin_portal/app.py + static assets + detect.py)

Data Flow Sequence:
1. User Browser → HTTP POST /upload-documents → Flask Backend
2. Flask calls OCR.py → returns tamper flag → stores result in MySQL
3. Flask requests Gemini API → generates prompt → returns to browser
4. Browser captures video+audio → HTTP POST /submit-liveness → Flask
5. Flask runs speech-to-text + face matcher → stores pass/fail in MySQL
6. Browser posts GDPR/DPDP consent → Flask finalizes status
7. Admin Browser → HTTP GET /admin-dashboard → Flask Admin App
8. Admin app calls detect.py & MySQL to render analytics

##### Architectural Patterns & Design Principles
- Separation of concerns: Presentation (HTML/JS), Application (Flask), AI Modules (OCR, GenAI wrapper, speech, face matcher), Data (MySQL)
- Modular AI services (OCR.py, detect.py) can be swapped or scaled independently
- Single-page flows in plain HTML/JS for rapid front-end changes without complex frameworks

##### Essential Details to Capture
- Distinct service endpoints for user vs. admin flows
- AI-pipeline ordering (OCR → prompt generation → liveness → face match)
- Data persistence interactions (read/write to MySQL)
- External dependency on Gemini API

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Onboarding Frontend
    subgraph "User Frontend" 
        direction TB
        UF1["first.html"]:::frontend
        UF2["second.html"]:::frontend
        UF3["third.html"]:::frontend
        UF4["fourth.html"]:::frontend
    end

    %% User Backend Service
    subgraph "Flask Backend (Python)" 
        direction TB
        Backend["app.py"]:::service
    end

    %% AI Engine Modules
    subgraph "AI Engine" 
        direction TB
        OCR["OCR & Tamper Detection (OCR.py)"]:::ai
        GenAI["GenAI Client"]:::ai
        Liveness["Liveness Checker"]:::ai
        FaceMatcher["Face Matcher"]:::ai
    end

    %% Database
    DB["MySQL (kyc_verification)"]:::db

    %% External API
    Gemini["Google Gemini API"]:::external

    %% Admin Portal
    subgraph "Admin Portal Service" 
        direction TB
        AdminApp["app.py"]:::service
        Detect["AI Analysis (detect.py)"]:::ai
        AdminUI["index.html\nscript.js\nstyles.css"]:::frontend
    end

    %% Data Flows - User Onboarding
    UF1 -->|"HTTP POST /upload-documents"| Backend
    Backend -->|"calls OCR"| OCR
    OCR -->|"tamper flag"| Backend
    Backend -->|"write result"| DB
    Backend -->|"requests prompt"| GenAI
    GenAI -->|"dynamic prompt"| Backend
    Backend -->|"serve prompt"| UF2

    UF2 -->|"HTTP POST /submit-liveness"| Backend
    Backend -->|"speech-to-text & face match"| Liveness
    Liveness -->|"transcript"| Backend
    Backend -->|"calls Face Matcher"| FaceMatcher
    FaceMatcher -->|"match result"| Backend
    Backend -->|"write result"| DB

    UF4 -->|"HTTP POST /submit-consent"| Backend
    Backend -->|"finalize status"| DB

    %% Admin Flows
    AdminUI -->|"HTTP GET /admin-dashboard"| AdminApp
    AdminApp -->|"calls detect.py"| Detect
    Detect -->|"analytics"| AdminApp
    AdminApp -->|"read/write"| DB

    %% Developer & Env
    VSCode[".vscode/"]:::config
    Req["requirements.txt"]:::config

    %% Click Events
    click UF1 "https://github.com/ravija-pasalkar/team_mitrix/blob/main/first.html"
    click UF2 "https://github.com/ravija-pasalkar/team_mitrix/blob/main/second.html"
    click UF3 "https://github.com/ravija-pasalkar/team_mitrix/blob/main/templates/third.html"
    click UF4 "https://github.com/ravija-pasalkar/team_mitrix/blob/main/templates/fourth.html"
    click Backend "https://github.com/ravija-pasalkar/team_mitrix/blob/main/app.py"
    click OCR "https://github.com/ravija-pasalkar/team_mitrix/blob/main/OCR.py"
    click AdminApp "https://github.com/ravija-pasalkar/team_mitrix/blob/main/admin_portal/app.py"
    click Detect "https://github.com/ravija-pasalkar/team_mitrix/blob/main/admin_portal/detect.py"
    click AdminUI "https://github.com/ravija-pasalkar/team_mitrix/blob/main/admin_portal/index.html"
    click AdminUI "https://github.com/ravija-pasalkar/team_mitrix/blob/main/admin_portal/script.js"
    click AdminUI "https://github.com/ravija-pasalkar/team_mitrix/blob/main/admin_portal/styles.css"
    click Req "https://github.com/ravija-pasalkar/team_mitrix/blob/main/requirements.txt"
    click VSCode "https://github.com/ravija-pasalkar/team_mitrix/tree/main/.vscode/"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#3399ff,color:#003366;
    classDef service fill:#d4edda,stroke:#28a745,color:#155724;
    classDef ai fill:#fff3cd,stroke:#ffc107,color:#856404;
    classDef db fill:#e2e3e5,stroke:#6c757d,color:#343a40,stroke-width:2px;
    classDef external fill:#f0f0f0,stroke:#aaaaaa,color:#333333,stroke-dasharray: 5 5;
    classDef config fill:#f8d7da,stroke:#dc3545,color:#721c24;
```
