# seed-platform/seed architecture

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

- Interactive diagram: https://gitdiagram.com/seed-platform/seed
- Repository: https://github.com/seed-platform/seed

## Overview

##### Frontend (User Interface)
- AngularJS application integrated with Bootstrap and additional JavaScript libraries.
- Static assets (under the “seed/static/seed” directory) that provide UI components, templates, partials, and client-side controllers.
- Optionally denote the Swagger API documentation avenue that is accessible via the UI or directly at a given endpoint (e.g., “/api/swagger”).

##### Backend (Web Application Layer)
- Django application housed in the “seed” module, which is organized into various submodules (e.g., for API endpoints, views, serializers, models, migrations, and Celery tasks).
- Separation of concerns (e.g., models, views, serializers, management commands, and API endpoints under “seed/views”, “seed/serializers”, “seed/models”, and “seed/api”).
- Extensive use of migrations and configurations in “config”, which helps manage environment-specific settings and URL routing.

##### Background Processing and Task Management
- Celery workers (triggered by scripts in the “bin” directory such as “start_celery.sh” and task definitions in “seed/tasks.py”) that handle asynchronous jobs (for data processing, file imports, etc.).
- If applicable, indicate any broker (usually Redis or RabbitMQ, even if not explicitly noted in the file tree) that Celery uses as an intermediary.

##### Database
- PostgreSQL database as the central data store.

##### Deployment and Infrastructure Components
- Docker components: Dockerfiles (“Dockerfile”, “Dockerfile-dev”, “Dockerfile.ecs”) and Docker Compose files (such as “docker-compose.yml”, “docker-compose.dev.yml”) that help in containerizing and orchestrating the system.
- External configuration for continuous integration (workflows in “.github/workflows”) and deployment scripts like “deploy.sh”.

##### External Interfaces and APIs
- RESTful APIs provided by the Django application, with endpoints grouped under “seed/api/v3” and “seed/api/v4”.
- Pointers for API consumers or developers (with the Swagger docs available at the proper endpoint).

- Use clear labels for each component (e.g., “AngularJS Frontend”, “Django Web Server”, “Celery Task Queue”, “PostgreSQL Database”).

## Diagram (Mermaid)

```mermaid
flowchart TD

    User["User Browser"]:::external

    subgraph "Frontend (AngularJS & Bootstrap)"
        FE["AngularJS Frontend"]:::frontend
        Static["Static Assets"]:::static
        Templates["UI Templates"]:::static
        Swagger["Swagger API Docs"]:::external
    end

    subgraph "Backend (Django Application)"
        Django["Django Web Server"]:::backend
        Models["Models"]:::backend
        Views["Views"]:::backend
        Serializers["Serializers"]:::backend
        API["API Endpoints"]:::backend
        Config["Configurations"]:::config
    end

    subgraph "Background Tasks (Celery)"
        Celery["Celery Workers"]:::celery
        Tasks["Task Definitions"]:::celery
    end

    subgraph "Database"
        DB["PostgreSQL Database"]:::database
        Migrations["Migrations"]:::database
        SQLFuncs["SQL Functions"]:::database
    end

    subgraph "Deployment & Infrastructure"
        Docker["Docker Containers"]:::deployment
        Compose["Docker Compose Files"]:::deployment
        CI["Deployment Script"]:::deployment
    end

    subgraph "External Interfaces"
        APIv3["REST API v3"]:::external
        APIv4["REST API v4"]:::external
    end

    %% Data flow connections

    User -->|"accesses"| FE
    FE -->|"sends HTTP requests"| Django
    FE -->|"loads"| Templates
    FE -->|"renders"| Swagger

    Config -->|"configures"| Django
    Django -->|"handles business logic"| Models
    Django -->|"renders views"| Views
    Django -->|"serializes data"| Serializers
    Django -->|"exposes"| API
    Django -->|"queues tasks"| Celery
    Django -->|"performs migrations"| Migrations

    Celery -->|"executes tasks defined in"| Tasks
    Celery -->|"reads/writes data"| DB

    Migrations -->|"updates schema"| DB
    SQLFuncs -->|"provides SQL functions"| DB

    Django -->|"exposes v3 API"| APIv3
    Django -->|"exposes v4 API"| APIv4

    CI -->|"triggers"| Docker
    Compose -->|"orchestrates"| Docker

    Docker -->|"hosts"| FE
    Docker -->|"hosts"| Django
    Docker -->|"hosts"| Celery

    %% Click Events
    click Static "https://github.com/seed-platform/seed/tree/develop/seed/static/seed"
    click Templates "https://github.com/seed-platform/seed/tree/develop/seed/templates/seed"
    click Django "https://github.com/seed-platform/seed/tree/develop/seed"
    click Config "https://github.com/seed-platform/seed/blob/develop/config/settings/common.py"
    click Celery "https://github.com/seed-platform/seed/blob/develop/bin/start_celery.sh"
    click Tasks "https://github.com/seed-platform/seed/blob/develop/seed/data_importer/tasks.py"
    click Migrations "https://github.com/seed-platform/seed/tree/develop/seed/migrations"
    click SQLFuncs "https://github.com/seed-platform/seed/blob/develop/seed/ubid/buildingid_functions.sql"
    click Docker "https://github.com/seed-platform/seed/tree/develop/Dockerfile"
    click Compose "https://github.com/seed-platform/seed/blob/develop/docker-compose.yml"
    click CI "https://github.com/seed-platform/seed/blob/develop/deploy.sh"
    click APIv3 "https://github.com/seed-platform/seed/tree/develop/seed/api/v3"
    click APIv4 "https://github.com/seed-platform/seed/tree/develop/seed/api/v4"
    click Swagger "https://github.com/seed-platform/seed/blob/develop/seed/templates/drf-yasg/swagger-ui.html"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef celery fill:#FFFF99,stroke:#000,stroke-width:2px;
    classDef database fill:#FFA500,stroke:#000,stroke-width:2px;
    classDef deployment fill:#D3D3D3,stroke:#000,stroke-width:2px;
    classDef external fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef static fill:#DDA0DD,stroke:#000,stroke-width:2px;
    classDef config fill:#20B2AA,stroke:#000,stroke-width:2px;
```
