# spacerumsfeld-code/topcakes architecture

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

- Interactive diagram: https://gitdiagram.com/spacerumsfeld-code/topcakes
- Repository: https://github.com/spacerumsfeld-code/topcakes

## Overview

##### Main System Components

a) Frontend Layer
- Next.js Application (src/app directory structure)
- Web3 Integration (ThirdWeb)
- UI Components (src/ui directory)

b) Backend Layer
- Server Components (src/server)
- API Routers
- Database Integration (Drizzle)

c) Infrastructure Layer (infra/)
- AWS Services
- Event Bus System
- Storage Solutions (S3)
- Secrets Management

##### Key Relationships to Highlight

- Client-to-server communication
- Web3 interaction flow
- Event bus publish/subscribe patterns
- Data persistence flow

##### Component Details

**Frontend Components:**
- Pages (src/app/**)
- Components (src/app/_components)
- Web3 Provider (src/providers)
- UI Library (src/ui)

**Backend Services:**
- API Routes (src/server/routers)
- Domain Logic (src/domain)
- Database Clients (src/clients)

**Infrastructure:**
- AWS Event Bus
- S3 Storage
- Database
- Secrets Management

##### Implementation Notes

- Clear separation between client and server components
- Event-driven architecture
- Demonstrate the Web3 integration points
- Database migration flow
- Authentication flow

##### Additional Elements

Include:
- Version information
- Main data flow paths
- Security boundaries
- Scaling points

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Frontend Layer"
        NextApp["Next.js Application"]
        Web3Provider["Web3 Provider"]
        UIComponents["UI Components"]
        AuthButton["Auth Button"]
        ClientServices["Client Services"]
    end

    subgraph "Server Layer"
        ServerComponents["Server Components"]
        APIRouters["API Routers"]
        DomainLogic["Domain Logic"]
    end

    subgraph "Infrastructure Layer"
        AWS["AWS Services"]
        EventBus["Event Bus"]
        S3["S3 Storage"]
        DB[(Database)]
        Secrets["Secrets Management"]
    end

    %% Frontend Connections
    NextApp --> Web3Provider
    NextApp --> UIComponents
    NextApp --> AuthButton
    NextApp --> ClientServices
    ClientServices --> APIRouters

    %% Server Connections
    APIRouters --> ServerComponents
    ServerComponents --> DomainLogic
    DomainLogic --> DB
    
    %% Infrastructure Connections
    ServerComponents --> EventBus
    ServerComponents --> S3
    ServerComponents --> Secrets
    EventBus --> AWS
    S3 --> AWS

    %% Styling
    classDef frontend fill:#a8d1ff,stroke:#333,stroke-width:2px
    classDef server fill:#90EE90,stroke:#333,stroke-width:2px
    classDef infra fill:#FFB6C1,stroke:#333,stroke-width:2px
    classDef web3 fill:#FFD700,stroke:#333,stroke-width:2px

    class NextApp,UIComponents,AuthButton,ClientServices frontend
    class ServerComponents,APIRouters,DomainLogic server
    class AWS,EventBus,S3,DB,Secrets infra
    class Web3Provider web3

    %% Click Events
    click NextApp "https://github.com/spacerumsfeld-code/TopCakes/tree/main/src/app/"
    click UIComponents "https://github.com/spacerumsfeld-code/TopCakes/tree/main/src/ui/"
    click Web3Provider "https://github.com/spacerumsfeld-code/TopCakes/blob/main/src/providers/Web3.provider.tsx"
    click AuthButton "https://github.com/spacerumsfeld-code/TopCakes/tree/main/src/app/_components/auth-button/"
    click ServerComponents "https://github.com/spacerumsfeld-code/TopCakes/tree/main/src/server/_internals/"
    click APIRouters "https://github.com/spacerumsfeld-code/TopCakes/tree/main/src/server/routers/"
    click DomainLogic "https://github.com/spacerumsfeld-code/TopCakes/tree/main/src/domain/"
    click ClientServices "https://github.com/spacerumsfeld-code/TopCakes/tree/main/src/clients/"
    click S3 "https://github.com/spacerumsfeld-code/TopCakes/blob/main/infra/storage.ts"
    click Secrets "https://github.com/spacerumsfeld-code/TopCakes/blob/main/infra/secret.ts"
    click DB "https://github.com/spacerumsfeld-code/TopCakes/tree/main/migrations/"

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        Server["Server Component"]:::server
        Infrastructure["Infrastructure"]:::infra
        Web3["Web3 Component"]:::web3
    end
```
