# sushilkshetri/final-project-stateful-serverless architecture

> Architecture diagram of the GitHub repository sushilkshetri/final-project-stateful-serverless, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sushilkshetri/final-project-stateful-serverless
- Repository: https://github.com/sushilkshetri/final-project-stateful-serverless

## Overview

This repository is a serverless comparison project: it implements a single-owner, in-memory object model alongside a Lambda-and-DynamoDB baseline, then benchmarks both on counters, contested bookings, chat broadcasts, and scale/cost. Shared rules are intended to keep the comparison consistent. The README documents the major interactions, but many sampled Go entry points and helpers are TODOs, so the graph represents documented design rather than verified runtime behavior; edges cite the README or the relevant excerpt where available.

Main entry points: [`stateless/cmd`](https://github.com/sushilkshetri/final-project-stateful-serverless/tree/main/stateless/cmd) (Stateless Lambdas), [`stateful/cmd`](https://github.com/sushilkshetri/final-project-stateful-serverless/tree/main/stateful/cmd) (Stateful Lambdas), [`loadtest/http/scenarios/counter.py`](https://github.com/sushilkshetri/final-project-stateful-serverless/blob/main/loadtest/http/scenarios/counter.py) (Counter workload), [`loadtest/http/scenarios/booking.py`](https://github.com/sushilkshetri/final-project-stateful-serverless/blob/main/loadtest/http/scenarios/booking.py) (Booking workload)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shared["Shared domain rules"]
  node_shared_rules["Domain rules"]
  node_booking_rules["Booking rules<br/>[booking.go]"]
  node_counter_rules["Counter rules<br/>[counter.go]"]
  node_chat_types["Chat message types<br/>[chat.go]"]
end

subgraph group_stateful["Stateful system"]
  node_stateful_functions["Stateful Lambdas"]
  node_object_client["Object client<br/>[objectclient.go]"]
  node_owner_node["Owner node<br/>[main.go]"]
  node_owner_server["HTTP and WebSocket server<br/>[server.go]"]
  node_owner_runtime["Owner runtime"]
  node_object_state["Stateful objects"]
  node_object_storage[("Object persistence<br/>[storage.go]")]
end

subgraph group_stateless["Stateless baseline"]
  node_stateless_functions["Stateless Lambdas"]
  node_dynamo_access["DynamoDB access<br/>[client.go]"]
  node_connection_table[("Connections table")]
end

subgraph group_evaluation["Benchmark workloads"]
  node_counter_workload["Counter workload<br/>[counter.py]"]
  node_booking_workload["Booking workload<br/>[booking.py]"]
  node_scale_workload["Scale and cost workload<br/>[many_objects.py]"]
  node_chat_workload["Chat benchmark<br/>[main.go]"]
  node_chat_room["Chat room workload<br/>[03-chat.yaml]"]
end

node_users(("Workload users"))
node_dynamodb[("DynamoDB")]
node_api_gateway["API Gateway WebSockets"]

node_users -->|"runs"| node_counter_workload
node_users -->|"runs"| node_booking_workload
node_users -->|"runs"| node_scale_workload
node_users -->|"runs"| node_chat_workload
node_counter_workload -.->|"exercises"| node_stateful_functions
node_counter_workload -.->|"exercises"| node_stateless_functions
node_booking_workload -.->|"exercises"| node_stateful_functions
node_booking_workload -.->|"exercises"| node_stateless_functions
node_scale_workload -.->|"exercises"| node_stateful_functions
node_scale_workload -.->|"exercises"| node_stateless_functions
node_chat_workload -.->|"measures"| node_chat_room
node_stateful_functions -->|"uses same rules"| node_shared_rules
node_stateless_functions -->|"uses same rules"| node_shared_rules
node_stateful_functions -->|"calls object"| node_object_client
node_object_client -->|"locates and calls"| node_owner_node
node_owner_node -->|"starts server"| node_owner_server
node_owner_server -->|"receives calls"| node_owner_runtime
node_owner_runtime -->|"handles serially"| node_object_state
node_object_state -.->|"persists state"| node_object_storage
node_stateless_functions -->|"accesses data"| node_dynamo_access
node_dynamo_access -->|"reads and writes"| node_dynamodb
node_stateless_functions -->|"serves chat"| node_api_gateway
node_stateless_functions -->|"stores connection IDs"| node_connection_table
node_stateful_functions -.->|"uses booking logic"| node_booking_rules
node_stateful_functions -.->|"uses counter logic"| node_counter_rules
node_stateless_functions -.->|"uses booking logic"| node_booking_rules
node_stateless_functions -.->|"uses counter logic"| node_counter_rules
node_stateless_functions -.->|"uses message format"| node_chat_types

click node_shared_rules "https://github.com/sushilkshetri/final-project-stateful-serverless/tree/main/shared"
click node_booking_rules "https://github.com/sushilkshetri/final-project-stateful-serverless/blob/main/shared/booking.go"
click node_counter_rules "https://github.com/sushilkshetri/final-project-stateful-serverless/blob/main/shared/counter.go"
click node_chat_types "https://github.com/sushilkshetri/final-project-stateful-serverless/blob/main/shared/chat.go"
click node_stateful_functions "https://github.com/sushilkshetri/final-project-stateful-serverless/tree/main/stateful/cmd"
click node_object_client "https://github.com/sushilkshetri/final-project-stateful-serverless/blob/main/stateful/client/objectclient.go"
click node_owner_node "https://github.com/sushilkshetri/final-project-stateful-serverless/blob/main/stateful/cmd/owner/main.go"
click node_owner_server "https://github.com/sushilkshetri/final-project-stateful-serverless/blob/main/stateful/owner/server.go"
click node_owner_runtime "https://github.com/sushilkshetri/final-project-stateful-serverless/tree/main/stateful/owner"
click node_object_state "https://github.com/sushilkshetri/final-project-stateful-serverless/tree/main/stateful/objects"
click node_object_storage "https://github.com/sushilkshetri/final-project-stateful-serverless/blob/main/stateful/owner/storage.go"
click node_stateless_functions "https://github.com/sushilkshetri/final-project-stateful-serverless/tree/main/stateless/cmd"
click node_dynamo_access "https://github.com/sushilkshetri/final-project-stateful-serverless/blob/main/stateless/db/client.go"
click node_connection_table "https://github.com/sushilkshetri/final-project-stateful-serverless/tree/main/stateless"
click node_counter_workload "https://github.com/sushilkshetri/final-project-stateful-serverless/blob/main/loadtest/http/scenarios/counter.py"
click node_booking_workload "https://github.com/sushilkshetri/final-project-stateful-serverless/blob/main/loadtest/http/scenarios/booking.py"
click node_scale_workload "https://github.com/sushilkshetri/final-project-stateful-serverless/blob/main/loadtest/http/scenarios/many_objects.py"
click node_chat_workload "https://github.com/sushilkshetri/final-project-stateful-serverless/blob/main/loadtest/chat/main.go"
click node_chat_room "https://github.com/sushilkshetri/final-project-stateful-serverless/blob/main/experiments/configs/03-chat.yaml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_shared_rules,node_booking_rules,node_counter_rules,node_chat_types,node_users toneBlue
class node_stateful_functions,node_object_client,node_owner_node,node_owner_server,node_owner_runtime,node_object_state,node_object_storage,node_dynamodb toneAmber
class node_stateless_functions,node_dynamo_access,node_connection_table,node_api_gateway toneMint
class node_counter_workload,node_booking_workload,node_scale_workload,node_chat_workload,node_chat_room toneRose
```

## Components

### Shared domain rules

- [Domain rules](https://github.com/sushilkshetri/final-project-stateful-serverless/tree/main/shared): `shared`
- [Booking rules](https://github.com/sushilkshetri/final-project-stateful-serverless/blob/main/shared/booking.go): `shared/booking.go`
- [Counter rules](https://github.com/sushilkshetri/final-project-stateful-serverless/blob/main/shared/counter.go): `shared/counter.go`
- [Chat message types](https://github.com/sushilkshetri/final-project-stateful-serverless/blob/main/shared/chat.go): `shared/chat.go`

### Stateful system

- [Stateful Lambdas](https://github.com/sushilkshetri/final-project-stateful-serverless/tree/main/stateful/cmd): `stateful/cmd`
- [Object client](https://github.com/sushilkshetri/final-project-stateful-serverless/blob/main/stateful/client/objectclient.go): `stateful/client/objectclient.go`
- [Owner node](https://github.com/sushilkshetri/final-project-stateful-serverless/blob/main/stateful/cmd/owner/main.go): `stateful/cmd/owner/main.go`
- [HTTP and WebSocket server](https://github.com/sushilkshetri/final-project-stateful-serverless/blob/main/stateful/owner/server.go): `stateful/owner/server.go`
- [Owner runtime](https://github.com/sushilkshetri/final-project-stateful-serverless/tree/main/stateful/owner): `stateful/owner`
- [Stateful objects](https://github.com/sushilkshetri/final-project-stateful-serverless/tree/main/stateful/objects): `stateful/objects`
- [Object persistence](https://github.com/sushilkshetri/final-project-stateful-serverless/blob/main/stateful/owner/storage.go): `stateful/owner/storage.go`

### Stateless baseline

- [Stateless Lambdas](https://github.com/sushilkshetri/final-project-stateful-serverless/tree/main/stateless/cmd): `stateless/cmd`
- [DynamoDB access](https://github.com/sushilkshetri/final-project-stateful-serverless/blob/main/stateless/db/client.go): `stateless/db/client.go`
- [Connections table](https://github.com/sushilkshetri/final-project-stateful-serverless/tree/main/stateless): `stateless`

### Benchmark workloads

- [Counter workload](https://github.com/sushilkshetri/final-project-stateful-serverless/blob/main/loadtest/http/scenarios/counter.py): `loadtest/http/scenarios/counter.py`
- [Booking workload](https://github.com/sushilkshetri/final-project-stateful-serverless/blob/main/loadtest/http/scenarios/booking.py): `loadtest/http/scenarios/booking.py`
- [Scale and cost workload](https://github.com/sushilkshetri/final-project-stateful-serverless/blob/main/loadtest/http/scenarios/many_objects.py): `loadtest/http/scenarios/many_objects.py`
- [Chat benchmark](https://github.com/sushilkshetri/final-project-stateful-serverless/blob/main/loadtest/chat/main.go): `loadtest/chat/main.go`
- [Chat room workload](https://github.com/sushilkshetri/final-project-stateful-serverless/blob/main/experiments/configs/03-chat.yaml): `experiments/configs/03-chat.yaml`

### Other components

- **Workload users**
- **DynamoDB**
- **API Gateway WebSockets**

## Connections

- Workload users → Counter workload: runs (evidence: `README.md`)
- Workload users → Booking workload: runs (evidence: `README.md`)
- Workload users → Scale and cost workload: runs (evidence: `README.md`)
- Workload users → Chat benchmark: runs (evidence: `README.md`)
- Counter workload → Stateful Lambdas: exercises
- Counter workload → Stateless Lambdas: exercises
- Booking workload → Stateful Lambdas: exercises
- Booking workload → Stateless Lambdas: exercises
- Scale and cost workload → Stateful Lambdas: exercises
- Scale and cost workload → Stateless Lambdas: exercises
- Chat benchmark → Chat room workload: measures
- Stateful Lambdas → Domain rules: uses same rules (evidence: `README.md`)
- Stateless Lambdas → Domain rules: uses same rules (evidence: `README.md`)
- Stateful Lambdas → Object client: calls object (evidence: `stateful/client/objectclient.go`)
- Object client → Owner node: locates and calls (evidence: `stateful/client/objectclient.go`)
- Owner node → HTTP and WebSocket server: starts server (evidence: `stateful/cmd/owner/main.go`)
- HTTP and WebSocket server → Owner runtime: receives calls (evidence: `stateful/owner/server.go`)
- Owner runtime → Stateful objects: handles serially (evidence: `README.md`)
- Stateful objects → Object persistence: persists state
- Stateless Lambdas → DynamoDB access: accesses data (evidence: `stateless/db/client.go`)
- DynamoDB access → DynamoDB: reads and writes (evidence: `README.md`)
- Stateless Lambdas → API Gateway WebSockets: serves chat (evidence: `README.md`)
- Stateless Lambdas → Connections table: stores connection IDs (evidence: `README.md`)
- Stateful Lambdas → Booking rules: uses booking logic
- Stateful Lambdas → Counter rules: uses counter logic
- Stateless Lambdas → Booking rules: uses booking logic
- Stateless Lambdas → Counter rules: uses counter logic
- Stateless Lambdas → Chat message types: uses message format
