# justsamridhi/apk-xray architecture

> Architecture diagram of the GitHub repository justsamridhi/apk-xray, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/justsamridhi/apk-xray
- Repository: https://github.com/justsamridhi/apk-xray

## Overview

APK-Xray is a web application for evidence-first static analysis of Android APKs. A user selects an APK in the frontend; the API validates and parses it, deterministic rules produce findings and an exposure score, and the report builder optionally requests Gemma explanations before schema validation. The frontend normalizes and presents the report, evidence, and language options. The README documents these capabilities, while the supplied excerpts show only parts of several modules; links based on README documentation are cited there.

Main entry points: [`frontend/src/App.tsx`](https://github.com/justsamridhi/apk-xray/blob/main/frontend/src/App.tsx) (Application shell), [`backend/api.py`](https://github.com/justsamridhi/apk-xray/blob/main/backend/api.py) (FastAPI upload API), [`backend/report_builder.py`](https://github.com/justsamridhi/apk-xray/blob/main/backend/report_builder.py) (Report assembly), [`frontend/src/api.ts`](https://github.com/justsamridhi/apk-xray/blob/main/frontend/src/api.ts) (Upload client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend experience"]
  node_app["Application shell<br/>[App.tsx]"]
  node_ui["UI components<br/>[components.tsx]"]
  node_upload_client["Upload client<br/>[api.ts]"]
  node_report_model["Report normalization<br/>[report.ts]"]
  node_sample_report["Sample report<br/>[sampleReport.ts]"]
  node_theme["Theme settings<br/>[theme.ts]"]
end

subgraph group_api["Upload and orchestration"]
  node_api["FastAPI upload API<br/>[api.py]"]
  node_config["Runtime settings<br/>[config.py]"]
end

subgraph group_analysis["Static analysis and reports"]
  node_parser["APK manifest parser<br/>[apk_parser.py]"]
  node_scoring["Deterministic rules<br/>[scoring.py]"]
  node_report_builder["Report assembly<br/>[report_builder.py]"]
end

subgraph group_explain["Explanation and validation"]
  node_schema_validator["Report validation"]
  node_schema["Report JSON Schema<br/>[report.schema.json]"]
  node_gemma["Gemma adapter<br/>[gemma.py]"]
end

node_user(("APK reviewer"))
node_gemma_service["Google Gemma API"]

node_user -->|"selects APK"| node_app
node_app -->|"uploads file"| node_upload_client
node_app -->|"renders"| node_ui
node_app -->|"uses settings"| node_theme
node_app -->|"loads sample"| node_sample_report
node_app -->|"normalizes report"| node_report_model
node_upload_client -->|"sends HTTP upload"| node_api
node_api -->|"loads settings"| node_config
node_api -->|"parses APK"| node_parser
node_api -->|"builds report"| node_report_builder
node_report_builder -->|"calculates score"| node_scoring
node_report_builder -->|"validates report"| node_schema_validator
node_schema_validator -->|"loads schema"| node_schema
node_report_builder -->|"requests explanations"| node_gemma
node_gemma -.->|"generates explanations"| node_gemma_service
node_api -->|"returns report"| node_app
node_app -->|"presents findings"| node_user

click node_app "https://github.com/justsamridhi/apk-xray/blob/main/frontend/src/App.tsx"
click node_ui "https://github.com/justsamridhi/apk-xray/blob/main/frontend/src/components.tsx"
click node_upload_client "https://github.com/justsamridhi/apk-xray/blob/main/frontend/src/api.ts"
click node_report_model "https://github.com/justsamridhi/apk-xray/blob/main/frontend/src/report.ts"
click node_sample_report "https://github.com/justsamridhi/apk-xray/blob/main/frontend/src/sampleReport.ts"
click node_theme "https://github.com/justsamridhi/apk-xray/blob/main/frontend/src/theme.ts"
click node_api "https://github.com/justsamridhi/apk-xray/blob/main/backend/api.py"
click node_config "https://github.com/justsamridhi/apk-xray/blob/main/backend/config.py"
click node_parser "https://github.com/justsamridhi/apk-xray/blob/main/backend/parser/apk_parser.py"
click node_scoring "https://github.com/justsamridhi/apk-xray/blob/main/backend/scoring.py"
click node_report_builder "https://github.com/justsamridhi/apk-xray/blob/main/backend/report_builder.py"
click node_schema_validator "https://github.com/justsamridhi/apk-xray/blob/main/backend/validation/validate_report_schema.py"
click node_schema "https://github.com/justsamridhi/apk-xray/blob/main/backend/schema/report.schema.json"
click node_gemma "https://github.com/justsamridhi/apk-xray/blob/main/backend/gemma.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_ui,node_upload_client,node_report_model,node_sample_report,node_theme,node_user toneBlue
class node_api,node_config toneAmber
class node_parser,node_scoring,node_report_builder,node_gemma_service toneMint
class node_schema_validator,node_schema,node_gemma toneRose
```

## Components

### Frontend experience

- [Application shell](https://github.com/justsamridhi/apk-xray/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [UI components](https://github.com/justsamridhi/apk-xray/blob/main/frontend/src/components.tsx): `frontend/src/components.tsx`
- [Upload client](https://github.com/justsamridhi/apk-xray/blob/main/frontend/src/api.ts): `frontend/src/api.ts`
- [Report normalization](https://github.com/justsamridhi/apk-xray/blob/main/frontend/src/report.ts): `frontend/src/report.ts`
- [Sample report](https://github.com/justsamridhi/apk-xray/blob/main/frontend/src/sampleReport.ts): `frontend/src/sampleReport.ts`
- [Theme settings](https://github.com/justsamridhi/apk-xray/blob/main/frontend/src/theme.ts): `frontend/src/theme.ts`

### Upload and orchestration

- [FastAPI upload API](https://github.com/justsamridhi/apk-xray/blob/main/backend/api.py): `backend/api.py`
- [Runtime settings](https://github.com/justsamridhi/apk-xray/blob/main/backend/config.py): `backend/config.py`

### Static analysis and reports

- [APK manifest parser](https://github.com/justsamridhi/apk-xray/blob/main/backend/parser/apk_parser.py): `backend/parser/apk_parser.py`
- [Deterministic rules](https://github.com/justsamridhi/apk-xray/blob/main/backend/scoring.py): `backend/scoring.py`
- [Report assembly](https://github.com/justsamridhi/apk-xray/blob/main/backend/report_builder.py): `backend/report_builder.py`

### Explanation and validation

- [Report validation](https://github.com/justsamridhi/apk-xray/blob/main/backend/validation/validate_report_schema.py): `backend/validation/validate_report_schema.py`
- [Report JSON Schema](https://github.com/justsamridhi/apk-xray/blob/main/backend/schema/report.schema.json): `backend/schema/report.schema.json`
- [Gemma adapter](https://github.com/justsamridhi/apk-xray/blob/main/backend/gemma.py): `backend/gemma.py`

### Other components

- **APK reviewer**
- **Google Gemma API**

## Connections

- APK reviewer → Application shell: selects APK (evidence: `README.md`)
- Application shell → Upload client: uploads file (evidence: `frontend/src/App.tsx`)
- Application shell → UI components: renders (evidence: `frontend/src/App.tsx`)
- Application shell → Theme settings: uses settings (evidence: `frontend/src/App.tsx`)
- Application shell → Sample report: loads sample (evidence: `frontend/src/App.tsx`)
- Application shell → Report normalization: normalizes report (evidence: `frontend/src/App.tsx`)
- Upload client → FastAPI upload API: sends HTTP upload (evidence: `README.md`)
- FastAPI upload API → Runtime settings: loads settings (evidence: `backend/api.py`)
- FastAPI upload API → APK manifest parser: parses APK (evidence: `backend/api.py`)
- FastAPI upload API → Report assembly: builds report (evidence: `backend/api.py`)
- Report assembly → Deterministic rules: calculates score (evidence: `backend/report_builder.py`)
- Report assembly → Report validation: validates report (evidence: `backend/report_builder.py`)
- Report validation → Report JSON Schema: loads schema (evidence: `backend/validation/validate_report_schema.py`)
- Report assembly → Gemma adapter: requests explanations (evidence: `backend/report_builder.py`)
- Gemma adapter → Google Gemma API: generates explanations
- FastAPI upload API → Application shell: returns report (evidence: `README.md`)
- Application shell → APK reviewer: presents findings (evidence: `README.md`)
