# agriworks/agriworks_platform architecture

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

- Interactive diagram: https://gitdiagram.com/agriworks/agriworks_platform
- Repository: https://github.com/agriworks/agriworks_platform

## Overview

##### Main Components

A. Client Layer
- Agriworks Portal (Frontend) as a separate component
- It to the backend via HTTP/REST APIs

B. Backend Service Layer (Core)
- Controllers Layer
- Authentication
- Admin
- Dataset
- Upload
- AgriWatchView
- Services Layer
- Authentication Service
- Dataset Service
- Upload Service
- Mail Service
- AgriWatchView Service
- Endpoint Protection Service

C. Data Layer
- Models
- User
- Dataset
- Session
- Tag
- AgriWatchView

D. External Services
- S3 Storage (evident from S3 scripts)
- Mail Service Integration
- Elastic Beanstalk (deployment platform)

**┌─────────────┐**
- Client    │
- ┘
- ↓
**┌─────────────┐**
- Backend   │
- ┘
- ↓
**┌─────────────┐**
- Data     │
- ┘

##### Key Relationships to Highlight

A. Request Flow:
- Client → Controllers → Services → Models
- Authentication flow separately
- File upload path to S3

B. Service Dependencies:
- How EndpointProtectionService interfaces with other services
- MailService external communications
- Demonstrate Dataset handling flow

##### Infrastructure Elements

Deployment-related components:
- Docker container
- Elastic Beanstalk environment
- CircleCI pipeline
- S3 storage

##### Specific Implementation Details

**[Frontend Portal] → [API Layer]**
- ↓
**[Controller Layer]**
- ↓
**[Service Layer] ←→ [External Services]**
- ↓
**[Model Layer] ←→ [Database]**

##### Technical Stack Indicators

- Python/Flask framework
- Docker containerization
- AWS services (S3, Elastic Beanstalk)
- Database (type to be specified)

Remember to:
- Annotations for critical paths
- Document any assumptions made

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef controller fill:#2ecc71,stroke:#27ae60,color:white
    classDef service fill:#f1c40f,stroke:#f39c12,color:black
    classDef model fill:#e74c3c,stroke:#c0392b,color:white
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    classDef infrastructure fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Client Layer
    subgraph Client
        Frontend["Agriworks Portal (Frontend)"]:::frontend
    end

    %% Controllers Layer
    subgraph Controllers
        AuthController["Authentication Controller"]:::controller
        AdminController["Admin Controller"]:::controller
        DatasetController["Dataset Controller"]:::controller
        UploadController["Upload Controller"]:::controller
        VisualizeController["Visualize Controller"]:::controller
        AgriWatchController["AgriWatch Controller"]:::controller
    end

    %% Services Layer
    subgraph Services
        AuthService["Authentication Service"]:::service
        DatasetService["Dataset Service"]:::service
        UploadService["Upload Service"]:::service
        VisualizeService["Visualize Service"]:::service
        MailService["Mail Service"]:::service
        AgriWatchService["AgriWatch Service"]:::service
        EndpointProtection["Endpoint Protection Service"]:::service
    end

    %% Models Layer
    subgraph Models
        UserModel["User Model"]:::model
        DatasetModel["Dataset Model"]:::model
        SessionModel["Session Model"]:::model
        TagModel["Tag Model"]:::model
        AgriWatchModel["AgriWatch Model"]:::model
    end

    %% External Services
    subgraph External
        S3["AWS S3 Storage"]:::external
        EmailService["Email Service"]:::external
        ElasticBeanstalk["Elastic Beanstalk"]:::external
        CircleCI["CircleCI Pipeline"]:::external
        Docker["Docker Container"]:::infrastructure
    end

    %% Relationships
    Frontend --> AuthController
    Frontend --> DatasetController
    Frontend --> UploadController
    Frontend --> VisualizeController
    Frontend --> AgriWatchController
    Frontend --> AdminController

    AuthController --> AuthService
    AdminController --> AuthService
    DatasetController --> DatasetService
    UploadController --> UploadService
    VisualizeController --> VisualizeService
    AgriWatchController --> AgriWatchService

    AuthService --> UserModel
    AuthService --> SessionModel
    DatasetService --> DatasetModel
    DatasetService --> TagModel
    AgriWatchService --> AgriWatchModel
    
    UploadService --> S3
    MailService --> EmailService
    
    EndpointProtection -.-> AuthService
    EndpointProtection -.-> DatasetService
    EndpointProtection -.-> UploadService
    EndpointProtection -.-> VisualizeService
    EndpointProtection -.-> AgriWatchService

    %% Click events for component mapping
    click AuthController "https://github.com/Agriworks/agriworks_platform/blob/master/Controllers/AuthenticationController.py"
    click AdminController "https://github.com/Agriworks/agriworks_platform/blob/master/Controllers/AdminController.py"
    click DatasetController "https://github.com/Agriworks/agriworks_platform/blob/master/Controllers/DatasetController.py"
    click UploadController "https://github.com/Agriworks/agriworks_platform/blob/master/Controllers/UploadController.py"
    click VisualizeController "https://github.com/Agriworks/agriworks_platform/blob/master/Controllers/VisualizeController.py"
    click AgriWatchController "https://github.com/Agriworks/agriworks_platform/blob/master/Controllers/AgriWatchViewController.py"
    
    click AuthService "https://github.com/Agriworks/agriworks_platform/blob/master/Services/AuthenticationService.py"
    click DatasetService "https://github.com/Agriworks/agriworks_platform/blob/master/Services/DatasetService.py"
    click UploadService "https://github.com/Agriworks/agriworks_platform/blob/master/Services/UploadService.py"
    click VisualizeService "https://github.com/Agriworks/agriworks_platform/blob/master/Services/VisualizeService.py"
    click MailService "https://github.com/Agriworks/agriworks_platform/blob/master/Services/MailService.py"
    click AgriWatchService "https://github.com/Agriworks/agriworks_platform/blob/master/Services/AgriWatchViewService.py"
    click EndpointProtection "https://github.com/Agriworks/agriworks_platform/blob/master/Services/EndpointProtectionService.py"
    
    click UserModel "https://github.com/Agriworks/agriworks_platform/blob/master/Models/User.py"
    click DatasetModel "https://github.com/Agriworks/agriworks_platform/blob/master/Models/Dataset.py"
    click SessionModel "https://github.com/Agriworks/agriworks_platform/blob/master/Models/Session.py"
    click TagModel "https://github.com/Agriworks/agriworks_platform/blob/master/Models/Tag.py"
    click AgriWatchModel "https://github.com/Agriworks/agriworks_platform/blob/master/Models/AgriWatchView.py"
    
    click ElasticBeanstalk "https://github.com/Agriworks/agriworks_platform/blob/master/.elasticbeanstalk/config.yml"
    click Docker "https://github.com/Agriworks/agriworks_platform/tree/master/Dockerfile"
    click CircleCI "https://github.com/Agriworks/agriworks_platform/blob/master/.circleci/config.yml"
    click S3 "https://github.com/Agriworks/agriworks_platform/blob/master/scripts/removeAdditionalDatasetsFromS3.py"
```
