# dzp2095/fcu architecture

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

- Interactive diagram: https://gitdiagram.com/dzp2095/fcu
- Repository: https://github.com/dzp2095/fcu

## Overview

##### Project type and purpose
- This is a research‐focused federated learning (FL) framework specialized for medical imaging, specifically enabling “client unlearning” in FL across two datasets: ICH (intracranial hemorrhage) and ISIC (skin lesions).
- Purpose: preprocess raw medical images, partition them into FL clients, run federated training with unlearning capability, and evaluate results.

##### File structure
- Top‐level:
- configs/ : YAML configs for different dataset runs and scripts
- scripts/ : dataset‐specific FL preprocessing pipelines
- src/ : core FL code (datasets, fl, model, modules, tasks, evaluation, utils)
- train.py : CLI entry point for launching FL training
- requirements.txt, .gitignore
- src breakdown:
- src/datasets : dataset wrappers & sampling
- src/fl : FL server & client implementations
- src/model : network architectures (DenseNet, generic net)
- src/modules : training loops, hooks, defaults
- src/tasks : task factories/registry for different dataset tasks
- src/evaluation : binary/multiclass evaluation strategies
- src/utils : argument parsing, device selection, logging

##### README
- Describes data download steps (Kaggle links), preprocessing, FL dataset generation, and training commands.
- Points to two main workflows (ICH and ISIC) driven by separate config files.
- Mentions paper citation.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Sources
    subgraph "Data Sources"
        DS_ISIC["ISIC2018 Raw Dataset"]:::data
        DS_ICH["RSNA-ICH Raw Dataset"]:::data
    end

    %% Preprocessing Layer
    subgraph "Preprocessing Layer"
        SCRIPT_ISIC["isic_prepare_fl.py"]:::data
        SCRIPT_ICH["ich_prepare_fl.py"]:::data
        SCRIPT_PRE_ICH["preprocess_ich.py"]:::data
        CONF_SCRIPTS_ISIC["configs/isic/scripts_conf.yaml"]:::config
        CONF_SCRIPTS_ICH["configs/ich/scripts_conf.yaml"]:::config
    end

    %% FL Data Partition
    FL_SHARDS["FL Dataset Shards per Client"]:::data

    %% CLI Entry
    CLI["train.py"]:::cli

    %% Task Orchestration
    subgraph "Task Orchestration"
        TASK_FACTORY["task_factory.py"]:::task
        TASK_REGISTRY["task_registry.py"]:::task
    end

    %% Dataset Wrappers & Sampling
    subgraph "Dataset Wrappers & Sampling"
        WRAPPER_ISIC["dataset_isic.py"]:::data
        WRAPPER_ICH["dataset_ich.py"]:::data
        SAMPLER["sampler.py"]:::data
    end

    %% Model Module
    subgraph "Model Module"
        DENSENET["densenet.py"]:::model
        NET["net.py"]:::model
    end

    %% Training Modules & Hooks
    subgraph "Training Modules"
        TRAINER["trainer.py"]:::module
        HOOKS["hooks.py"]:::module
        DEFAULTS["defaults.py"]:::module
    end

    %% Utilities
    subgraph "Utilities"
        ARGS["args_parser.py"]:::util
        DEVICE["device_selector.py"]:::util
        LOGGER["metric_logger.py"]:::util
        SAMPLE_DIR["sample_dirichlet.py"]:::util
    end

    %% Federated Learning Core
    subgraph "Federated Learning Core"
        SERVER["server.py"]:::core
        CLIENTS["client.py"]:::core
    end

    %% Evaluation Strategies
    subgraph "Evaluation"
        EVAL_STRATEGY["evaluation_strategy.py"]:::eval
        BINARY_EVAL["binary_evaluation.py"]:::eval
        MULTI_EVAL["multiclass_evaluation.py"]:::eval
    end

    %% Connections
    DS_ISIC -->|"input to"| SCRIPT_ISIC
    DS_ICH -->|"input to"| SCRIPT_ICH
    DS_ICH -->|"input to"| SCRIPT_PRE_ICH

    CONF_SCRIPTS_ISIC -->|"drives"| SCRIPT_ISIC
    CONF_SCRIPTS_ICH -->|"drives"| SCRIPT_ICH

    SCRIPT_ISIC -->|"creates shards"| FL_SHARDS
    SCRIPT_ICH -->|"creates shards"| FL_SHARDS
    SCRIPT_PRE_ICH -->|"creates shards"| FL_SHARDS

    FL_SHARDS -->|"fed into"| CLI

    CLI -->|"uses"| TASK_FACTORY
    CLI -->|"uses"| TASK_REGISTRY

    TASK_FACTORY -->|"selects"| WRAPPER_ISIC
    TASK_FACTORY -->|"selects"| WRAPPER_ICH
    TASK_FACTORY -->|"selects"| DENSENET
    TASK_FACTORY -->|"selects"| NET
    TASK_FACTORY -->|"selects"| TRAINER
    TASK_FACTORY -->|"selects"| HOOKS
    TASK_FACTORY -->|"selects"| DEFAULTS
    TASK_FACTORY -->|"selects"| EVAL_STRATEGY

    WRAPPER_ISIC -->|"samples data"| SAMPLER
    WRAPPER_ICH -->|"samples data"| SAMPLER

    %% Clients and Server interactions
    CLIENTS -->|"send updates"| SERVER
    SERVER -->|"aggregate & broadcast model"| CLIENTS
    CLIENTS -->|"train local model"| DENSENET
    CLIENTS -->|"train local model"| NET
    CLIENTS -->|"invoke hooks"| HOOKS
    CLIENTS -->|"log metrics"| LOGGER

    CLIENTS -->|"evaluate"| BINARY_EVAL
    CLIENTS -->|"evaluate"| MULTI_EVAL
    SERVER -->|"evaluate global"| EVAL_STRATEGY

    %% Click Events
    click SCRIPT_ISIC "https://github.com/dzp2095/fcu/blob/main/scripts/isic_prepare_fl.py"
    click SCRIPT_ICH "https://github.com/dzp2095/fcu/blob/main/scripts/ich_prepare_fl.py"
    click SCRIPT_PRE_ICH "https://github.com/dzp2095/fcu/blob/main/scripts/preprocess_ich.py"
    click CONF_SCRIPTS_ISIC "https://github.com/dzp2095/fcu/blob/main/configs/isic/scripts_conf.yaml"
    click CONF_SCRIPTS_ICH "https://github.com/dzp2095/fcu/blob/main/configs/ich/scripts_conf.yaml"
    click CLI "https://github.com/dzp2095/fcu/blob/main/train.py"
    click SERVER "https://github.com/dzp2095/fcu/blob/main/src/fl/server.py"
    click CLIENTS "https://github.com/dzp2095/fcu/blob/main/src/fl/client.py"
    click DENSENET "https://github.com/dzp2095/fcu/blob/main/src/model/densenet.py"
    click NET "https://github.com/dzp2095/fcu/blob/main/src/model/net.py"
    click WRAPPER_ISIC "https://github.com/dzp2095/fcu/blob/main/src/datasets/dataset_isic.py"
    click WRAPPER_ICH "https://github.com/dzp2095/fcu/blob/main/src/datasets/dataset_ich.py"
    click SAMPLER "https://github.com/dzp2095/fcu/blob/main/src/datasets/sampler.py"
    click TASK_FACTORY "https://github.com/dzp2095/fcu/blob/main/src/tasks/task_factory.py"
    click TASK_REGISTRY "https://github.com/dzp2095/fcu/blob/main/src/tasks/task_registry.py"
    click TRAINER "https://github.com/dzp2095/fcu/blob/main/src/modules/trainer.py"
    click HOOKS "https://github.com/dzp2095/fcu/blob/main/src/modules/hooks.py"
    click DEFAULTS "https://github.com/dzp2095/fcu/blob/main/src/modules/defaults.py"
    click BINARY_EVAL "https://github.com/dzp2095/fcu/blob/main/src/evaluation/binary_evaluation.py"
    click MULTI_EVAL "https://github.com/dzp2095/fcu/blob/main/src/evaluation/multiclass_evaluation.py"
    click EVAL_STRATEGY "https://github.com/dzp2095/fcu/blob/main/src/evaluation/evaluation_strategy.py"
    click ARGS "https://github.com/dzp2095/fcu/blob/main/src/utils/args_parser.py"
    click DEVICE "https://github.com/dzp2095/fcu/blob/main/src/utils/device_selector.py"
    click LOGGER "https://github.com/dzp2095/fcu/blob/main/src/utils/metric_logger.py"
    click SAMPLE_DIR "https://github.com/dzp2095/fcu/blob/main/utils/sample_dirichlet.py"

    %% Styles
    classDef data fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef config fill:#B0E0E6,stroke:#000,stroke-width:1px
    classDef cli fill:#FFD700,stroke:#000,stroke-width:1px
    classDef task fill:#FFA500,stroke:#000,stroke-width:1px
    classDef model fill:#FF8C00,stroke:#000,stroke-width:1px
    classDef module fill:#FFB347,stroke:#000,stroke-width:1px
    classDef util fill:#DDA0DD,stroke:#000,stroke-width:1px
    classDef core fill:#90EE90,stroke:#000,stroke-width:1px
    classDef eval fill:#D8BFD8,stroke:#000,stroke-width:1px
```
