# postig0x/farseer-eks-deployment architecture

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

- Interactive diagram: https://gitdiagram.com/postig0x/farseer-eks-deployment
- Repository: https://github.com/postig0x/farseer-eks-deployment

## Overview

##### Main Components

a) Application Layer:
- Frontend (Next.js application)
- Backend (Python application with LLM integration)
- LLM Service Integration (xAI's grok-beta)

b) Infrastructure Layer:
- Blue/Green Deployment Architecture
- Kubernetes Clusters (for each environment: Dev, QA, Production, SB)
- AWS Infrastructure (VPC, EC2, ALB)
- Docker Swarm (for container orchestration)

**[Client Browsers] → [ALB/Ingress] → [Frontend Service]**

**[Frontend Pods] ↔ [Backend Pods] ↔ [LLM Service]**

**[Kubernetes Cluster]**
- Blue Environment
- Green Environment

**[VPC]**
- [EC2 Instances]
- [Load Balancers]
- [IAM Roles]

##### Key Relationships to Highlight

a) Deployment Flow:
- CI/CD pipeline flow from Jenkins through environments
- Blue/green deployment switching mechanism

b) Network Flow:
- External traffic ingress through ALB
- Internal service communication
- Log data flow paths
- LLM API communication

##### Specific Implementation Details

- Log analysis workflow
- Error analysis pipeline
- Integration with xAI's grok-beta
- Kubernetes resource management
- Infrastructure as Code deployment (Terraform)

Remember to include version control indicators and documentation references, as this system appears to be actively developed and maintained across multiple environments.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Client Layer"
        Client["Web Browser"]
    end

    subgraph "Load Balancer Layer"
        ALB["Application Load Balancer"]:::aws
        click ALB "https://github.com/postig0x/farseer-eks-deployment/tree/main/Terraform/blue/Dev/modules/ALB"
    end

    subgraph "Application Layer"
        Frontend["Frontend Service"]:::frontend
        click Frontend "https://github.com/postig0x/farseer-eks-deployment/tree/main/farseer/frontend"
        Backend["Backend Service"]:::backend
        click Backend "https://github.com/postig0x/farseer-eks-deployment/tree/main/farseer/backend"
        LLM["xAI Grok-Beta Service"]:::external
        click LLM "https://github.com/postig0x/farseer-eks-deployment/blob/main/farseer/frontend/utils/simulateLLMResponse.ts"
    end

    subgraph "Kubernetes Layer"
        subgraph "Blue Environment"
            BlueFrontend["Frontend Pods"]:::blue
            click BlueFrontend "https://github.com/postig0x/farseer-eks-deployment/blob/main/k8s/blue/Dev/frontend/frontend-deployment.yaml"
            BlueBackend["Backend Pods"]:::blue
            click BlueBackend "https://github.com/postig0x/farseer-eks-deployment/blob/main/k8s/blue/Dev/backend/backend-deployment.yaml"
            BlueHPA["HPA Config"]:::blue
            click BlueHPA "https://github.com/postig0x/farseer-eks-deployment/blob/main/k8s/blue/Dev/backend/backend-hpa.yaml"
        end

        subgraph "Green Environment"
            GreenFrontend["Frontend Pods"]:::green
            click GreenFrontend "https://github.com/postig0x/farseer-eks-deployment/tree/main/k8s/green"
            GreenBackend["Backend Pods"]:::green
            GreenHPA["HPA Config"]:::green
        end
    end

    subgraph "Infrastructure Layer"
        VPC["AWS VPC"]:::aws
        click VPC "https://github.com/postig0x/farseer-eks-deployment/tree/main/Terraform/blue/Dev/modules/VPC"
        EC2["EC2 Instances"]:::aws
        click EC2 "https://github.com/postig0x/farseer-eks-deployment/tree/main/Terraform/blue/Dev/modules/EC2"
        
        subgraph "Environment Configs"
            Dev["Development"]:::env
            click Dev "https://github.com/postig0x/farseer-eks-deployment/tree/main/Terraform/blue/Dev"
            QA["QA"]:::env
            click QA "https://github.com/postig0x/farseer-eks-deployment/tree/main/Terraform/blue/QA"
            Prod["Production"]:::env
            click Prod "https://github.com/postig0x/farseer-eks-deployment/tree/main/Terraform/blue/Production"
            SB["Sandbox"]:::env
            click SB "https://github.com/postig0x/farseer-eks-deployment/tree/main/Terraform/blue/sb"
        end
    end

    subgraph "CI/CD Layer"
        Jenkins["Jenkins Pipeline"]:::cicd
        click Jenkins "https://github.com/postig0x/farseer-eks-deployment/tree/main/Jenkinsfile"
        DeployScripts["Deployment Scripts"]:::cicd
        click DeployScripts "https://github.com/postig0x/farseer-eks-deployment/tree/main/CICD_Scripts"
    end

    %% Relationships
    Client --> ALB
    ALB --> Frontend
    Frontend --> Backend
    Backend --> LLM
    Frontend --> BlueFrontend
    Frontend --> GreenFrontend
    Backend --> BlueBackend
    Backend --> GreenBackend
    BlueBackend --> BlueHPA
    GreenBackend --> GreenHPA
    BlueFrontend --> VPC
    BlueBackend --> VPC
    GreenFrontend --> VPC
    GreenBackend --> VPC
    VPC --> EC2
    Jenkins --> DeployScripts
    DeployScripts --> |Deploys to| Dev
    DeployScripts --> |Deploys to| QA
    DeployScripts --> |Deploys to| Prod
    DeployScripts --> |Deploys to| SB

    %% Styles
    classDef aws fill:#FF9900,stroke:#232F3E,color:white
    classDef frontend fill:#00BCD4,stroke:#0097A7,color:white
    classDef backend fill:#4CAF50,stroke:#388E3C,color:white
    classDef external fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef blue fill:#2196F3,stroke:#1976D2,color:white
    classDef green fill:#4CAF50,stroke:#388E3C,color:white
    classDef env fill:#78909C,stroke:#546E7A,color:white
    classDef cicd fill:#FF5722,stroke:#E64A19,color:white
```
