# bencodezen/amp-shark architecture

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

- Interactive diagram: https://gitdiagram.com/bencodezen/amp-shark
- Repository: https://github.com/bencodezen/amp-shark

## Overview

##### Main Components
a. Frontend (Vue.js App)
- src/main.ts → bootstraps the Vue application with Vite & TypeScript
- Vue Router (src/router/) → route definitions (index, play, high-score, sign-in)
- Pinia Store (src/stores/GameStore.ts) → client‐side state management
- Components & Pages (src/components/, src/pages/) → UI for sign‐in, gameplay, timer, scoreboard
- Composables (src/composables/) → reusable logic for timer (useTimer) and Score API (useScoreApi)
b. AWS Amplify & CI/CD
- amplify.yml → build & deploy settings in Amplify Console
- amplify/ (CLI‐generated CloudFormation resources)
c. AWS Services
- Amazon Cognito (Auth) → user authentication & identity pools
- AWS AppSync (GraphQL API) → creates GraphQL endpoint
- Amazon DynamoDB (Data) → stores high scores, game round data

##### Relationships & Data Flows
- Browser (Vue App) ⇄ Cognito SDK (Amplify Auth)
- Sign-up / Sign-in flows
- Browser ⇄ AppSync GraphQL
- Queries & mutations via useScoreApi composable
- AppSync ⇄ DynamoDB
- Data sources & resolvers defined in amplify/data/resource.ts
- GitHub (or repo) → Amplify Console
- CI/CD pipeline triggered by amplify.yml

##### Architectural Patterns & Principles
- SPA (Single‐Page Application) pattern – clear separation of routing and components
- Modular composables for reusability (e.g. useTimer, useScoreApi)
- State management with Pinia (GameStore)
- Infrastructure as Code via Amplify CLI (CloudFormation under the hood)
- Serverless backend – pay‐per‐use, auto‐scaling

##### Putting It All Together
- In the center, show AWS Amplify Console as the orchestrator of CI/CD and IaC

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Side
    subgraph "Client (Browser)"
        direction TB
        Main["Vue App Bootstrap"]:::client
        subgraph "Routing" 
            direction TB
            RouterIndex["Router Index"]:::client
            RouterRoutes["Router Routes"]:::client
        end
        Store["GameStore (Pinia)"]:::client
        subgraph "Components"
            direction TB
            ArrowSymbol["ArrowSymbol.vue"]:::client
            GamePlay["GamePlay.vue"]:::client
            TheAuthenticator["TheAuthenticator.vue"]:::client
            TheScoreboard["TheScoreboard.vue"]:::client
            TheTimer["TheTimer.vue"]:::client
        end
        subgraph "Pages"
            direction TB
            HomePage["Home Page"]:::client
            HighScorePage["High Score Page"]:::client
            SignInPage["Sign-In Page"]:::client
            subgraph "Play Flow"
                direction TB
                PlayIndex["Play Index"]:::client
                PlayRound["Play Round"]:::client
                PlayComplete["Play Complete"]:::client
            end
        end
        subgraph "Composables"
            direction TB
            ScoreApi["useScoreApi()"]:::client
            TimerLogic["useTimer()"]:::client
        end
    end

    %% CI/CD & Amplify
    subgraph "Amplify & CI/CD"
        direction TB
        GitHub["Git Repository"]:::infra
        AmplifyConsole["AWS Amplify Console"]:::infra
        CloudFormation["CloudFormation (amplify/backend)"]:::infra
    end

    %% AWS Services
    subgraph "AWS Services"
        direction TB
        Cognito["Amazon Cognito"]:::aws
        AppSync["AWS AppSync (GraphQL API)"]:::aws
        DynamoDB[(DynamoDB)]:::db
    end

    %% Relationships
    Main -->|"Authenticate"| Cognito
    Main -->|"GraphQL Query/Mutation"| AppSync
    AppSync -->|"Read/Write"| DynamoDB
    GitHub -->|"- - Git Push / CI Trigger - -"| AmplifyConsole
    AmplifyConsole -->|"- - Deploy / IaC - -"| CloudFormation
    CloudFormation --> Cognito
    CloudFormation --> AppSync
    CloudFormation --> DynamoDB

    %% Click Events
    click Main "https://github.com/bencodezen/amp-shark/blob/main/src/main.ts"
    click RouterIndex "https://github.com/bencodezen/amp-shark/blob/main/src/router/index.ts"
    click RouterRoutes "https://github.com/bencodezen/amp-shark/blob/main/src/router/routes.ts"
    click Store "https://github.com/bencodezen/amp-shark/blob/main/src/stores/GameStore.ts"
    click ArrowSymbol "https://github.com/bencodezen/amp-shark/blob/main/src/components/ArrowSymbol.vue"
    click GamePlay "https://github.com/bencodezen/amp-shark/blob/main/src/components/GamePlay.vue"
    click TheAuthenticator "https://github.com/bencodezen/amp-shark/blob/main/src/components/TheAuthenticator.vue"
    click TheScoreboard "https://github.com/bencodezen/amp-shark/blob/main/src/components/TheScoreboard.vue"
    click TheTimer "https://github.com/bencodezen/amp-shark/blob/main/src/components/TheTimer.vue"
    click HomePage "https://github.com/bencodezen/amp-shark/blob/main/src/pages/index.vue"
    click HighScorePage "https://github.com/bencodezen/amp-shark/blob/main/src/pages/high-score.vue"
    click SignInPage "https://github.com/bencodezen/amp-shark/blob/main/src/pages/sign-in.vue"
    click PlayIndex "https://github.com/bencodezen/amp-shark/blob/main/src/pages/play/index.vue"
    click PlayRound "https://github.com/bencodezen/amp-shark/blob/main/src/pages/play/round-[id].vue"
    click PlayComplete "https://github.com/bencodezen/amp-shark/blob/main/src/pages/play/complete.vue"
    click ScoreApi "https://github.com/bencodezen/amp-shark/blob/main/src/composables/useScoreApi.ts"
    click TimerLogic "https://github.com/bencodezen/amp-shark/blob/main/src/composables/useTimer.ts"
    click AmplifyConsole "https://github.com/bencodezen/amp-shark/blob/main/amplify.yml"
    click CloudFormation "https://github.com/bencodezen/amp-shark/blob/main/amplify/backend.ts"
    click Cognito "https://github.com/bencodezen/amp-shark/blob/main/amplify/auth/resource.ts"
    click AppSync "https://github.com/bencodezen/amp-shark/blob/main/amplify/data/resource.ts"
    click DynamoDB "https://github.com/bencodezen/amp-shark/blob/main/amplify/data/resource.ts"

    %% Styles
    classDef client fill:#D0E8FF,stroke:#0366d6,color:#000
    classDef infra fill:#FFF7ED,stroke:#EA580C,color:#000
    classDef aws fill:#FFEDD5,stroke:#D97706,color:#000
    classDef db fill:#D1FAE5,stroke:#059669,color:#000,stroke-width:2px
```
