# bjornmelin/bjornmelin-platform-io architecture

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

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

## Overview

##### Main Components

A. Client Layer:
- Next.js 14 Frontend (React 18)
- Static Assets (S3/CloudFront)
- Client-side Components

B. Edge Layer:
- CloudFront Distribution
- Route 53 DNS
- ACM Certificates

C. Application Layer:
- Next.js Server Components
- API Routes
- Lambda Functions

D. Infrastructure Layer:
- AWS Services Integration
- Storage Solutions
- Email Services

**┌─────────────────────────────────────────────────────────────┐**
- Client Browser                          │
- ┬─────────────────────────────┘
- ▼
**┌─────────────────────────────────────────────────────────────┐**
- Edge Layer (Global)                      │
- ┌─────────────┐    ┌──────────────┐    ┌──────────────┐   │
- Route 53   │──▶│  CloudFront   │◀───│     ACM      │   │
- ┘    └──────────────┘    └──────────────┘   │
- ┬─────────────────────────────┘
- ▼
**┌─────────────────────────────────────────────────────────────┐**
- Application Layer                         │
- ┌─────────────┐    ┌──────────────┐    ┌──────────────┐   │
- Next.js    │    │   Lambda     │    │     S3       │   │
- Server    │──▶│  Functions   │──▶│   Bucket     │   │
- ┘    └──────────────┘    └──────────────┘   │
- ┬─────────────────────────────┘
- ▼
**┌─────────────────────────────────────────────────────────────┐**
- Services Layer                            │
- ┌─────────────┐    ┌──────────────┐    ┌──────────────┐   │
- SES      │    │  CloudWatch  │    │     IAM      │   │
- Email     │    │  Monitoring  │    │    Roles     │   │
- ┘    └──────────────┘    └──────────────┘   │
- ┘

##### Important Flows to Highlight

A. Static Content Delivery:
**Browser → CloudFront → S3 Bucket**

B. Contact Form Flow:
**Browser → API Route → Lambda → SES**

C. DNS Resolution:
**Browser → Route 53 → CloudFront**

##### Component Details

Frontend:
- Next.js 14 App Router structure
- Server vs. client components
- Static asset handling

Infrastructure:
- AWS services from /infrastructure/lib/stacks
- Relationships between stacks
- CloudWatch monitoring points

##### Additional Elements

- Version badges for major components
- Scaling and redundancy where applicable
- Security perimeters

##### Implementation Notes

- Maintain consistent styling
- Component versions
- Brief descriptions for complex interactions

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client["Client Layer"]
        Browser["Web Browser"]
        ClientComp["Client Components"]:::frontend
        StaticAssets["Static Assets"]:::frontend
    end

    subgraph Edge["Edge Layer"]
        Route53["Route 53 DNS"]:::edge
        CloudFront["CloudFront CDN"]:::edge
        ACM["ACM Certificates"]:::security
    end

    subgraph App["Application Layer"]
        NextServer["Next.js Server"]:::app
        APIRoutes["API Routes"]:::api
        Lambda["Lambda Functions"]:::app
    end

    subgraph Services["Services Layer"]
        S3["S3 Bucket"]:::storage
        SES["SES Email"]:::service
        CloudWatch["CloudWatch"]:::monitoring
        IAM["IAM Roles"]:::security
    end

    %% Connections
    Browser --> Route53
    Route53 --> CloudFront
    ACM --> CloudFront
    CloudFront --> NextServer
    CloudFront --> S3
    NextServer --> APIRoutes
    APIRoutes --> Lambda
    Lambda --> SES
    Lambda --> S3
    Lambda --> CloudWatch

    %% Click Events
    click ClientComp "https://github.com/bjornmelin/bjornmelin-platform-io/tree/main/src/components"
    click StaticAssets "https://github.com/bjornmelin/bjornmelin-platform-io/tree/main/public/"
    click APIRoutes "https://github.com/bjornmelin/bjornmelin-platform-io/tree/main/src/app/api"
    click Lambda "https://github.com/bjornmelin/bjornmelin-platform-io/tree/main/infrastructure/lib/functions"
    click Route53 "https://github.com/bjornmelin/bjornmelin-platform-io/blob/main/infrastructure/lib/stacks/dns-stack.ts"
    click S3 "https://github.com/bjornmelin/bjornmelin-platform-io/blob/main/infrastructure/lib/stacks/storage-stack.ts"
    click SES "https://github.com/bjornmelin/bjornmelin-platform-io/blob/main/infrastructure/lib/stacks/email-stack.ts"
    click CloudWatch "https://github.com/bjornmelin/bjornmelin-platform-io/blob/main/infrastructure/lib/stacks/monitoring-stack.ts"
    click NextServer "https://github.com/bjornmelin/bjornmelin-platform-io/tree/main/src/app"

    %% Styling
    classDef frontend fill:#3498db
    classDef edge fill:#2ecc71
    classDef api fill:#e74c3c
    classDef app fill:#f39c12
    classDef storage fill:#8e44ad
    classDef service fill:#2c3e50
    classDef security fill:#95a5a6
    classDef monitoring fill:#16a085

    %% Legend
    subgraph Legend
        Frontend["Frontend"]:::frontend
        Edge["Edge Services"]:::edge
        API["API"]:::api
        Application["Application"]:::app
        Storage["Storage"]:::storage
        Services["Services"]:::service
        Security["Security"]:::security
        Monitoring["Monitoring"]:::monitoring
    end
```
