# erikat04/tfg_antivirus_erikat architecture

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

- Interactive diagram: https://gitdiagram.com/erikat04/tfg_antivirus_erikat
- Repository: https://github.com/erikat04/tfg_antivirus_erikat

## Overview

##### Project Type & Purpose
- Type: Full-stack, cross-platform mobile/desktop application.
- Purpose: Provide malware protection via hash-based detection, user account management, and quarantining capabilities.

##### File Structure
- Top-level “android”, “linux”, “windows” folders: platform-specific Flutter runners.
- “lib/”: Flutter Dart code, subdivided into:
– data_access (DAO interfaces & implementations for local DB)
– model (domain objects: File, User, Hash, Device, ForbiddenFolder)
– utils (isolates, DB utilities, app essentials)
– viewmodels (state & business logic providers)
– views & widgets (UI layer)
- “lib/database.sql”: schema for SQLite.
- “integration_test”: end-to-end UI tests.
- “pubspec.yaml”: dependencies (Flutter, HTTP, SQLite, etc.).
- External repos: FastAPI backend (remote MySQL), hosted on Vercel; local SQLite.

##### Key Insights from README
- Two data stores:
– Remote MySQL via FastAPI for user accounts & global fingerprint DB.
– Local SQLite for caching scans, quarantines, and settings.
- Core features:
– Account lifecycle (login/logout, profile, password change).
– File scanning (background isolates, recursive traversal, quarantining).
– Permissions management (deny/restore/delete).
- External services: FreeDB (MySQL host), Vercel (API host).

##### Components & Relationships
a. Main Components
1. Flutter Client (Android/iOS, Linux, Windows):
- UI Layer (Views & Widgets)
- ViewModels (Business logic & state)
- Data Access Layer (DAOs, SQLite)
- Scan Isolate (background file traversal & hash computation)
2. Local SQLite Database
3. FastAPI Backend (hosted on Vercel)
4. Remote MySQL Database (FreeDB)
5. File System (host OS folders & files)
6. External Services (Authentication, Hosting)
b. Relationships & Data Flows
- UI ↔ ViewModels: user actions trigger state updates.
- ViewModels ↔ DAOs: read/write local SQLite (settings, cached scan results, quarantine list).
- Scan Isolate → File System: recursive hashing of files.
- ViewModels ↔ FastAPI API: HTTP calls for user management, remote fingerprint queries, sync quarantine status.
- FastAPI ↔ MySQL: CRUD on users, fingerprints, device records.
c. Architectural Patterns & Principles
- MVVM (Model–View–ViewModel) in Flutter
- Repository/DAO pattern for data access
- Isolate for heavy background compute (scan)
- Clean separation: Presentation / Business Logic / Data
d. Key Technologies & Frameworks
- Flutter & Dart: Client UI & logic
- SQLite (sqflite plugin): local persistence
- FastAPI & Python: backend API
- MySQL: central database
- Vercel: API hosting
- FreeDB: remote MySQL hosting

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Flutter Client Container
    subgraph "Flutter Client" 
        direction TB
        subgraph "UI Layer"
            direction TB
            Views["Views & Widgets"]:::ui
            click Views "https://github.com/erikat04/tfg_antivirus_erikat/tree/main/lib/views/"
            Widgets["Dialogs, AppDrawer, DropdownMenuItem"]:::ui
            click Widgets "https://github.com/erikat04/tfg_antivirus_erikat/tree/main/lib/widgets/"
        end

        subgraph "ViewModels"
            direction TB
            AnalysisProvider["AnalysisProvider"]:::logic
            LanguageProvider["LanguageProvider"]:::logic
            StyleProvider["StyleProvider"]:::logic
            UserDataProvider["UserDataProvider"]:::logic
            click AnalysisProvider "https://github.com/erikat04/tfg_antivirus_erikat/blob/main/lib/viewmodels/analysis_provider.dart"
            click LanguageProvider "https://github.com/erikat04/tfg_antivirus_erikat/blob/main/lib/viewmodels/language_provider.dart"
            click StyleProvider "https://github.com/erikat04/tfg_antivirus_erikat/blob/main/lib/viewmodels/style_provider.dart"
            click UserDataProvider "https://github.com/erikat04/tfg_antivirus_erikat/blob/main/lib/viewmodels/user_data_provider.dart"
        end

        subgraph "Data Access Layer"
            direction TB
            DAOs["DAO Interfaces & Implementations"]:::datastore
            click DAOs "https://github.com/erikat04/tfg_antivirus_erikat/tree/main/lib/data_access/"
            SQLiteSchema["SQLite Schema"]:::datastore
            click SQLiteSchema "https://github.com/erikat04/tfg_antivirus_erikat/blob/main/lib/database.sql"
        end

        subgraph "Domain Models"
            direction TB
            Models["Device, File, User, Hash, ForbiddenFolder, APIContent"]:::model
            click Models "https://github.com/erikat04/tfg_antivirus_erikat/tree/main/lib/model/"
        end

        ScanIsolate["Scan Isolate"]:::logic
        click ScanIsolate "https://github.com/erikat04/tfg_antivirus_erikat/blob/main/lib/utils/scan_isolate.dart"

        subgraph "Utilities"
            direction TB
            Utils["App Essentials & DB Utils"]:::utility
            click Utils "https://github.com/erikat04/tfg_antivirus_erikat/tree/main/lib/utils/"
        end

        Views -->|interacts with| AnalysisProvider
        Widgets -->|interacts with| AnalysisProvider
        AnalysisProvider -->|calls| DAOs
        LanguageProvider -->|calls| DAOs
        StyleProvider -->|calls| DAOs
        UserDataProvider -->|calls| DAOs
        DAOs -->|reads/writes| SQLiteSchema
        AnalysisProvider -->|spawns| ScanIsolate
        ScanIsolate -->|accesses| FileSystem
        Utils --> AnalysisProvider
    end

    %% Local DB
    SQLiteDB["Local SQLite Database"]:::datastore
    SQLiteSchema --> SQLiteDB

    %% File System
    FileSystem["Host File System"]:::external

    %% FastAPI Backend
    subgraph "FastAPI Backend (Vercel)" 
        direction TB
        API["FastAPI API"]:::backend
    end
    API -->|CRUD operations| MySQLDB

    %% Remote DB
    MySQLDB["Remote MySQL Database"]:::datastore

    %% External Services
    subgraph "External Services"
        direction TB
        AuthService["Authentication Service"]:::external
        Hosting["Vercel Host"]:::external
    end

    %% Platform Runners
    subgraph "Platform Runners"
        direction TB
        Android["Android Runner"]:::platform
        Linux["Linux Runner"]:::platform
        Windows["Windows Runner"]:::platform
        click Android "https://github.com/erikat04/tfg_antivirus_erikat/tree/main/android/"
        click Linux "https://github.com/erikat04/tfg_antivirus_erikat/tree/main/linux/"
        click Windows "https://github.com/erikat04/tfg_antivirus_erikat/tree/main/windows/"
    end

    %% Integration Tests & Config
    IntegrationTests["E2E Integration Tests"]:::test
    click IntegrationTests "https://github.com/erikat04/tfg_antivirus_erikat/blob/main/integration_test/login_integration_test.dart"
    Pubspec["Dependency Config (pubspec.yaml)"]:::config
    click Pubspec "https://github.com/erikat04/tfg_antivirus_erikat/blob/main/pubspec.yaml"

    %% Connections across layers
    AnalysisProvider -->|HTTP over TLS| API
    UserDataProvider -->|HTTP over TLS| API
    API -->|hosted on| Hosting
    API -->|auth via| AuthService

    %% Legend (as subgraph for styling)
    subgraph "Legend"
        direction TB
        UINode["UI Components"]:::ui
        LogicNode["Logic & Providers"]:::logic
        DataNode["Data Stores"]:::datastore
        BackendNode["Backend Service"]:::backend
        ExternalNode["External Services"]:::external
        ModelNode["Domain Models"]:::model
        UtilityNode["Utilities"]:::utility
        PlatformNode["Platform Runners"]:::platform
        TestNode["Integration Tests"]:::test
        ConfigNode["Configurations"]:::config
    end

    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef logic fill:#98FB98,stroke:#000,stroke-width:1px
    classDef datastore fill:#FFA500,stroke:#000,stroke-width:1px
    classDef backend fill:#FFD700,stroke:#000,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#000,stroke-width:1px
    classDef model fill:#FFB6C1,stroke:#000,stroke-width:1px
    classDef utility fill:#E6E6FA,stroke:#000,stroke-width:1px
    classDef platform fill:#F0E68C,stroke:#000,stroke-width:1px
    classDef test fill:#FFE4E1,stroke:#000,stroke-width:1px
    classDef config fill:#E0FFFF,stroke:#000,stroke-width:1px
```
