# emaohi/shifty architecture

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

- Interactive diagram: https://gitdiagram.com/emaohi/shifty
- Repository: https://github.com/emaohi/shifty

## Overview

##### Main Components

a) Core Application Components:
- Django Web Application (Main server)
- Celery Worker System
- RabbitMQ Message Broker
- Database Layer (MySQL)
- Redis Cache
- ElasticSearch Engine

b) External Services:
- Google Maps API
- Profanity API
- Holidays API
- Logo Finder Service

##### Client Layer
- Manager Interface
- Employee Interface
- Anonymous User Interface

##### Web Application Layer (Django)
- Core Module (shift management)
- Log Module (user/business management)
- Menu Module (quiz system)

##### Service Layer
- Authentication Service
- Shift Generation Algorithm
- Search Service
- Caching Service
- Leader Board Service

##### Background Processing Layer
- Celery Workers
- Task Queue (RabbitMQ)

##### Data Storage Layer
- MySQL Database
- Redis Cache
- ElasticSearch

##### External Services Layer
- Third-party APIs
- Logo Finder Service

##### Specific Design Elements

Use the following visual elements:
- Blue rectangles for core application components
- Green rectangles for external services
- Orange rectangles for data stores
- Purple rectangles for message queues

##### Key Flows to Highlight

a) Shift Management Flow:
- Shift creation/generation
- Shift swap requests
- Employee assignments

b) Background Tasks Flow:
- Holiday updates
- Email notifications
- ElasticSearch indexing
- Logo fetching

c) Caching Strategy:
- ETL to business
- Employee requests
- Manager messages
- Previous shifts

##### Additional Details

A separate section showing:
- Health check monitoring points
- Cache invalidation paths
- Search indexing flow
- Leader board update mechanism

##### Notes Section

Notes about:
- Scalability points
- Failure recovery paths
- Cache update strategies
- Algorithm selection points

Remember to highlight the key features mentioned in the README, such as the shift generation algorithm, caching strategy, and integration with external services, as these are crucial to understanding the system's architecture.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    subgraph ClientLayer["Client Layer"]
        MI["Manager Interface"]
        EI["Employee Interface"]
        AI["Anonymous Interface"]
    end

    %% Web Application Layer
    subgraph WebApp["Django Web Application"]
        Core["Core Module"]:::core
        Log["Log Module"]:::log
        Menu["Quiz Module"]:::menu
        Auth["Authentication Service"]:::auth
        ShiftGen["Shift Generation Algorithm"]:::shiftgen
        Search["Search Service"]:::search
    end

    %% Service Layer
    subgraph Services["Service Layer"]
        Cache["Caching Service"]
        Leader["Leader Board Service"]
        CeleryW["Celery Worker"]:::celery
        TaskQ["RabbitMQ Queue"]:::queue
    end

    %% Data Storage Layer
    subgraph Storage["Data Storage"]
        DB[(MySQL Database)]
        Redis[(Redis Cache)]
        ES[(ElasticSearch)]
    end

    %% External Services Layer
    subgraph External["External Services"]
        Maps["Google Maps API"]
        Prof["Profanity API"]
        Holiday["Holidays API"]
        Logo["Logo Finder"]
    end

    %% Relationships
    MI --> Core
    EI --> Core
    AI --> Core
    
    Core --> Auth
    Core --> ShiftGen
    Core --> Search
    Core --> Cache
    
    Log --> Auth
    Menu --> Auth
    
    Search --> ES
    Cache --> Redis
    
    CeleryW --> TaskQ
    TaskQ --> Core
    
    Core --> DB
    Log --> DB
    Menu --> DB
    
    Core -.-> Maps
    Core -.-> Prof
    CeleryW -.-> Holiday
    CeleryW -.-> Logo

    %% Styling
    classDef core fill:#a8d5ff
    classDef log fill:#a8d5ff
    classDef menu fill:#a8d5ff
    classDef auth fill:#a8d5ff
    classDef shiftgen fill:#a8d5ff
    classDef search fill:#a8d5ff
    classDef celery fill:#ffb6c1
    classDef queue fill:#dda0dd

    %% Click Events
    click Core "https://github.com/emaohi/shifty/tree/master/core/"
    click Log "https://github.com/emaohi/shifty/tree/master/log/"
    click Menu "https://github.com/emaohi/shifty/tree/master/menu/"
    click Auth "https://github.com/emaohi/shifty/blob/master/log/backends.py"
    click ShiftGen "https://github.com/emaohi/shifty/blob/master/core/shift_generator.py"
    click Search "https://github.com/emaohi/shifty/blob/master/core/search.py"
    click CeleryW "https://github.com/emaohi/shifty/blob/master/Shifty/celery.py"
    click MI "https://github.com/emaohi/shifty/tree/master/templates/manager/"
    click EI "https://github.com/emaohi/shifty/tree/master/templates/employee/"

    %% Legend
    subgraph Legend
        L1[Django Components]:::core
        L2[Background Tasks]:::celery
        L3[Message Queue]:::queue
        L4[("Data Storage")]
        L5["External API"]
    end
```
