# lunalynx12/sentra architecture

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

- Interactive diagram: https://gitdiagram.com/lunalynx12/sentra
- Repository: https://github.com/lunalynx12/sentra

## Overview

##### Project type and purpose
- This is a full-stack web application (“Sentra”) for file and URL threat scanning, built as an MVP of a malware analysis platform.
- The frontend is a React+TypeScript single-page app (Vite + TailwindCSS). The backend is a FastAPI service in Python using YARA rules for detection, persisting scan history to a database.

##### File structure
- Top-level directories:
- backend/
– src/main.py (FastAPI entrypoint)
– src/routes/scan.py (API endpoints)
– src/services/{file_scanner, url_scanner}.py (scan logic)
– src/database.py & models.py (ORM + schemas)
– yara_rules/ (collection of .yar rule files)
– ai.py, signatures.txt, docs for additional reference
- frontend/
– src/pages (HomePage, ScannerPage, RegisterPage, SignInPage)
– src/components (Header, Footer, hero, scanner, results)
– utils/mockScan (simulated data flows)
– Vite/Tailwind configs
- requirements.txt (backend deps)

##### README for additional insights
- Tech stack and feature list
- Scan flow: size check ➔ cache lookup ➔ actual scan ➔ DB store ➔ result display

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (React + TypeScript SPA)"
        direction TB
        Client["Client SPA"]:::frontend
        Main["Entry Point (main.tsx)"]:::frontend
        subgraph "Pages"
            direction TB
            HomePage["HomePage"]:::frontend
            ScannerPage["ScannerPage"]:::frontend
            RegisterPage["RegisterPage"]:::frontend
            SignInPage["SignInPage"]:::frontend
        end
        subgraph "UI Components"
            direction TB
            Header["Header"]:::frontend
            Footer["Footer"]:::frontend
            Hero["Hero Section"]:::frontend
            FileScannerComp["FileScanner"]:::frontend
            URLScannerComp["URLScanner"]:::frontend
            ScanProgress["ScanProgress"]:::frontend
            ScanTabs["ScanTabs"]:::frontend
            ScanHistory["ScanHistory"]:::frontend
            ResultDetails["ResultDetails"]:::frontend
        end
        MockScan["MockScan Analyzer (stub)"]:::external
    end

    %% Backend Layer
    subgraph "Backend (FastAPI Server)"
        direction TB
        APIServer["API Gateway\n(FastAPI Server)"]:::backend
        Routes["Scan Routes"]:::backend
        subgraph "Scanner Services"
            direction TB
            FileScannerSvc["File Scanner Service"]:::backend
            URLScannerSvc["URL Scanner Service"]:::backend
            ThreatCalc["Threat Level Calculator"]:::backend
        end
        RuleStore["YARA Rule Store"]:::datastore
        subgraph "Database Layer"
            direction TB
            DBConn["Database Connection"]:::backend
            ORMModels["ORM Models & Schemas"]:::backend
        end
        Docs["Docs & Signatures"]:::external
    end

    %% Data Store
    Database["Relational Database"]:::datastore

    %% External Services
    PaymentService["Payment/Subscription Service"]:::external

    %% Connections
    Client -->|"HTTP REST"| APIServer
    APIServer -->|"routes to"| Routes
    Routes -->|"calls"| FileScannerSvc
    Routes -->|"calls"| URLScannerSvc
    FileScannerSvc -->|"loads rules from"| RuleStore
    URLScannerSvc -->|"loads rules from"| RuleStore
    FileScannerSvc -->|"calculates threat"| ThreatCalc
    URLScannerSvc -->|"calculates threat"| ThreatCalc
    ThreatCalc -->|"writes scan result"| DBConn
    ORMModels -->|"defines schema"| DBConn
    Routes -->|"persists/retrieves"| DBConn
    DBConn -->|"stores in"| Database
    Routes -->|"responds to"| Client
    MockScan -.->|"fallback scan"| Routes
    APIServer -->|"billing on oversize"| PaymentService

    %% Click Events
    click Client "https://github.com/lunalynx12/sentra/tree/main/frontend/"
    click Main "https://github.com/lunalynx12/sentra/blob/main/frontend/src/main.tsx"
    click HomePage "https://github.com/lunalynx12/sentra/blob/main/frontend/src/pages/HomePage.tsx"
    click ScannerPage "https://github.com/lunalynx12/sentra/blob/main/frontend/src/pages/ScannerPage.tsx"
    click RegisterPage "https://github.com/lunalynx12/sentra/blob/main/frontend/src/pages/RegisterPage.tsx"
    click SignInPage "https://github.com/lunalynx12/sentra/blob/main/frontend/src/pages/SignInPage.tsx"
    click Header "https://github.com/lunalynx12/sentra/blob/main/frontend/src/components/Header.tsx"
    click Footer "https://github.com/lunalynx12/sentra/blob/main/frontend/src/components/Footer.tsx"
    click Hero "https://github.com/lunalynx12/sentra/blob/main/frontend/src/components/hero/Hero.tsx"
    click FileScannerComp "https://github.com/lunalynx12/sentra/blob/main/frontend/src/components/scanner/FileScanner.tsx"
    click URLScannerComp "https://github.com/lunalynx12/sentra/blob/main/frontend/src/components/scanner/URLScanner.tsx"
    click ScanProgress "https://github.com/lunalynx12/sentra/blob/main/frontend/src/components/scanner/ScanProgress.tsx"
    click ScanTabs "https://github.com/lunalynx12/sentra/blob/main/frontend/src/components/scanner/ScanTabs.tsx"
    click ScanHistory "https://github.com/lunalynx12/sentra/blob/main/frontend/src/components/results/ScanHistory.tsx"
    click ResultDetails "https://github.com/lunalynx12/sentra/blob/main/frontend/src/components/results/ResultDetails.tsx"
    click MockScan "https://github.com/lunalynx12/sentra/blob/main/frontend/src/utils/mockScan.ts"
    click APIServer "https://github.com/lunalynx12/sentra/blob/main/backend/src/main.py"
    click Routes "https://github.com/lunalynx12/sentra/blob/main/backend/src/routes/scan.py"
    click FileScannerSvc "https://github.com/lunalynx12/sentra/blob/main/backend/src/services/file_scanner.py"
    click URLScannerSvc "https://github.com/lunalynx12/sentra/blob/main/backend/src/services/url_scanner.py"
    click RuleStore "https://github.com/lunalynx12/sentra/tree/main/backend/yara_rules/"
    click DBConn "https://github.com/lunalynx12/sentra/blob/main/backend/src/database.py"
    click ORMModels "https://github.com/lunalynx12/sentra/blob/main/backend/src/models.py"
    click Docs "https://github.com/lunalynx12/sentra/blob/main/backend/docs/backend/yara.md"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,stroke-width:1px
    classDef backend fill:#D0FFD6,stroke:#28a745,stroke-width:1px
    classDef datastore fill:#FFE0B2,stroke:#e65100,stroke-width:1px
    classDef external fill:#E0E0E0,stroke:#6c757d,stroke-width:1px
```
