# gedaaaa/personal-serverless-web-app architecture

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

- Interactive diagram: https://gitdiagram.com/gedaaaa/personal-serverless-web-app
- Repository: https://github.com/gedaaaa/personal-serverless-web-app

## Overview

##### Project Type and Purpose
- This is a full-stack monorepo designed as a personal serverless web framework for rapid prototyping and tech exploration.
- Frontend is a SvelteKit/Svelte 5 application deployed via SST.
- Backend consists of multiple Kotlin/Micronaut microservices, each deployed as AWS Lambda functions.
- Infrastructure is defined and deployed with AWS CDK (Java/TypeScript), and content is delivered via Cloudflare.

##### High-Level Architecture Components
- Developer Environment: VS Code Dev Container, Docker, local‐env scripts, NX/pnpm workspace
- CI/CD: GitHub Actions workflows (ci-pr.yml, cd-merge.yml)
- Frontend (apps/frontend/demo-website): SvelteKit app deployed by SST → CloudFront/CDN (Cloudflare)
- Backend Microservices (apps/backend/\<service\>/{app,infra}):
- Service Code (Kotlin/Micronaut) → AWS Lambda functions
- Infra Code (AWS CDK stacks) → API Gateway, DynamoDB tables, SQS queues, IAM, Parameter Store
- Shared Library (libs/jvm-shared-lib): common DynamoDB, SQS, SSM, security, types, utilities
- AWS Services at runtime:
- API Gateway
- Lambda Functions (Auth, Email, Memo, Helloworld)
- DynamoDB (one table per service)
- SQS Queues (for email & notification messages)
- SSM Parameter Store (config)
- CloudFront + Cloudflare CDN

##### Relationships and Data Flows
a. Browser → Cloudflare CDN → Frontend SvelteKit app
b. Frontend → HTTP(S) calls to API Gateway endpoints (e.g. /auth/*, /memo/*)
c. API Gateway → routes to corresponding AWS Lambda (Microservice handler)
d. Lambda (Auth/Memo) ↔ DynamoDB for reads/writes
e. Lambda (Memo) → publishes notification messages to SQS → triggers Lambda in Email service
f. Email Lambda → pulls message from SQS → sends email via external provider (Resend)
g. All Lambdas read config/credentials from SSM Parameter Store
h. CDK stacks → define and deploy all AWS resources

##### Architectural Patterns & Principles
- Microservices: each domain (auth, memo, email, helloworld) is isolated into its own service and infra stack
- Serverless: compute via AWS Lambda, auto-scaling, pay-per-use
- Event-driven: SQS queues decouple memo notifications from email sending
- Infrastructure as Code: AWS CDK definitions live alongside application code
- Shared Library: centralize cross-cutting concerns (DynamoDB config, SQS config, security, types)

##### Essential Elements to Capture
- Frontend (SST stack)
- API Gateway routing to each Lambda
- Lambda functions for Auth, Memo, Email, Helloworld
- DynamoDB tables per service
- SQS queues and event triggers
- SSM Parameter Store for configuration
- Shared library dependency
- CI/CD pipeline and DevContainer local workflow

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Zones
    subgraph "Developer & CI/CD" 
        direction TB
        D1[".devcontainer/"]:::infra
        D2["local-env/"]:::infra
        D3["nx.json"]:::infra
        D4["package.json"]:::infra
        D5["pnpm-lock.yaml"]:::infra
        D6["settings.gradle.kts"]:::infra
        CI1["ci-pr.yml"]:::infra
        CI2["cd-merge.yml"]:::infra
    end

    subgraph "Frontend"
        direction TB
        FEStack["SvelteKit App (Lambda via SST)"]:::compute
        FEpkg["package.json"]:::infra
        FEsrc["src/"]:::infra
        FEsst["sst.config.ts"]:::infra
    end

    subgraph "Shared Library"
        direction TB
        Lib["jvm-shared-lib"]:::infra
        LibSrc["src/main/kotlin/top/sunbath/shared/"]:::infra
    end

    subgraph "Backend Services"
        direction TB
        subgraph "Auth Service"
            direction TB
            AuthApp["Auth Lambda"]:::compute
            AuthInfra["Auth CDK Stack"]:::infra
            AuthDB["Auth DynamoDB Table"]:::datastore
        end
        subgraph "Memo Service"
            direction TB
            MemoApp["Memo Lambda"]:::compute
            MemoInfra["Memo CDK Stack"]:::infra
            MemoDB["Memo DynamoDB Table"]:::datastore
            MemoQueue["Memo SQS Queue"]:::message
        end
        subgraph "Email Service"
            direction TB
            EmailApp["Email Lambda"]:::compute
            EmailInfra["Email CDK Stack"]:::infra
            EmailQueue["Email SQS Queue"]:::message
        end
        subgraph "HelloWorld Service"
            direction TB
            HelloApp["HelloWorld Lambda"]:::compute
            HelloInfra["HelloWorld CDK Stack"]:::infra
            HelloDB["HelloWorld DynamoDB Table"]:::datastore
        end
    end

    subgraph "AWS Account / Region"
        direction TB
        APIGW["API Gateway"]:::api
        ParamStore["SSM Parameter Store"]:::datastore
        CloudFront["CloudFront + Cloudflare CDN"]:::api
    end

    %% Flows
    Browser["Browser"]:::external
    Browser -->|"HTTPS"| CloudFront
    CloudFront -->|"Serves App"| FEStack
    FEStack -->|"API calls"| APIGW

    APIGW -->|"Auth routes"| AuthApp
    APIGW -->|"Memo routes"| MemoApp
    APIGW -->|"Email routes"| EmailApp
    APIGW -->|"HelloWorld routes"| HelloApp

    AuthApp -->|"reads/writes"| AuthDB
    MemoApp -->|"reads/writes"| MemoDB
    MemoApp -->|"publish notification"| MemoQueue
    MemoQueue -->|"triggers"| EmailApp
    EmailApp -->|"reads messages"| EmailQueue

    HelloApp -->|"reads/writes"| HelloDB

    AuthApp -->|"reads config"| ParamStore
    MemoApp -->|"reads config"| ParamStore
    EmailApp -->|"reads config"| ParamStore
    HelloApp -->|"reads config"| ParamStore

    %% Shared Library usage
    AuthApp -->|"uses shared lib"| Lib
    MemoApp -->|"uses shared lib"| Lib
    EmailApp -->|"uses shared lib"| Lib
    HelloApp -->|"uses shared lib"| Lib

    %% Click Events
    click D1 "https://github.com/gedaaaa/personal-serverless-web-app/tree/main/.devcontainer/"
    click D2 "https://github.com/gedaaaa/personal-serverless-web-app/tree/main/local-env/"
    click D3 "https://github.com/gedaaaa/personal-serverless-web-app/blob/main/nx.json"
    click D4 "https://github.com/gedaaaa/personal-serverless-web-app/blob/main/package.json"
    click D5 "https://github.com/gedaaaa/personal-serverless-web-app/blob/main/pnpm-lock.yaml"
    click D6 "https://github.com/gedaaaa/personal-serverless-web-app/blob/main/settings.gradle.kts"
    click CI1 "https://github.com/gedaaaa/personal-serverless-web-app/blob/main/.github/workflows/ci-pr.yml"
    click CI2 "https://github.com/gedaaaa/personal-serverless-web-app/blob/main/.github/workflows/cd-merge.yml"
    click FEStack "https://github.com/gedaaaa/personal-serverless-web-app/tree/main/apps/frontend/demo-website/"
    click FEpkg "https://github.com/gedaaaa/personal-serverless-web-app/blob/main/apps/frontend/demo-website/package.json"
    click FEsrc "https://github.com/gedaaaa/personal-serverless-web-app/tree/main/apps/frontend/demo-website/src/"
    click FEsst "https://github.com/gedaaaa/personal-serverless-web-app/blob/main/apps/frontend/demo-website/sst.config.ts"
    click Lib "https://github.com/gedaaaa/personal-serverless-web-app/tree/main/libs/jvm-shared-lib/"
    click LibSrc "https://github.com/gedaaaa/personal-serverless-web-app/tree/main/libs/jvm-shared-lib/src/main/kotlin/top/sunbath/shared/"
    click AuthApp "https://github.com/gedaaaa/personal-serverless-web-app/tree/main/apps/backend/auth/app/"
    click AuthInfra "https://github.com/gedaaaa/personal-serverless-web-app/tree/main/apps/backend/auth/infra/"
    click MemoApp "https://github.com/gedaaaa/personal-serverless-web-app/tree/main/apps/backend/memo/app/"
    click MemoInfra "https://github.com/gedaaaa/personal-serverless-web-app/tree/main/apps/backend/memo/infra/"
    click EmailApp "https://github.com/gedaaaa/personal-serverless-web-app/tree/main/apps/backend/email/app/"
    click EmailInfra "https://github.com/gedaaaa/personal-serverless-web-app/tree/main/apps/backend/email/infra/"
    click HelloApp "https://github.com/gedaaaa/personal-serverless-web-app/tree/main/apps/backend/helloworld/app/"
    click HelloInfra "https://github.com/gedaaaa/personal-serverless-web-app/tree/main/apps/backend/helloworld/infra/"

    %% Styles
    classDef compute fill:#cfe2f3,stroke:#000
    classDef datastore fill:#d9ead3,stroke:#000,stroke-dasharray: 5 5
    classDef message fill:#f9cb9c,stroke:#000
    classDef api fill:#c9c,stroke:#000
    classDef infra fill:#eeeeee,stroke:#000
    classDef external fill:#f0f0f0,stroke:#000,stroke-dasharray: 2 2
```
