# j0nathan-ll0yd/aws-cloudformation-media-downloader architecture

> Architecture diagram of the GitHub repository j0nathan-ll0yd/aws-cloudformation-media-downloader, 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/j0nathan-ll0yd/aws-cloudformation-media-downloader
- Repository: https://github.com/j0nathan-ll0yd/aws-cloudformation-media-downloader

## Overview

##### Main Components

a. Client-Side Components:
- iOS Mobile App (external component)
- Feedly Integration (external webhook source)

b. AWS Infrastructure Components:
- API Gateway (entry point for REST APIs)
- CloudFront (content delivery)
- Lambda Functions (serverless compute)
- S3 (file storage)
- DynamoDB (database)
- SNS/SQS (push notifications)
- Secrets Manager (credentials storage)

**┌─ External Layer ─────────────────────────────────┐**
- iOS App                    Feedly Webhook        │
- ┬────────────────┬──────────────┘

**┌─ API Layer ─────▼────────────────▼──────────────┐**
- API Gateway                                      │
- Custom Authorizer Lambda                     │
- ┬────────────────────────────────┘

**┌─ Service Layer ─▼────────────────────────────────┐**
- ┌─ File Management ─┐  ┌─ User Management ─┐     │
- StartFileUpload │  │ - RegisterUser    │     │
- UploadPart     │  │ - LoginUser       │     │
- CompleteUpload │  │ - UserDelete      │     │
- ListFiles      │  │ - UserSubscribe   │     │
- ┘  └─────────────────────┘    │
- ┌─ Notifications ───┐  ┌─ Device Management ─┐   │
- SendPushNotif  │  │ - RegisterDevice    │   │
- WebhookFeedly  │  │ - PruneDevices     │   │
- ┘  └─────────────────────┘    │
- ┬────────────────────────────────┘

**┌─ Storage Layer ─▼────────────────────────────────┐**
- S3 Buckets         DynamoDB Tables               │
- ┘

##### Important Flows to Highlight

a. Media Download Flow:
**iOS App → API Gateway → StartFileUpload → S3 → CompleteFileUpload → DynamoDB**

b. Push Notification Flow:
**Feedly → WebhookFeedly → SNS → SendPushNotification → iOS App**

c. User Authentication Flow:
**iOS App → API Gateway → LoginUser → DynamoDB**

##### Additional Elements

- Version/environment information
- Security boundaries and VPC if applicable
- Monitoring and logging flows

##### Implementation Notes

- Related Lambda functions together
- Scaling and redundancy where applicable

Remember to include the integration points with external services (APNS, Github, Feedly) while maintaining clarity about the security boundaries and authorization flows.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Layer
    subgraph External
        IOS[iOS Mobile App]:::external
        Feedly[Feedly Webhook]:::external
    end

    %% API Layer
    subgraph APILayer
        APIG[API Gateway]:::api
        Auth[Custom Authorizer]:::lambda
    end
    click Auth "https://github.com/j0nathan-ll0yd/aws-cloudformation-media-downloader/tree/master/src/lambdas/ApiGatewayAuthorizer"
    
    %% Service Layer
    subgraph FileManagement
        Start[StartFileUpload]:::lambda
        Upload[UploadPart]:::lambda
        Complete[CompleteFileUpload]:::lambda
        List[ListFiles]:::lambda
    end
    click Start "https://github.com/j0nathan-ll0yd/aws-cloudformation-media-downloader/tree/master/src/lambdas/StartFileUpload"
    click Upload "https://github.com/j0nathan-ll0yd/aws-cloudformation-media-downloader/tree/master/src/lambdas/UploadPart"
    click Complete "https://github.com/j0nathan-ll0yd/aws-cloudformation-media-downloader/tree/master/src/lambdas/CompleteFileUpload"
    click List "https://github.com/j0nathan-ll0yd/aws-cloudformation-media-downloader/tree/master/src/lambdas/ListFiles"

    subgraph UserManagement
        Register[RegisterUser]:::lambda
        Login[LoginUser]:::lambda
        Delete[UserDelete]:::lambda
        Subscribe[UserSubscribe]:::lambda
    end
    click Register "https://github.com/j0nathan-ll0yd/aws-cloudformation-media-downloader/tree/master/src/lambdas/RegisterUser"
    click Login "https://github.com/j0nathan-ll0yd/aws-cloudformation-media-downloader/tree/master/src/lambdas/LoginUser"
    click Delete "https://github.com/j0nathan-ll0yd/aws-cloudformation-media-downloader/tree/master/src/lambdas/UserDelete"
    click Subscribe "https://github.com/j0nathan-ll0yd/aws-cloudformation-media-downloader/tree/master/src/lambdas/UserSubscribe"

    subgraph DeviceManagement
        RegDevice[RegisterDevice]:::lambda
        Prune[PruneDevices]:::lambda
    end
    click RegDevice "https://github.com/j0nathan-ll0yd/aws-cloudformation-media-downloader/tree/master/src/lambdas/RegisterDevice"
    click Prune "https://github.com/j0nathan-ll0yd/aws-cloudformation-media-downloader/tree/master/src/lambdas/PruneDevices"

    subgraph Notifications
        Push[SendPushNotification]:::lambda
        WebhookF[WebhookFeedly]:::lambda
    end
    click Push "https://github.com/j0nathan-ll0yd/aws-cloudformation-media-downloader/tree/master/src/lambdas/SendPushNotification"
    click WebhookF "https://github.com/j0nathan-ll0yd/aws-cloudformation-media-downloader/tree/master/src/lambdas/WebhookFeedly"

    %% Storage Layer
    subgraph Storage
        S3[(S3 Buckets)]:::storage
        DDB[(DynamoDB)]:::storage
    end

    %% CDN Layer
    CDN[CloudFront]:::cdn
    click CDN "https://github.com/j0nathan-ll0yd/aws-cloudformation-media-downloader/tree/master/src/lambdas/CloudfrontMiddleware"

    %% Messaging
    SNS{SNS/SQS}:::messaging

    %% Connections
    IOS --> APIG
    Feedly --> WebhookF
    APIG --> Auth
    Auth --> APIG

    %% File Management Flow
    APIG --> Start
    Start --> S3
    APIG --> Upload
    Upload --> S3
    APIG --> Complete
    Complete --> S3
    Complete --> DDB
    APIG --> List
    List --> DDB

    %% User Management Flow
    APIG --> Register
    Register --> DDB
    APIG --> Login
    Login --> DDB
    APIG --> Delete
    Delete --> DDB
    APIG --> Subscribe
    Subscribe --> DDB

    %% Device Management Flow
    APIG --> RegDevice
    RegDevice --> DDB
    APIG --> Prune
    Prune --> DDB

    %% Notification Flow
    WebhookF --> SNS
    SNS --> Push
    Push --> IOS

    %% CDN Flow
    S3 --> CDN
    CDN --> IOS

    %% Styles
    classDef external fill:#68a0cf
    classDef api fill:#95d475
    classDef lambda fill:#f9d56e
    classDef storage fill:#bf85bf
    classDef messaging fill:#ff9b73
    classDef cdn fill:#c9c9c9

    %% Legend
    subgraph Legend
        E[External Services]:::external
        A[API Services]:::api
        L[Lambda Functions]:::lambda
        S[(Storage Services)]:::storage
        M{Message Services}:::messaging
        C[CDN Services]:::cdn
    end
```
