# regista6/ea-fc-automated-sbc-solving architecture

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

- Interactive diagram: https://gitdiagram.com/regista6/ea-fc-automated-sbc-solving
- Repository: https://github.com/regista6/ea-fc-automated-sbc-solving

## Overview

##### Project type and purpose
- This is a Python‐based command-line tool (full-stack only in the sense of input → processing → output) for solving EA FC Squad Building Challenges (SBCs) using integer programming.
- The README makes it clear: it reads club/player data (CSV), applies constraints from input.py, builds a CP-SAT model in optimize.py, runs Google OR-Tools to minimize total cost, and writes the squad to output.xlsx.

##### File structure
- Top level:
- input.py ‒ defines all SBC constraints (formation, max league, unique country, club, rarity, etc.) and objective settings
- main.py ‒ orchestrates data loading (CSV), preprocessing (filters), kicks off optimization
- optimize.py ‒ contains functions to create each constraint in the CP-SAT model and to solve it
- *.csv ‒ datasets for different clubs or a master input.csv for broad player data
- output.xlsx ‒ final squad result
- requirements.txt, LICENSE, README.md, .gitignore
- No front-end, no web server—purely a local Python pipeline.
- Dependencies controlled via requirements.txt; Google OR-Tools is the core solver.

##### README for additional insights
- The README walks through how to configure constraints in input.py, which lines to uncomment in optimize.py, and how to run main.py.
- It lists external integration points: a Chrome extension for data download and mentions FutDB API use for large datasets.

##### Detailed elements
- Configuration Module (input.py)
- Data Layer (pandas + CSV files)
- Preprocessor (main.py filters)
- Constraint Factory (optimize.py functions grouped by type: league, club, rarity, chemistry, etc.)
- OR-Tools CP-SAT Solver
- Output Writer (main.py + openpyxl)
- External Data Source (Chrome extension or API)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Data Sources
    subgraph "External Data Sources"
        direction TB
        ChromeExt["Chrome Extension"]:::external
        FutDB["FutDB API"]:::external
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        CSV1["input.csv"]:::data
        CSV2["Catamarca FC_23.csv"]:::data
        CSV3["Catamarca FC_24.csv"]:::data
        CSV4["Catamarca FC_25.csv"]:::data
        CSV5["Fc25Players.csv"]:::data
        CSV6["Frederik FC_24.csv"]:::data
        CSV7["Real_Madrid_FC_24.csv"]:::data
    end

    %% Code Modules
    subgraph "Code Modules"
        direction TB
        InputMod["input.py\n(Configuration Module)"]:::code
        MainMod["main.py\n(Orchestrator/CLI)"]:::code
        OptMod["optimize.py\n(Constraint Factory/Model Builder)"]:::code
    end

    %% Solver Engine
    Solver["Google OR-Tools CP-SAT\n(Solver Engine)"]:::solver

    %% Output
    Output["output.xlsx"]:::data

    %% Documentation & Setup
    subgraph "Documentation & Setup"
        direction TB
        README["README.md"]:::doc
        GITIGNORE[".gitignore"]:::doc
        LICENSEF["LICENSE"]:::doc
        REQ["requirements.txt"]:::doc
    end

    %% Flow
    ChromeExt --> CSV1
    ChromeExt --> CSV2
    FutDB --> CSV3
    FutDB --> CSV4
    FutDB --> CSV5
    FutDB --> CSV6
    FutDB --> CSV7

    CSV1 --> MainMod
    CSV2 --> MainMod
    CSV3 --> MainMod
    CSV4 --> MainMod
    CSV5 --> MainMod
    CSV6 --> MainMod
    CSV7 --> MainMod

    MainMod --> InputMod
    InputMod --> MainMod
    MainMod --> OptMod
    OptMod --> Solver
    Solver --> MainMod
    MainMod --> Output

    %% Click Events
    click InputMod "https://github.com/regista6/ea-fc-automated-sbc-solving/blob/master/input.py"
    click MainMod "https://github.com/regista6/ea-fc-automated-sbc-solving/blob/master/main.py"
    click OptMod "https://github.com/regista6/ea-fc-automated-sbc-solving/blob/master/optimize.py"
    click REQ "https://github.com/regista6/ea-fc-automated-sbc-solving/blob/master/requirements.txt"
    click Output "https://github.com/regista6/ea-fc-automated-sbc-solving/blob/master/output.xlsx"
    click README "https://github.com/regista6/ea-fc-automated-sbc-solving/blob/master/README.md"
    click GITIGNORE "https://github.com/regista6/ea-fc-automated-sbc-solving/blob/master/.gitignore"
    click LICENSEF "https://github.com/regista6/ea-fc-automated-sbc-solving/tree/master/LICENSE"
    click CSV1 "https://github.com/regista6/ea-fc-automated-sbc-solving/blob/master/input.csv"
    click CSV2 "https://github.com/regista6/ea-fc-automated-sbc-solving/blob/master/Catamarca FC_23.csv"
    click CSV3 "https://github.com/regista6/ea-fc-automated-sbc-solving/blob/master/Catamarca FC_24.csv"
    click CSV4 "https://github.com/regista6/ea-fc-automated-sbc-solving/blob/master/Catamarca FC_25.csv"
    click CSV5 "https://github.com/regista6/ea-fc-automated-sbc-solving/blob/master/Fc25Players.csv"
    click CSV6 "https://github.com/regista6/ea-fc-automated-sbc-solving/blob/master/Frederik FC_24.csv"
    click CSV7 "https://github.com/regista6/ea-fc-automated-sbc-solving/blob/master/Real_Madrid_FC_24.csv"

    %% Styles
    classDef code fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef data fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef external fill:#FFA500,stroke:#000,stroke-width:1px;
    classDef solver fill:#FFB6C1,stroke:#000,stroke-width:1px;
    classDef doc fill:#D3D3D3,stroke:#000,stroke-width:1px;
```
