# flipkart/foxtrot architecture

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

- Interactive diagram: https://gitdiagram.com/flipkart/foxtrot
- Repository: https://github.com/flipkart/foxtrot

## Overview

##### Main Components
- Clients/Users: Represent different types of consumers:
- Web Console (built using Twitter Bootstrap, jQuery, D3, Flot, etc.)
- External REST API consumers and command-line FQL clients.
- Foxtrot Server: The central service (built with Dropwizard) that exposes REST endpoints.
- Business Logic and Core Processing (Foxtrot Core):
- Query execution, caching, scheduling jobs, internal event handling (using Guava Event Bus) and alerting.
- Query and SQL Processing (Foxtrot SQL):
- FQL parsing and transformation into actions/queries.
- Data Translation (Foxtrot Translator):
- Handling document transformation and possibly data segregation.
- Shared Utilities (Foxtrot Common):
- POJOs and utility classes used across all modules.
- External Data Stores:
- HBase: for fast row get/put operations.
- Elasticsearch: for indexing, aggregation, and search.
- Hazelcast: as a distributed caching layer.
- Authentication & Authorization:
- Different auth providers (Google, IDMAN, and others) integrated into the server (using modules under foxtrot-server/auth).
- Deployment & Configuration:
- Docker and Docker Compose setups, various configuration files (YAML) that enable custom deployment pipelines.

- Frontend / Client Layer:
- Service Layer (Foxtrot Server):
- REST API endpoints.
- Authentication & Authorization (e.g., JWT Auth, Auth Providers).
- Endpoints for event ingestion, console management, and FQL queries.
- Server to the “Business Logic / Core” layer below it.
- Business Logic / Core Layer:
- Inside “Foxtrot Core” include key responsibilities:
- Query Store for executing actions.
- Cache management (using Hazelcast).
- Scheduled jobs (e.g., data deletion, session cleanup, and index optimization).
- Internal event bus for propagating alerts/notifications.
- That this layer uses “Foxtrot Common” for shared data models and utilities.
- Query Processing / SQL Engine:
- Mention its role in parsing FQL and acting as the query translation layer.
- Data Translation:
- “Foxtrot Translator” as an adjacent or integrated module that helps with document transformation and identity key distribution.
- Data Storage/External Services:
- “HBase Cluster” for fast raw data storage.
- “Elasticsearch Cluster” for analytics and indexing.
- “Hazelcast Cluster” for distributed caching.
- Infrastructure & Deployment:
- Optionally denote a containerization layer – with Dockerfiles and docker-compose files – that “envelops” these services, indicating that deployment configurations support different pull-in environments for tests, production, and even specialized deployments (e.g., using different docker-compose files for authentication).

##### Architectural Patterns & Design Principles
- Layered Architecture: Clearly separate the UI/Client interactions (REST API and web console) from the service logic (server, core, SQL processing) and from the external data storage.
- Modular Design: Emphasize the separation between foxtrot-common, foxtrot-core, foxtrot-server, etc.
- Extensibility: Note that new analytics operations are easily added by creating annotated classes – show an “extensibility point” marker if desired.
- Separation of Concerns: Authentication, query processing, data translation, and data storage are each handled in separate modules; connect them through well-defined interfaces.

##### Final Suggestions
- To capture important design principles such as modularity and extensibility points.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        WC["Web Console"]:::client
        RC["REST/CLI Client"]:::client
    end

    %% Service Layer
    subgraph "Service Layer"
        FS["Foxtrot Server - API & Auth"]:::server
        RE["REST API Endpoints"]:::server
        AM["Auth Module"]:::server
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        FC["Foxtrot Core - Business Logic & Caching"]:::core
        FCm["Foxtrot Common - Shared Utilities"]:::common
        FC -->|"uses"| FCm
    end

    %% Processing Layer
    subgraph "Processing Layer"
        FSQL["Foxtrot SQL - Query Processing"]:::sql
        FT["Foxtrot Translator - Data Translation"]:::translator
    end

    %% External Data Stores
    subgraph "External Data Stores"
        HBase["HBase Cluster"]:::external
        ES["Elasticsearch Cluster"]:::external
        HZ["Hazelcast Cluster"]:::external
    end

    %% Deployment and Configuration
    subgraph "Deployment & Configuration"
        DEP["Deployment & Configuration"]:::deployment
    end

    %% Connections from Clients to Service Layer
    WC -->|"RESTAPICall"| FS
    RC -->|"RESTAPICall"| FS

    %% Connections within Service Layer
    FS -->|"exposes"| RE
    FS -->|"handles"| AM

    %% Connections from Service Layer to Business Logic
    FS -->|"ingestData"| FC

    %% Query Processing Connections
    FS -->|"FQLQuery"| FSQL
    FSQL -->|"executesQuery"| FC

    %% Data Translation Connection
    FC -->|"transformsData"| FT

    %% Connections from Business Logic to External Data Stores
    FC -->|"rawDataOps"| HBase
    FC -->|"analyticsOps"| ES
    FC -->|"cacheOps"| HZ

    %% Deployment Connections
    DEP -->|"deploys"| FS
    DEP -->|"deploys"| FC
    DEP -->|"deploys"| FSQL
    DEP -->|"deploys"| FT

    %% Click Events
    click WC "https://github.com/flipkart/foxtrot/tree/master/foxtrot-server/src/main/resources/console"
    click RE "https://github.com/flipkart/foxtrot/tree/master/foxtrot-server/src/main/java/com/flipkart/foxtrot/server/resources"
    click FS "https://github.com/flipkart/foxtrot/tree/master/foxtrot-server"
    click FC "https://github.com/flipkart/foxtrot/tree/master/foxtrot-core"
    click FCm "https://github.com/flipkart/foxtrot/tree/master/foxtrot-common"
    click FSQL "https://github.com/flipkart/foxtrot/tree/master/foxtrot-sql"
    click FT "https://github.com/flipkart/foxtrot/tree/master/foxtrot-translator"
    click AM "https://github.com/flipkart/foxtrot/tree/master/foxtrot-server/src/main/java/com/flipkart/foxtrot/server/auth"
    click DEP "https://github.com/flipkart/foxtrot/tree/master/config directory"

    %% Styles
    classDef client fill:#FCEAC1,stroke:#333,stroke-width:2px;
    classDef server fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef core fill:#A9DFBF,stroke:#117864,stroke-width:2px;
    classDef common fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef sql fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    classDef translator fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef external fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
    classDef deployment fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
```
