# jaredgrxss/nexus architecture

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

- Interactive diagram: https://gitdiagram.com/jaredgrxss/nexus
- Repository: https://github.com/jaredgrxss/nexus

## Overview

##### Main Components
- Services Layer: Represent each trading strategy as its own component. Components like Reversion, Momentum, Regression, and Index-rebalance (found within the services directory) should be represented as separate modules.
- Helpers/Utilities: These common utilities handle logging, AWS integrations, database interactions, and cloud-related functions. They support the main services and can be grouped under a “Helpers” or “Utilities” block.
- AWS Infrastructure: Illustrate integrations with AWS SQS, SNS, and Secrets Manager. The CloudFormation templates (organized under the cloudformation directory) indicate how the AWS environment (both staging and production) is configured.
- Environment & Security: Include elements for environment management (encrypted .env files) and security modules covering GPG and secret decryption.
- Entry Point: The main application (app.py) indicates the integrated executable which ties together the various services and initialization code.

##### Relationships and Interactions
- Service to the Helpers block to show they rely on shared utilities (e.g., logging, database access, AWS cloud operations).
- Data flow between the services and AWS:

##### Architectural Patterns and Design Principles
- Security and Environment Management: Highlight secure secret management and encrypted environment file handling as key design considerations.

##### Incorporate Technology and Tools
- For AWS Integration, annotate components with the specific services (SQS, SNS, Secrets Manager).
- That the platform makes use of Python (with dependencies installed from requirements.txt) and uses tools like GPG for environment file encryption.
- Mention infrastructure automation via CloudFormation templates found in the cloudformation directory.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Environment & Security
    subgraph "Environment & Security"
        ES1["Encrypted Env (.env-production.gpg)"]:::es
        ES2["Encrypted Env (.env-staging.gpg)"]:::es
    end

    %% Core Application
    subgraph "Core Application"
        AE["Application Entry (app.py)"]:::app
    end

    %% Trading Services
    subgraph "Trading Services"
        RS["Reversion Service"]:::service
        MS["Momentum Service"]:::service
        RG["Regression Service"]:::service
        IR["Index-rebalance Service"]:::service
    end

    %% Helpers/Utilities
    subgraph "Helpers/Utilities"
        HL["Helpers & Utilities"]:::helper
    end

    %% AWS Infrastructure
    subgraph "AWS Infrastructure"
        SQS["AWS SQS"]:::aws
        SNS["AWS SNS"]:::aws
        SM["AWS Secrets Manager"]:::aws
        CF["CloudFormation Templates"]:::aws
    end

    %% Relationships & Data Flow
    ES1 -.-> AE
    ES2 -.-> AE

    AE -->|"orchestrates"| RS
    AE -->|"orchestrates"| MS
    AE -->|"orchestrates"| RG
    AE -->|"orchestrates"| IR

    RS -->|"uses"| HL
    MS -->|"uses"| HL
    RG -->|"uses"| HL
    IR -->|"uses"| HL

    RS -->|"sends_event"| SQS
    MS -->|"sends_event"| SQS
    RG -->|"sends_event"| SNS
    IR -->|"sends_event"| SNS

    AE -->|"retrieves_secrets"| SM

    CF -->|"deploys"| SQS
    CF -->|"deploys"| SNS
    CF -->|"deploys"| SM

    %% Click Events
    click AE "https://github.com/jaredgrxss/nexus/blob/main/app.py"
    click RS "https://github.com/jaredgrxss/nexus/blob/main/services/reversion.py"
    click MS "https://github.com/jaredgrxss/nexus/blob/main/services/momentum.py"
    click RG "https://github.com/jaredgrxss/nexus/blob/main/services/regression.py"
    click IR "https://github.com/jaredgrxss/nexus/blob/main/services/index-rebalance.py"
    click HL "https://github.com/jaredgrxss/nexus/tree/main/helpers/"
    click CF "https://github.com/jaredgrxss/nexus/tree/main/cloudformation/"
    click ES1 "https://github.com/jaredgrxss/nexus/blob/main/.env-production.gpg"
    click ES2 "https://github.com/jaredgrxss/nexus/blob/main/.env-staging.gpg"

    %% Styles
    classDef app fill:#ffcccc,stroke:#333,stroke-width:2px;
    classDef service fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef helper fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef aws fill:#ffeecc,stroke:#333,stroke-width:2px;
    classDef es fill:#ffebcc,stroke:#333,stroke-width:2px;
```
