# fixthestatusquo/proca-server architecture

> Architecture diagram of the GitHub repository fixthestatusquo/proca-server, 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/fixthestatusquo/proca-server
- Repository: https://github.com/fixthestatusquo/proca-server

## Overview

##### Main Components

a. Core Components:
- Proca Server (Elixir)
- Web Layer (Phoenix Framework)
- GraphQL API
- Action Processing Engine
- Database Layer
- Authentication/Authorization System

b. SDK Components:
- API Client (TypeScript)
- Queue Management Library
- Crypto Library
- CLI Tool (Python)

c. Service Components:
- Multiple Sync Services:
- Emarsys Sync
- Mailchimp Sync
- Salesforce Sync
- Trust Sync
- Proca Gate (AWS Lambda)

##### Relationship Flows

**┌─────────────────────────────────────────────────────────────┐**
- External Clients                        │
- ▲─────────────────────────────▲──────────────┘

**┌───────────────┴─────────────┐    ┌─────────┴──────────┐**
- Proca SDK Components    │    │    Python CLI       │
- API Client              │    │   Management Tool   │
- Queue Library          │    └──────────┬──────────┘
- Crypto Library        │                │
- ┬──────────┘                │

**┌──────────────▼───────────────────────────▼──────────────┐**
- Proca Core Server                      │
- ┤
- ┌─────────────┐    ┌──────────────┐   ┌────────────┐  │
- GraphQL    │    │   Phoenix    │   │  Action    │  │
- API      │    │   Web App    │   │ Processing │  │
- ┬───────┘    └──────┬───────┘   └─────┬──────┘  │

- ┌─────▼────────────────────▼──────────────────▼─────┐  │
- Data Layer                        │  │
- ┬┘  │
- ┬───────────────┘   │

**┌─────────────────────────────────────▼─────────────────┐  │**
- Sync Services                         │  │
- ┬────────────┬────────────┬───────────────┤  │
- Emarsys   │ Mailchimp  │ Salesforce │    Trust      │  │
- Sync     │   Sync     │   Sync     │    Sync       │  │
- ┴────────────┴────────────┴───────────────┘  │

##### Important Details

a. Server Architecture:
- Phoenix/Elixir server structure
- GraphQL API endpoint
- Action processing pipeline
- Database connections
- Encryption/decryption points

b. Integration Points:
- How SDK components interact with the server
- Sync service connections
- External service integration points

c. Data Flow:
- Encrypted data paths
- Action processing flow
- Synchronization paths

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph External["External Clients"]
        Client1[Web Clients]
        Client2[Mobile Apps]
    end

    subgraph SDK["SDK Layer"]
        APIClient["API Client"]:::sdk
        CryptoLib["Crypto Library"]:::sdk
        CLITool["CLI Management Tool"]:::sdk
    end

    subgraph Core["Proca Core Server"]
        subgraph WebLayer["Web Layer"]
            Phoenix["Phoenix Web App"]:::core
            GraphQL["GraphQL API"]:::core
        end

        subgraph Processing["Processing Layer"]
            ActionEngine["Action Processing Engine"]:::core
            Auth["Authentication System"]:::core
            Campaign["Campaign Management"]:::core
            ActionPages["Action Pages"]:::core
            Contact["Contact Management"]:::core
            Org["Organization Management"]:::core
        end

        subgraph Data["Data Layer"]
            DB["Database"]:::data
            Repo["Repository Layer"]:::data
        end
    end

    subgraph Sync["Sync Services"]
        Emarsys["Emarsys Sync"]:::sync
        Mailchimp["Mailchimp Sync"]:::sync
        Salesforce["Salesforce Sync"]:::sync
        Trust["Trust Sync"]:::sync
        Gate["Proca Gate"]:::sync
    end

    %% Relationships
    Client1 & Client2 --> APIClient
    APIClient & CryptoLib & CLITool --> GraphQL
    GraphQL --> ActionEngine
    Phoenix --> ActionEngine
    ActionEngine --> DB
    DB --> Repo
    ActionEngine --> Sync
    Auth --> DB
    Campaign & ActionPages & Contact & Org --> DB

    %% Click Events
    click APIClient "https://github.com/fixthestatusquo/proca-server/tree/main/sdk/api/"
    click CryptoLib "https://github.com/fixthestatusquo/proca-server/tree/main/sdk/crypto/"
    click CLITool "https://github.com/fixthestatusquo/proca-server/tree/main/sdk/cli-py/"
    click GraphQL "https://github.com/fixthestatusquo/proca-server/tree/main/proca/lib/proca_web/schema/"
    click Phoenix "https://github.com/fixthestatusquo/proca-server/tree/main/proca/lib/proca_web/"
    click ActionEngine "https://github.com/fixthestatusquo/proca-server/tree/main/proca/lib/proca/stage/"
    click Auth "https://github.com/fixthestatusquo/proca-server/blob/main/proca/lib/proca/auth.ex"
    click Repo "https://github.com/fixthestatusquo/proca-server/blob/main/proca/lib/proca/repo.ex"
    click Campaign "https://github.com/fixthestatusquo/proca-server/blob/main/proca/lib/proca/campaign.ex"
    click ActionPages "https://github.com/fixthestatusquo/proca-server/blob/main/proca/lib/proca/action_page.ex"
    click Contact "https://github.com/fixthestatusquo/proca-server/blob/main/proca/lib/proca/contact.ex"
    click Org "https://github.com/fixthestatusquo/proca-server/blob/main/proca/lib/proca/org.ex"
    click Emarsys "https://github.com/fixthestatusquo/proca-server/tree/main/archive/service/emarsys-sync/"
    click Mailchimp "https://github.com/fixthestatusquo/proca-server/tree/main/archive/service/mailchimp-sync/"
    click Salesforce "https://github.com/fixthestatusquo/proca-server/tree/main/archive/service/salesforce-sync/"
    click Trust "https://github.com/fixthestatusquo/proca-server/tree/main/archive/service/trust-sync/"
    click Gate "https://github.com/fixthestatusquo/proca-server/tree/main/archive/service/proca-gate/"

    %% Styling
    classDef core fill:#2374ab
    classDef sdk fill:#57cc99
    classDef sync fill:#f4d03f
    classDef data fill:#808080

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[SDK Components]:::sdk
        L3[Sync Services]:::sync
        L4[Data Components]:::data
    end
```
