# hhyo/archery architecture

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

- Interactive diagram: https://gitdiagram.com/hhyo/archery
- Repository: https://github.com/hhyo/archery

## Overview

##### Project Type and Purpose
- Archery is a web-based SQL auditing and query platform. Its primary purpose is to provide a user interface for running SQL queries, performing audit reviews, executing amendments, and managing database tasks.
- The README and overall repository structure indicate that it supports multiple database backends (MySQL, MariaDB, MsSQL, Oracle, etc.), along with features like data dictionary generation, slow log processing, and session management.
- It leverages several external tools (goInception for SQL auditing; SOAR for SQL optimization; etc.), making it a complex, service-oriented application.

##### Analyzing the File Structure
- The top-level directories show multiple components:
- The "archery" directory contains Django’s core settings and URL configuration files (asgi.py, settings.py, urls.py, wsgi.py) which indicates the main entry point for the Django application.
- The “common” directory holds authentication logic, middleware, dashboard utilities, templates, static resources, and utility modules. This is the shared code used application-wide.
- The “sql” directory and “sql_api” sub-directory include modules specific to SQL auditing, workflows, execution, and APIs exposing these services.
- The “src” and “docker-compose” folders indicate Dockerfiles, Kubernetes charts, and deployment scripts – showing how the application is containerized and orchestrated.
- There are clear separations of concerns with different modules, suggesting an MVC-like pattern managed by Django and an API layer that might be separately leveraged by external clients.

- Use clear and concise labels for each component (e.g., “Web Client”, “Django Application Server”, “SQL Workflow Module”, “External Database Connectors”, “Docker/Container Infrastructure”).
- Another style for deployment/infrastructure components (Docker, Kubernetes/Helm charts).
- Detail external integrations (e.g., goInception, SQLAdvisor) and show how these connect to the SQL auditing module.
- Optionally, include labels for asynchronous operations (queues or scheduled tasks) and how they interact with the primary workflow.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend Layer"
        FC["Web Client"]:::frontend
        SA["Static Assets"]:::frontend
        TP["Templates"]:::frontend
    end

    subgraph "Backend Layer"
        DA["Django Application Server"]:::backend
        DC["Django Core"]:::backend
        CB["Common Business Logic"]:::backend
        SW["SQL Workflow Module"]:::backend
        AP["API Layer"]:::backend
    end

    subgraph "Data/External Services"
        DB["Database Connectors"]:::db
        EX["External Service Connectors"]:::external
    end

    subgraph "Deployment/Infrastructure"
        DO["Docker & Container Configurations"]:::deployment
        OR["Orchestration Charts"]:::deployment
    end

    %% Frontend to Backend Interaction
    FC -->|"sends HTTP requests"| DA

    %% Backend Internal Breakdown
    DA -->|"uses"| DC
    DA -->|"calls"| CB
    DA -->|"triggers"| SW
    DA -->|"exposes"| AP

    %% SQL Workflow interactions with external data/services
    SW -->|"queries"| DB
    SW -->|"integrates"| EX
    AP -->|"fetches"| DB
    AP -->|"invokes"| EX

    %% Deployment and Orchestration
    OR -->|"orchestrates"| DO
    DO -->|"hosts"| DA

    %% Click events for component mapping
    click SA "https://github.com/hhyo/archery/tree/master/common/static"
    click TP "https://github.com/hhyo/archery/tree/master/common/templates"
    click DC "https://github.com/hhyo/archery/blob/master/archery/urls.py"
    click CB "https://github.com/hhyo/archery/blob/master/common/auth.py"
    click SW "https://github.com/hhyo/archery/blob/master/sql/sql_workflow.py"
    click AP "https://github.com/hhyo/archery/blob/master/sql_api/views.py"
    click DB "https://github.com/hhyo/archery/tree/master/sql/engines"
    click EX "https://github.com/hhyo/archery/tree/master/sql/plugins"
    click DO "https://github.com/hhyo/archery/tree/master/src/docker"
    click OR "https://github.com/hhyo/archery/tree/master/src/charts"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef db fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef external fill:#FFA07A,stroke:#000,stroke-width:2px;
    classDef deployment fill:#DDA0DD,stroke:#000,stroke-width:2px;
```
