# northernforce/reefscape architecture

> Architecture diagram of the GitHub repository northernforce/reefscape, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/northernforce/reefscape
- Repository: https://github.com/northernforce/reefscape

## Overview

##### Main Components

a. Robot Control Layer
- "Robot.java" at the top level as the main entry point
- It to "NFRRobotContainer" which manages robot configuration
- "NFRRobotChooser" to show robot selection capability

b. Subsystems Layer
- Main Drive class
- Module components (representing individual wheel modules)
- Gyro components
- Odometry handling

c. Command Layer
- "DriveCommands" and its relationship to the Drive subsystem
- Command flow from operator interface to subsystems

d. Input/Control Layer
- "ZippyOI" (Operator Interface) components:
- Driver OI
- Programmer OI
- How these interface with the command system

e. Hardware Interface Layer
- IO interfaces (GyroIO, ModuleIO)
- Both real hardware implementations (ModuleIOTalonFX, GyroIOPigeon2)
- Simulation implementations (ModuleIOSim)

##### Relationships and Data Flow

- Bidirectional communication between hardware interfaces and physical components

##### Technical Details

- Relationship between Constants.java and subsystem configuration
- Where autonomous and teleoperated code paths diverge
- How the PathplannerLib integrates with the drive subsystem
- Where simulation interfaces are available

##### Implementation Notes

- Use UML-style notation for class relationships where appropriate
- Notes about critical real-time processes (like PhoenixOdometryThread)
- Where configuration files (like deploy/test.chor) fit into the system

Remember to maintain a balance between showing enough detail to understand the system's architecture while not overwhelming the viewer with implementation-specific details. The focus should be on the high-level structure and the interactions between major components.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Style Definitions
    classDef core fill:#b3d9ff,stroke:#333,stroke-width:2px
    classDef subsystem fill:#90EE90,stroke:#333,stroke-width:2px
    classDef command fill:#FFE5B4,stroke:#333,stroke-width:2px
    classDef operator fill:#FFA07A,stroke:#333,stroke-width:2px
    classDef hardware fill:#D3D3D3,stroke:#333,stroke-width:2px
    classDef simulation fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef config fill:#F0E68C,stroke:#333,stroke-width:2px

    %% Core Robot Control
    Robot["Robot.java"]:::core
    NFRContainer["NFRRobotContainer"]:::core
    NFRChooser["NFRRobotChooser"]:::core

    %% Configuration
    subgraph ConfigLayer["Configuration Layer"]
        Constants["Constants.java"]:::config
        DriveConst["DriveConstants"]:::config
        ZippyConst["ZippyConstants"]:::config
        TunerConst["TunerConstants"]:::config
    end

    %% Operator Interface
    subgraph OILayer["Operator Interface Layer"]
        ZippyOI["ZippyOI"]:::operator
        DriverOI["ZippyDriverOI"]:::operator
        ProgrammerOI["ZippyProgrammerOI"]:::operator
    end

    %% Command Layer
    DriveCommands["DriveCommands"]:::command

    %% Drive Subsystem
    subgraph DriveSubsystem["Drive Subsystem"]
        Drive["Drive"]:::subsystem
        Module["Module"]:::subsystem
        OdometryThread["PhoenixOdometryThread"]:::subsystem
    end

    %% Hardware Interfaces
    subgraph HardwareLayer["Hardware Interface Layer"]
        GyroIO["GyroIO"]:::hardware
        ModuleIO["ModuleIO"]:::hardware
        GyroImpl["GyroIOPigeon2"]:::hardware
        ModuleImpl["ModuleIOTalonFX"]:::hardware
        ModuleSim["ModuleIOSim"]:::simulation
    end

    %% Vendor Integration
    subgraph VendorLayer["Vendor Integration"]
        PhoenixUtil["PhoenixUtil"]:::core
        PathPlanner["LocalADStarAK"]:::core
    end

    %% Relationships
    Robot --> NFRContainer
    NFRContainer --> NFRChooser
    NFRContainer --> Drive
    NFRContainer --> ZippyOI

    ZippyOI --> DriverOI
    ZippyOI --> ProgrammerOI
    DriverOI --> DriveCommands
    ProgrammerOI --> DriveCommands

    DriveCommands --> Drive
    Drive --> Module
    Drive --> OdometryThread
    
    Module --> ModuleIO
    ModuleIO --> ModuleImpl
    ModuleIO --> ModuleSim
    
    Drive --> GyroIO
    GyroIO --> GyroImpl

    ConfigLayer --> Drive
    Drive --> PathPlanner
    Drive --> PhoenixUtil

    %% Click Events
    click Robot "https://github.com/NorthernForce/Reefscape/blob/main/src/main/java/frc/robot/Robot.java"
    click NFRContainer "https://github.com/NorthernForce/Reefscape/blob/main/src/main/java/org/northernforce/util/NFRRobotContainer.java"
    click NFRChooser "https://github.com/NorthernForce/Reefscape/blob/main/src/main/java/org/northernforce/util/NFRRobotChooser.java"
    click Drive "https://github.com/NorthernForce/Reefscape/blob/main/src/main/java/frc/robot/subsystems/drive/Drive.java"
    click Module "https://github.com/NorthernForce/Reefscape/blob/main/src/main/java/frc/robot/subsystems/drive/Module.java"
    click OdometryThread "https://github.com/NorthernForce/Reefscape/blob/main/src/main/java/frc/robot/subsystems/drive/PhoenixOdometryThread.java"
    click GyroIO "https://github.com/NorthernForce/Reefscape/blob/main/src/main/java/frc/robot/subsystems/drive/GyroIO.java"
    click GyroImpl "https://github.com/NorthernForce/Reefscape/blob/main/src/main/java/frc/robot/subsystems/drive/GyroIOPigeon2.java"
    click ModuleIO "https://github.com/NorthernForce/Reefscape/blob/main/src/main/java/frc/robot/subsystems/drive/ModuleIO.java"
    click ModuleImpl "https://github.com/NorthernForce/Reefscape/blob/main/src/main/java/frc/robot/subsystems/drive/ModuleIOTalonFX.java"
    click ModuleSim "https://github.com/NorthernForce/Reefscape/blob/main/src/main/java/frc/robot/subsystems/drive/ModuleIOSim.java"
    click DriveCommands "https://github.com/NorthernForce/Reefscape/blob/main/src/main/java/frc/robot/commands/DriveCommands.java"
    click ZippyOI "https://github.com/NorthernForce/Reefscape/blob/main/src/main/java/frc/robot/zippy/ZippyOI.java"
    click DriverOI "https://github.com/NorthernForce/Reefscape/blob/main/src/main/java/frc/robot/zippy/ZippyDriverOI.java"
    click ProgrammerOI "https://github.com/NorthernForce/Reefscape/blob/main/src/main/java/frc/robot/zippy/ZippyProgrammerOI.java"
    click Constants "https://github.com/NorthernForce/Reefscape/blob/main/src/main/java/frc/robot/Constants.java"
    click DriveConst "https://github.com/NorthernForce/Reefscape/blob/main/src/main/java/frc/robot/util/DriveConstants.java"
    click ZippyConst "https://github.com/NorthernForce/Reefscape/blob/main/src/main/java/frc/robot/robots/ZippyConstants.java"
    click TunerConst "https://github.com/NorthernForce/Reefscape/blob/main/src/main/java/frc/robot/util/TunerConstants.java"
    click PhoenixUtil "https://github.com/NorthernForce/Reefscape/blob/main/src/main/java/frc/robot/util/PhoenixUtil.java"
    click PathPlanner "https://github.com/NorthernForce/Reefscape/blob/main/src/main/java/frc/robot/util/LocalADStarAK.java"
```
