# dontmint/chatemployeebot architecture

> Architecture diagram of the GitHub repository dontmint/chatemployeebot, 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/dontmint/chatemployeebot
- Repository: https://github.com/dontmint/chatemployeebot

## Overview

##### Main Components

a) Core Service Layer:
- Employee management system (derived from employee.go and manager.go)
- Broadcast system (from broadcast.go)
- Menu handling system (from menu.go)

b) Data Layer:
- PostgreSQL Database (indicated by postgresql.go and database/postgresql.sql)
- Data models for employees, locations, and check-in/checkout records

c) API Layer:
- REST/API endpoints (from api.go)
- Interaction points for external systems

d) Configuration:
- Config management (from config.yaml)
- Environment settings

##### Component Relationships

- Bot Service → PostgreSQL Database (data persistence)
- API Layer → Bot Service (service interactions)
- Bot Service → Broadcast System (notifications)
- Configuration → All Components (settings distribution)

##### Architectural Pattern Representation

Use these symbols and layouts:
- Hexagons for API endpoints

##### Detailed Component Breakdown

Bot Service (Core):
**┌─────────────────────────┐**
- Bot Service Core    │
- ┤
- Employee Management   │
- Location Tracking     │
- Check-in/out Logic   │
- Menu Handling        │
- ┘

Database Layer:
**┌─────────────────────────┐**
- PostgreSQL Layer     │
- ┤
- Employee Records      │
- Location Data        │
- Check-in/out Logs    │
- ┘

##### Implementation Details

a) Helper Functions Layer:
- Utility functions (from helper.go)
- Functionality (from map.go)
- Report generation (from report.go)

b) Infrastructure Elements:
- Docker container (from Dockerfile)
- Azure Pipeline integration (from azure-pipelines.yml)

##### Data Flow Representation

Following flows:

## Diagram (Mermaid)

```mermaid
%%{init: {
  'theme': 'base',
  'themeVariables': {
    'primaryColor': '#2b2b2b',
    'primaryTextColor': '#fff',
    'primaryBorderColor': '#7C0000',
    'lineColor': '#F8B229',
    'secondaryColor': '#006100',
    'tertiaryColor': '#0000ff'
  }
}}%%

flowchart TB
    subgraph Infrastructure
        Docker["Docker Container"]:::infrastructure
        CICD["Azure Pipeline"]:::infrastructure
        Config["Configuration Management"]:::config
    end

    subgraph "API Layer"
        API["REST API Interface"]:::api
    end

    subgraph "Core Service Layer"
        BotService["Bot Service"]:::core
        EmpSystem["Employee Management"]:::core
        MenuHandler["Menu Handler"]:::core
        BroadcastSys["Broadcast System"]:::core
    end

    subgraph "Helper Layer"
        MapFunc["Map Functionality"]:::helper
        ReportGen["Report Generator"]:::helper
        Utils["Utility Functions"]:::helper
    end

    subgraph "Data Layer"
        DB[(PostgreSQL Database)]:::database
        Models["Data Models"]:::data
        Schema["Database Schema"]:::data
    end

    %% Connections
    Config --> BotService
    Config --> API
    Config --> DB

    API --> BotService
    BotService --> EmpSystem
    BotService --> MenuHandler
    BotService --> BroadcastSys
    
    EmpSystem --> DB
    MenuHandler --> DB
    BroadcastSys --> DB

    BotService --> MapFunc
    BotService --> ReportGen
    BotService --> Utils

    Models --> DB
    Schema --> DB

    Docker --> BotService
    CICD --> Docker

    %% Click Events
    click BotService "https://github.com/dontmint/chatEmployeeBot/blob/main/main.go"
    click EmpSystem "https://github.com/dontmint/chatEmployeeBot/blob/main/employee.go"
    click MenuHandler "https://github.com/dontmint/chatEmployeeBot/blob/main/menu.go"
    click BroadcastSys "https://github.com/dontmint/chatEmployeeBot/blob/main/broadcast.go"
    click API "https://github.com/dontmint/chatEmployeeBot/blob/main/api.go"
    click MapFunc "https://github.com/dontmint/chatEmployeeBot/blob/main/map.go"
    click ReportGen "https://github.com/dontmint/chatEmployeeBot/blob/main/report.go"
    click Utils "https://github.com/dontmint/chatEmployeeBot/blob/main/helper.go"
    click Models "https://github.com/dontmint/chatEmployeeBot/blob/main/struct.go"
    click DB "https://github.com/dontmint/chatEmployeeBot/blob/main/postgresql.go"
    click Schema "https://github.com/dontmint/chatEmployeeBot/blob/main/database/postgresql.sql"
    click Config "https://github.com/dontmint/chatEmployeeBot/blob/main/config.yaml"
    click Docker "https://github.com/dontmint/chatEmployeeBot/tree/main/Dockerfile"
    click CICD "https://github.com/dontmint/chatEmployeeBot/blob/main/azure-pipelines.yml"

    %% Styling
    classDef core fill:#2b2b2b,stroke:#7C0000,color:#fff
    classDef api fill:#F8B229,stroke:#000,color:#000
    classDef database fill:#006100,stroke:#000,color:#fff
    classDef helper fill:#0000ff,stroke:#000,color:#fff
    classDef data fill:#4B0082,stroke:#000,color:#fff
    classDef infrastructure fill:#800000,stroke:#000,color:#fff
    classDef config fill:#008080,stroke:#000,color:#fff

    %% Legend
    subgraph Legend
        L1["Core Service"]:::core
        L2["API Component"]:::api
        L3["Database"]:::database
        L4["Helper Function"]:::helper
        L5["Data Component"]:::data
        L6["Infrastructure"]:::infrastructure
        L7["Configuration"]:::config
    end
```
