# touero/opsariichthys-bidens architecture

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

- Interactive diagram: https://gitdiagram.com/touero/opsariichthys-bidens
- Repository: https://github.com/touero/opsariichthys-bidens

## Overview

##### Main Components

- API Layer:
- “api” directory, which houses the core functionality (api_core.py, api_master.py, constants_api.py).
- That it handles HTTP requests (GET/POST) and provides endpoints for accessing the various statistical datasets.

- Database Layer:
- “database” directory containing scripts like create_db.py, database.py, and model.py along with SQL scripts for both MySQL and SQLite.
- This component is responsible for establishing database connections, executing queries, and storing/retrieving statistical data.

- Logging Component:
- “logs” directory (with re_log.py) as the logging subsystem.
- This component captures and manages log information and error reporting for debugging and analytics.

- Deployment & Environment:
- Configuration and environment files like env.py and the GitHub workflows (located under .github/workflows) which illustrate CI/CD processes.

- Auxiliary or Driver Components:
- “local_driver.py” and “run.py” as entry points: run.py for local execution and docker_run.py for initiating the Docker container.

##### Architectural Patterns and Technologies

- That the system is designed with a layered architecture, where:
- The API layer acts as the controller/service entry point,
- The Database layer handles data access and persistence,
- And the Logging component manages monitoring and error reporting.
- Use of FastAPI as the main framework for the API layer.
- MySQL and SQLite as represented in the SQL scripts (and annotate which SQL flavor is used in each scenario).
- That Docker is used for environment encapsulation and streamlined deployment.

## Diagram (Mermaid)

```mermaid
flowchart TD
    ExternalClient["External Client (curl, Frontend)"]:::external

    subgraph "Deployment & Environment"
        Dockerfile["Dockerfile"]:::deploy
        Dockerignore[".dockerignore"]:::deploy
        DockerRun["docker_run.py"]:::deploy
        Env["env.py"]:::deploy
        Workflows[".github/workflows"]:::deploy
    end

    subgraph "Auxiliary/Driver Components"
        RunPy["run.py"]:::aux
        LocalDriver["local_driver.py"]:::aux
    end

    APISvc["API Service (FastAPI)"]:::api
    DatabaseSvc["Database Service (MySQL/SQLite)"]:::db
    LoggingSvc["Logging Service"]:::log

    ExternalClient -->|"HTTP_Request"| APISvc

    RunPy -->|"Local_Exec"| APISvc
    LocalDriver -->|"Local_Exec"| APISvc

    Dockerfile -->|"Deploy_Config"| APISvc
    Dockerignore -->|"Deploy_Config"| APISvc
    DockerRun -->|"Deploy_Config"| APISvc
    Env -->|"Deploy_Config"| APISvc
    Workflows -->|"Deploy_Config"| APISvc

    APISvc -->|"DB_Query"| DatabaseSvc
    APISvc -->|"Log_Entry"| LoggingSvc

    click APISvc "https://github.com/touero/opsariichthys-bidens/tree/master/api/"
    click DatabaseSvc "https://github.com/touero/opsariichthys-bidens/tree/master/database/"
    click LoggingSvc "https://github.com/touero/opsariichthys-bidens/tree/master/logs/"
    click Dockerfile "https://github.com/touero/opsariichthys-bidens/tree/master/Dockerfile"
    click Dockerignore "https://github.com/touero/opsariichthys-bidens/blob/master/.dockerignore"
    click DockerRun "https://github.com/touero/opsariichthys-bidens/blob/master/docker_run.py"
    click Env "https://github.com/touero/opsariichthys-bidens/blob/master/env.py"
    click Workflows "https://github.com/touero/opsariichthys-bidens/tree/master/.github/workflows/"
    click RunPy "https://github.com/touero/opsariichthys-bidens/blob/master/run.py"
    click LocalDriver "https://github.com/touero/opsariichthys-bidens/blob/master/local_driver.py"

    classDef external fill:#F9E79F,stroke:#333,stroke-width:2px;
    classDef api fill:#AED6F1,stroke:#333,stroke-width:2px;
    classDef db fill:#A9DFBF,stroke:#333,stroke-width:2px;
    classDef log fill:#FCF3CF,stroke:#333,stroke-width:2px;
    classDef deploy fill:#F5B7B1,stroke:#333,stroke-width:2px;
    classDef aux fill:#D2B4DE,stroke:#333,stroke-width:2px;
```
