# thecybersandeep/apkauditor architecture

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

- Interactive diagram: https://gitdiagram.com/thecybersandeep/apkauditor
- Repository: https://github.com/thecybersandeep/apkauditor

## Overview

1. **Overall shape**
   - This is a **single-page, fully client-side APK analysis tool**.
   - The architecture is intentionally flat: `index.html` provides the UI, `apk-analyzer.js` contains nearly all analysis logic, and `lib/` holds third-party browser libraries.
   - There is **no backend service, database, or upload pipeline**; the APK is processed entirely in the user’s browser.

2. **Primary boundary: browser-only execution**
   - The key architectural boundary is between the **local APK file chosen by the user** and the **in-memory analysis workspace** inside the browser.
   - All extraction, parsing, scanning, browsing, and PDF generation happen locally, so the system’s trust and privacy model depends on client-side execution only.

3. **Presentation layer**
   - `index.html` is the presentation shell for the whole product.
   - It hosts the drag-and-drop entry point, tabbed views, search, findings navigation, code browsing, manifest/component views, and report export controls.
   - Since there is no server-rendered layer, the UI is the main orchestration surface for the analysis workflow.

4. **Analysis engine**
   - `apk-analyzer.js` is the core subsystem and likely acts as both parser and coordinator.
   - It is responsible for taking the APK archive, unpacking its contents, dispatching parsers for different file types, building the analysis model, and wiring results back to the UI.
   - The repository structure suggests a **monolithic client-side analyzer** rather than a set of isolated services.

5. **APK ingestion and archive extraction**
   - The first data flow is: **APK file → ZIP extraction → file inventory**.
   - `JSZip` from `lib/jszip.min.js` is used to read the APK as a ZIP archive and enumerate its internal files.
   - This extracted file set becomes the shared source for later subsystems such as DEX analysis, manifest parsing, file explorer, and tracker detection.

6. **DEX analysis pipeline**
   - Multi-DEX support means the analyzer processes `classes.dex` through `classes9.dex` as a combined code corpus.
   - The DEX subsystem turns bytecode into higher-level representations: Java-like pseudocode, Smali disassembly, class trees, method lists, field lists, and string tables.
   - This is the main source of evidence for both code browsing and many security findings.

7. **Security scanning subsystem**
   - A rule-based scanner searches the decompiled code and extracted strings for security issues.
   - The rules cover several domains: storage misuse, weak crypto, insecure network handling, component exposure, WebView misconfiguration, secrets, reflection/dynamic loading, and native library usage.
   - Findings are enriched with security taxonomy labels such as **CWE**, **OWASP Mobile Top 10**, and **MASVS**, which makes the scanner a reporting layer as well as a detection layer.

8. **Android manifest and component analysis**
   - The manifest parser decodes binary AXML to expose app metadata and security-relevant configuration.
   - It extracts exported activities, services, receivers, providers, permissions, SDK levels, backup settings, deep links, and custom permissions.
   - Component inspection sits on top of this and generates testable ADB commands for exported entry points, making it a specialized analysis view rather than a separate pipeline.

9. **Certificate and signing analysis**
   - The tool also parses APK signing certificates from PKCS#7/DER data.
   - This is a distinct subsystem because it does not depend on DEX decompilation; it operates on the APK’s signing metadata.
   - In architecture terms, it is a package-level trust and provenance check alongside code and manifest analysis.

10. **Tracker and SDK detection**
   - Tracker detection is implemented as a string/signature matching layer over the extracted DEX content.
   - It identifies common ad SDKs, analytics libraries, crash reporters, and payment libraries.
   - This subsystem is separate from security scanning: it is about third-party ecosystem fingerprinting rather than vulnerability detection.

11. **File explorer and artifact viewing**
   - The file explorer exposes the APK as a browsable package, not just as code.
   - It supports inspection of XML, JSON, images, SQLite databases, native `.so` files, and other embedded assets with appropriate renderers such as syntax highlighting or hex view.
   - This is the artifact exploration boundary between raw package contents and derived analysis results.

12. **Reporting and export**
   - Findings can be exported into a PDF report using `jspdf` from `lib/jspdf.umd.min.js`.
   - The report layer consumes the already-built analysis model rather than rerunning analysis, which keeps reporting as a downstream output stage.
   - That makes the flow: **analysis model → UI views and PDF report**.

13. **Key runtime and dependency implications**
   - The runtime is a **modern browser**; the README explicitly targets Chrome, Firefox, and Edge.
   - The project is JavaScript-only on the client side, which shapes everything: memory-based processing, local file access via browser APIs, and no external calls.
   - The only substantive third-party dependencies are ZIP extraction and PDF generation.

14. **Deployment and hosting**
   - `CNAME` indicates the project is meant to be hosted as a static site, likely via a custom domain.
   - That fits the architecture: static assets served to the browser, with all meaningful computation happening after the page loads.
   - For diagramming, treat deployment as a static front end with no application server.

15. **Good diagram summary**
   - The main architecture diagram should show:
     - User drops APK into browser UI
     - UI passes file to client-side analyzer
     - Analyzer extracts archive contents
     - Parallel parsers process DEX, manifest, certificates, and assets
     - Rule engine produces security findings and tracker/component metadata
     - UI renders tabs and search results
     - PDF export consumes the same analysis results
   - The critical architectural message is that this is a **local, browser-based APK forensics and security analysis pipeline**, not a networked application.

Main entry points: [`apk-analyzer.js`](https://github.com/thecybersandeep/apkauditor/blob/main/apk-analyzer.js) (Analyzer Core), [`index.html`](https://github.com/thecybersandeep/apkauditor/blob/main/index.html) (UI Shell)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser_app["Browser App"]
  node_user_apk["APK File<br/>input artifact"]
  node_index_html["UI Shell<br/>single-page UI<br/>[index.html]"]
end

subgraph group_client_analysis["Client Analysis"]
  node_apk_analyzer_js["Analyzer Core<br/>client-side orchestrator<br/>[apk-analyzer.js]"]
  node_archive_extract["Archive Extract<br/>zip unpacking"]
  node_file_inventory[("File Inventory<br/>package contents")]
  node_dex_pipeline["DEX Pipeline<br/>bytecode analysis"]
  node_decompiled_code["Code Views<br/>pseudocode and smali"]
  node_manifest_parser["Manifest Parser<br/>binary AXML parser"]
  node_component_view["Components<br/>entry-point analysis"]
  node_certificate_parser["Signing Check<br/>certificate analysis"]
  node_tracker_detector{{"Tracker Scan<br/>signature matching"}}
  node_security_scanner{{"Security Rules<br/>rule-based scanner"}}
  node_findings_model[("Findings Model<br/>analysis results")]
  node_artifact_browser["Artifact Browser<br/>file explorer"]
  node_pdf_export["PDF Export<br/>report generation"]
end

subgraph group_vendor_libs["Vendor Libraries"]
  node_jszip_lib["JSZip<br/>archive library"]
  node_jspdf_lib["jsPDF<br/>pdf library"]
end

node_user_apk -->|"drop/select"| node_index_html
node_index_html -->|"invoke"| node_apk_analyzer_js
node_apk_analyzer_js -->|"read archive"| node_jszip_lib
node_jszip_lib -->|"enumerate files"| node_archive_extract
node_archive_extract -->|"build inventory"| node_file_inventory
node_file_inventory -->|"provide dex"| node_dex_pipeline
node_dex_pipeline -->|"emit views"| node_decompiled_code
node_file_inventory -->|"provide manifest"| node_manifest_parser
node_manifest_parser -->|"summarize"| node_component_view
node_file_inventory -->|"provide signing data"| node_certificate_parser
node_file_inventory -->|"browse assets"| node_artifact_browser
node_dex_pipeline -->|"fingerprint"| node_tracker_detector
node_dex_pipeline -->|"scan code"| node_security_scanner
node_manifest_parser -->|"scan config"| node_security_scanner
node_tracker_detector -->|"record results"| node_findings_model
node_security_scanner -->|"record findings"| node_findings_model
node_component_view -->|"add metadata"| node_findings_model
node_certificate_parser -->|"add provenance"| node_findings_model
node_artifact_browser -->|"link artifacts"| node_findings_model
node_findings_model -->|"render tabs"| node_index_html
node_findings_model -->|"export report"| node_pdf_export
node_pdf_export -->|"generate pdf"| node_jspdf_lib
node_apk_analyzer_js -->|"assemble model"| node_findings_model

click node_index_html "https://github.com/thecybersandeep/apkauditor/blob/main/index.html"
click node_apk_analyzer_js "https://github.com/thecybersandeep/apkauditor/blob/main/apk-analyzer.js"

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_user_apk,node_index_html toneBlue
class node_apk_analyzer_js,node_archive_extract,node_file_inventory,node_dex_pipeline,node_decompiled_code,node_manifest_parser,node_component_view,node_certificate_parser,node_tracker_detector,node_security_scanner,node_findings_model,node_artifact_browser,node_pdf_export toneAmber
class node_jszip_lib,node_jspdf_lib toneMint
```

## Components

### Browser App

Static single-page APK analysis tool running fully in the browser.

- **APK File**: input artifact · Local APK selected or dropped by the user for analysis.
- [UI Shell](https://github.com/thecybersandeep/apkauditor/blob/main/index.html): single-page UI · Presentation layer with drag-and-drop entry, tabs, search, findings, artifact views, and export controls. · `index.html`

### Client Analysis

In-browser APK ingestion, parsing, scanning, browsing, and reporting pipeline.

- [Analyzer Core](https://github.com/thecybersandeep/apkauditor/blob/main/apk-analyzer.js): client-side orchestrator · Monolithic browser-side engine that coordinates extraction, parsing, scanning, and model assembly. · `apk-analyzer.js`
- **Archive Extract**: zip unpacking · Reads the APK as a ZIP archive and enumerates internal files.
- **File Inventory**: package contents · Shared in-memory set of extracted APK files used by downstream analyses.
- **DEX Pipeline**: bytecode analysis · Processes classes.dex through multi-DEX inputs into code representations and symbols.
- **Code Views**: pseudocode and smali · Java-like output, Smali disassembly, class trees, method lists, field lists, and strings.
- **Manifest Parser**: binary AXML parser · Decodes AndroidManifest metadata and component configuration from binary XML.
- **Components**: entry-point analysis · Summarizes exported activities, services, receivers, providers, permissions, and test commands.
- **Signing Check**: certificate analysis · Parses APK signing certificates and provenance metadata from PKCS#7 or DER data.
- **Tracker Scan**: signature matching · Fingerprints ads, analytics, crash reporting, payment, and other third-party SDKs.
- **Security Rules**: rule-based scanner · Finds weak crypto, insecure storage, WebView issues, secrets, reflection, native usage, and other risks.
- **Findings Model**: analysis results · Unified in-memory result set consumed by UI views and report export.
- **Artifact Browser**: file explorer · Browses XML, JSON, images, SQLite databases, native libraries, and other embedded assets.
- **PDF Export**: report generation · Builds downloadable reports from the completed analysis model.

### Vendor Libraries

Third-party browser dependencies used for archive reading and PDF export.

- **JSZip**: archive library · Browser ZIP library used to read APK archives.
- **jsPDF**: pdf library · Browser PDF library used for report generation.

## Connections

- APK File → UI Shell: drop/select · User provides the APK through the browser interface.
- UI Shell → Analyzer Core: invoke · UI hands the selected APK to the client-side analyzer.
- Analyzer Core → JSZip: read archive · Analyzer uses JSZip to unpack the APK as a ZIP archive.
- JSZip → Archive Extract: enumerate files · ZIP reader produces the APK file listing and contents.
- Archive Extract → File Inventory: build inventory · Extracted files become the shared package inventory.
- File Inventory → DEX Pipeline: provide dex · DEX analysis consumes the extracted bytecode files.
- DEX Pipeline → Code Views: emit views · Decompiler and disassembler outputs feed code browsing.
- File Inventory → Manifest Parser: provide manifest · Manifest analysis reads binary XML from the package inventory.
- Manifest Parser → Components: summarize · Parsed manifest data becomes exported component and permission views.
- File Inventory → Signing Check: provide signing data · Signing metadata is parsed from package contents.
- File Inventory → Artifact Browser: browse assets · Raw package contents are exposed through artifact viewers.
- DEX Pipeline → Tracker Scan: fingerprint · Tracker detection matches SDK and library signatures in code and strings.
- DEX Pipeline → Security Rules: scan code · Rule engine scans decompiled code and extracted strings for issues.
- Manifest Parser → Security Rules: scan config · Security checks also use manifest configuration and component exposure.
- Tracker Scan → Findings Model: record results · Tracker matches are added to the unified analysis model.
- Security Rules → Findings Model: record findings · Security findings are aggregated into the unified result set.
- Components → Findings Model: add metadata · Component exposure and testable entry points enrich the result model.
- Signing Check → Findings Model: add provenance · Signing and certificate data contribute trust-related metadata.
- Artifact Browser → Findings Model: link artifacts · Browsable files are connected back to the analysis workspace.
- Findings Model → UI Shell: render tabs · UI renders search, findings, code browsing, manifest views, and reports from the shared model.
- Findings Model → PDF Export: export report · PDF generation consumes the completed analysis model without rerunning analysis.
- PDF Export → jsPDF: generate pdf · Report output is built with jsPDF in the browser.
- Analyzer Core → Findings Model: assemble model · Analyzer coordinates all parsers and produces the unified workspace state.
