# morning3tar/tpcsa architecture

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

- Interactive diagram: https://gitdiagram.com/morning3tar/tpcsa
- Repository: https://github.com/morning3tar/tpcsa

## Overview

##### Project type and purpose
- This is a terminal-based, open-source Python tool whose primary role is to scan one or more hosts over TLS, extract and analyze their X.509 certificates and TLS configurations, run security checks, and finally render results to the console or export them in various formats.

##### File structure
Top-level items:
- main.py       – entry point, CLI parsing and orchestration
- scanner.py    – core scanning & analysis logic
- targets.txt   – example input file for bulk scans
- results.html  – sample output in HTML
- requirements.txt – third-party dependencies
- README.md/.gitignore/LICENSE – project metadata

There are no subdirectories; the code lives in two main modules:
- main.py (CLI interface, argument parsing, mode switching)
- scanner.py (network I/O, certificate retrieval, analysis, report generation)

##### Insights from the README
- Uses Python 3.7+ and a small ecosystem of SSL/TLS and reporting libraries.
- Features a menu-driven interactive mode or full CLI mode.
- Supports exporting to CSV, JSON, HTML, Markdown.
- Performs certificate detail extraction, TLS protocol/cipher enumeration, security checks (expiration, weak algorithms, HSTS/HPKP) and renders colorized tables.

##### Detailed capture
- Export formats as forks from the Report Generator.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Input Layer
    CLI["CLI Interface"]:::frontend
    Targets["Targets Input File<br/>(targets.txt)"]:::file
    CLI -->|"targets list"| Targets
    CLI -->|"invoke scan"| ScannerEngine

    %% Scanning Pipeline
    ScannerEngine["Scanner Engine"]:::network
    CLI --> ScannerEngine
    ScannerEngine --> CertRetriever
    CertRetriever["Certificate Retriever<br/>(ssl.connect)"]:::network
    CertRetriever --> CertAnalyzer
    CertAnalyzer["Certificate Analyzer<br/>(cryptography.x509)"]:::analysis
    CertAnalyzer --> TLSAnalyzer
    TLSAnalyzer["TLS Config Analyzer<br/>(protocol & cipher enum)"]:::analysis
    TLSAnalyzer --> SecurityEngine
    SecurityEngine["Security Rules Engine<br/>(expiry, weak algos, HSTS/HPKP)"]:::analysis
    SecurityEngine --> ReportGen

    %% External Hosts
    HostCloud["Target Host<br/>(external)"]:::external
    HostCloud --> CertRetriever

    %% Reporting Layer
    ReportGen["Report Generator<br/>(console + CSV/JSON/HTML/MD)"]:::reporting
    ReportGen --> Console["Console Output"]:::reporting
    ReportGen --> CSV["Export CSV"]:::reporting
    ReportGen --> JSON["Export JSON"]:::reporting
    ReportGen --> HTML["Export HTML<br/>(results.html)"]:::reporting
    ReportGen --> MD["Export Markdown"]:::reporting

    %% Project Files & Metadata
    Requirements["Dependency Specification<br/>(requirements.txt)"]:::file
    README["Project Documentation<br/>(README.md)"]:::file
    License["License File<br/>(LICENSE)"]:::file
    Gitignore["Git Ignore Config<br/>(.gitignore)"]:::file

    %% Connections to project files
    CLI --- Requirements
    CLI --- README
    CLI --- License
    CLI --- Gitignore

    %% Click Events
    click CLI "https://github.com/morning3tar/tpcsa/blob/master/main.py"
    click ScannerEngine "https://github.com/morning3tar/tpcsa/blob/master/scanner.py"
    click CertRetriever "https://github.com/morning3tar/tpcsa/blob/master/scanner.py"
    click CertAnalyzer "https://github.com/morning3tar/tpcsa/blob/master/scanner.py"
    click TLSAnalyzer "https://github.com/morning3tar/tpcsa/blob/master/scanner.py"
    click SecurityEngine "https://github.com/morning3tar/tpcsa/blob/master/scanner.py"
    click ReportGen "https://github.com/morning3tar/tpcsa/blob/master/scanner.py"
    click Targets "https://github.com/morning3tar/tpcsa/blob/master/targets.txt"
    click HTML "https://github.com/morning3tar/tpcsa/blob/master/results.html"
    click Requirements "https://github.com/morning3tar/tpcsa/blob/master/requirements.txt"
    click README "https://github.com/morning3tar/tpcsa/blob/master/README.md"
    click License "https://github.com/morning3tar/tpcsa/tree/master/LICENSE"
    click Gitignore "https://github.com/morning3tar/tpcsa/blob/master/.gitignore"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef network fill:#90EE90,stroke:#333,stroke-width:1px
    classDef analysis fill:#FFA500,stroke:#333,stroke-width:1px
    classDef reporting fill:#DDA0DD,stroke:#333,stroke-width:1px
    classDef file fill:#F0E68C,stroke:#333,stroke-width:1px
    classDef external fill:#E0FFFF,stroke:#333,stroke-width:1px
```
