# btelle/alexa-boardgame-answers architecture

> Architecture diagram of the GitHub repository btelle/alexa-boardgame-answers, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/btelle/alexa-boardgame-answers
- Repository: https://github.com/btelle/alexa-boardgame-answers

## Overview

##### Main Components Identification
The project is an Alexa Skill with the following key components:

a) Alexa Interaction Layer
- Custom slots (board game names and equipment types)
- Intent definitions
- Sample utterances

b) Data Layer
- Game-specific JSON files containing rule information
- Response templates

c) Lambda Function Layer
- AWS Lambda handler for processing requests

##### Component Relationships

Use the following connections:

- User → Alexa Device
- Alexa Device → Alexa Skills Kit
- Alexa Skills Kit → Lambda Function
- Lambda Function → Game Data JSON Files

- Intent Schema ⇢ Alexa Skills Kit
- Custom Slots ⇢ Alexa Skills Kit
- Sample Utterances ⇢ Alexa Skills Kit

##### Specific Elements

a) Input Processing:
- How user questions about board games are matched to intents
- Custom slot types for game names and equipment

b) Data Organization:
- Game-specific JSON files structure
- How responses are templated and formatted

c) Response Flow:
- How answers are constructed and returned to the user

##### Technical Details to Highlight

- JSON file structure for game rules
- Intent matching process
- Custom slot type implementation
- Response formation logic

Remember to include a note about the contribution workflow, showing how new games can be added through the data/games directory and how the custom slots are updated accordingly.

This system design should effectively communicate both the current architecture and how it can be extended with new games and question types in the future.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph User["User Interaction Layer"]
        User1[User]
        AlexaDevice[Alexa Device]
        ASR[Speech Recognition]
    end

    subgraph ASK["Alexa Skills Kit Layer"]
        IntentSchema["Intent Schema"]:::config
        CustomSlots["Custom Slots"]:::config
        Utterances["Sample Utterances"]:::config
        ASKInterface["ASK Interface"]:::alexa
    end

    subgraph Lambda["Lambda Processing Layer"]
        LambdaFn["Lambda Function"]:::lambda
        IntentProcessor["Intent Processing"]:::lambda
        ResponseBuilder["Response Builder"]:::lambda
    end

    subgraph Data["Data Storage Layer"]
        GameData["Game Data Store"]:::data
        ResponseTemplates["Response Templates"]:::data
        TestData["Test Data"]:::test
    end

    %% User Flow
    User1 --> AlexaDevice
    AlexaDevice --> ASR
    ASR --> ASKInterface

    %% Configuration Flow
    IntentSchema -.-> ASKInterface
    CustomSlots -.-> ASKInterface
    Utterances -.-> ASKInterface

    %% Processing Flow
    ASKInterface --> LambdaFn
    LambdaFn --> IntentProcessor
    IntentProcessor --> ResponseBuilder
    
    %% Data Access
    ResponseBuilder --> GameData
    ResponseBuilder --> ResponseTemplates
    IntentProcessor --> TestData

    %% Return Flow
    ResponseBuilder --> ASKInterface
    ASKInterface --> AlexaDevice
    AlexaDevice --> User1

    %% Click Events
    click CustomSlots "https://github.com/btelle/alexa-boardgame-answers/tree/master/alexa/custom_slots"
    click IntentSchema "https://github.com/btelle/alexa-boardgame-answers/blob/master/alexa/intents.txt"
    click Utterances "https://github.com/btelle/alexa-boardgame-answers/blob/master/alexa/sample_utterances.txt"
    click GameData "https://github.com/btelle/alexa-boardgame-answers/tree/master/data/games"
    click ResponseTemplates "https://github.com/btelle/alexa-boardgame-answers/blob/master/data/responses.json"
    click LambdaFn "https://github.com/btelle/alexa-boardgame-answers/tree/master/lambda"
    click TestData "https://github.com/btelle/alexa-boardgame-answers/tree/master/test-data"

    %% Styling
    classDef config fill:#90EE90,stroke:#333,stroke-width:2px
    classDef alexa fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef lambda fill:#FFD700,stroke:#333,stroke-width:2px
    classDef data fill:#FFA500,stroke:#333,stroke-width:2px
    classDef test fill:#DDA0DD,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1[Configuration]:::config
        L2[Alexa Components]:::alexa
        L3[Lambda Processing]:::lambda
        L4[Data Storage]:::data
        L5[Test Components]:::test
    end
```
