# oldgalileo/bastille architecture

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

- Interactive diagram: https://gitdiagram.com/oldgalileo/bastille
- Repository: https://github.com/oldgalileo/bastille

## Overview

##### Main Components
- Frontend User Interface (UI):
- This is located in the “app” directory. Notice the Vue components (e.g., App.vue, Navigation.vue, Dashboard.vue), routing (app/src/router), state management (app/src/store), and build/config files (under app/build and app/config).
- The UI likely enables users to upload strategies, view tournament results, and configure tournaments.
- Backend Tournament Engine:
- The root-level files “main.go”, “server.go”, and “tournament.go” indicate that the core tournament logic and API server are implemented in Go.
- This server is responsible for orchestrating tournaments, scheduling matches, handling score calculations, and interfacing with strategy containers.
- Strategy Containerization Module:
- The “dock” directory (including “Dockerfile” and “relay.go”) is dedicated to setting up containerized environments wherein submitted strategies (written in any compiled language or Python as a starter) are run safely.
- The relay component likely handles the communication between the container (stdout/stdin) and the backend’s supervisor.
- Example Strategies:
- Located in the “examples” directory, these scripts (in Python, Bash, etc.) are sample strategies that help users get started.
- (Optional) Configuration/Deployment:
- There are various configuration files, such as .babelrc, webpack confs, and package.json, which underline the frontend building and deployment process.

##### Relationships and Data Flow
- Direction of Interaction:
- The Frontend communicates with the Backend over HTTP/REST (or possibly WebSockets) to submit strategies and fetch tournament results.
- The Backend orchestrates the tournament by launching containers using the Docker-related modules. It directs the containerized strategies via the “relay” mechanism to exchange moves through standard I/O.
- The examples serve as a reference for users on how to write strategies that interact with the containerized supervisor.
- Inside the container environment, show bi-directional communication with the strategy’s process (stdin and stdout streams) that feed back to the backend’s scoring logic.

##### Architectural Patterns and Design Principles
- Separation of Concerns:
- Clearly separate the frontend (Vue) from the backend (Go) and the strategy execution (Docker).
- Containerization:
- That each strategy runs in an isolated container, highlighting security and scalability foundations.
- Modularization:
- That the project is modular (with separate directories for UI, backend, docker setup, and examples) making it easy to extend or modify specific parts (like strategy handling or UI improvements).

##### Relevant Technologies and Frameworks
- Frontend Technologies: Vue.js, Webpack, Babel, and associated Node.js tooling.
- Backend Technologies: Go programming language, with modules deployed as server.go and tournament.go.
- Containerization: Docker (as seen in the “dock” directory), with specialized logic in relay.go to manage strategy container communication.
- Communication Interfaces: Use standard I/O for interacting with strategies, as described in the README’s strategy example.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Frontend Layer: Vue.js Application
    subgraph "Frontend (Vue.js Application)"
        F1["App.vue"]:::frontend
        F2["Navigation.vue"]:::frontend
        F3["Dashboard.vue"]:::frontend
        F4["Router"]:::frontend
        F5["Store"]:::frontend
        F6["Build Config"]:::frontend
        F7["App Config"]:::frontend
    end

    %% Backend Layer: Go Tournament Engine
    subgraph "Backend Tournament Engine (Go)"
        B1["main.go"]:::backend
        B2["server.go"]:::backend
        B3["tournament.go"]:::backend
    end

    %% Strategy Containerization Module
    subgraph "Strategy Containerization Module"
        C1["Dockerfile"]:::container
        C2["relay.go"]:::container
    end

    %% Example Strategies
    subgraph "Example Strategies"
        E1["allcoop.py"]:::examples
        E2["titfortat.bash"]:::examples
    end

    %% Interactions
    %% Frontend initiates API calls to Backend
    F1 -->|"APICalls"| B1

    %% Backend orchestrates container launches
    B2 -->|"LaunchContainer"| C1

    %% Bidirectional communication between Backend and Containerization (using standard I/O)
    C2 -->|"StdIn/StdOut"| B3
    B3 -->|"Feedback"| C2

    %% Backend sends tournament results back to Frontend
    B3 -->|"Results"| F3

    %% Example Strategies provide sample implementations to the Containerization module
    E1 -->|"ProvidesStrategy"| C1
    E2 -->|"ProvidesStrategy"| C1

    %% Styles
    classDef frontend fill:#ffdead,stroke:#000,stroke-width:2px;
    classDef backend fill:#add8e6,stroke:#000,stroke-width:2px;
    classDef container fill:#90ee90,stroke:#000,stroke-width:2px;
    classDef examples fill:#ffff99,stroke:#000,stroke-width:2px;

    %% Click Events
    click F1 "https://github.com/oldgalileo/bastille/tree/master/app/"
    click F2 "https://github.com/oldgalileo/bastille/blob/master/app/src/components/Navigation.vue"
    click F3 "https://github.com/oldgalileo/bastille/blob/master/app/src/components/Dashboard.vue"
    click F4 "https://github.com/oldgalileo/bastille/tree/master/app/src/router"
    click F5 "https://github.com/oldgalileo/bastille/tree/master/app/src/store"
    click F6 "https://github.com/oldgalileo/bastille/tree/master/app/build"
    click F7 "https://github.com/oldgalileo/bastille/tree/master/app/config"

    click B1 "https://github.com/oldgalileo/bastille/blob/master/main.go"
    click B2 "https://github.com/oldgalileo/bastille/blob/master/server.go"
    click B3 "https://github.com/oldgalileo/bastille/blob/master/tournament.go"

    click C1 "https://github.com/oldgalileo/bastille/tree/master/dock/Dockerfile"
    click C2 "https://github.com/oldgalileo/bastille/blob/master/dock/relay.go"

    click E1 "https://github.com/oldgalileo/bastille/blob/master/examples/allcoop.py"
    click E2 "https://github.com/oldgalileo/bastille/blob/master/examples/titfortat.bash"
```
