MCPcopy Index your code
hub / github.com/airscholar/FlinkCommerce

github.com/airscholar/FlinkCommerce @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
16 symbols 46 edges 8 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Apache Flink E-Commerce Analytics with Elasticsearch and Postgres

This repository contains an Apache Flink application for real-time sales analytics built using Docker Compose to orchestrate the necessary infrastructure components, including Apache Flink, Elasticsearch, and Postgres. The application processes financial transaction data from Kafka, performs aggregations, and stores the results in both Postgres and Elasticsearch for further analysis.

Requirements

  • Docker
  • Docker Compose

Architecture

System Architecture.png

Installation and Setup

  1. Clone this repository.
  2. Navigate to the repository directory.
  3. Run docker-compose up to start the required services (Apache Flink, Elasticsearch, Postgres).
  4. The Sales Transaction Generator main.py helps to generate the sales transactions into Kafka.

Usage

  1. Ensure all Docker containers are up and running.
  2. Run the FlinkCommerce application provided in this repository to perform real-time analytics on financial transactions.

Application Details

The DataStreamJob class within the FlinkCommerce package serves as the main entry point for the Flink application. The application consumes financial transaction data from Kafka, performs various transformations, and stores aggregated results in both Postgres and Elasticsearch.

Components

Apache Flink

  • Sets up the Flink execution environment.
  • Connects to Kafka as a source for financial transaction data.
  • Processes, transforms, and performs aggregations on transaction data streams.

Postgres

  • Stores transaction data and aggregated results in tables (transactions, sales_per_category, sales_per_day, sales_per_month).

Elasticsearch

  • Stores transaction data for further analysis.

Code Structure

  • DataStreamJob.java: Contains the Flink application logic, including Kafka source setup, stream processing, transformations, and sinks for Postgres and Elasticsearch.
  • Deserializer, Dto, and utils packages: Include necessary classes and utilities for deserialization, data transfer objects, and JSON conversion.

Configuration

  • Kafka settings (bootstrap servers, topic, group ID) are configured within the Kafka source setup.
  • Postgres connection details (URL, username, password) are defined in the jdbcUrl, username, and password variables.

Sink Operations

  • The application includes sink operations for Postgres using JDBC to create tables (transactions, sales_per_category, sales_per_day, sales_per_month) and perform insert/update operations.
  • Additionally, it includes an Elasticsearch sink to index transaction data for further analysis.

Video

Flink Ecommerce Analytics

Core symbols most depended-on inside this repo

generate_sales_transactions
called by 1
SalesTransactionGenerator/main.py
main
called by 1
SalesTransactionGenerator/main.py
convertTransactionToJson
called by 1
src/main/java/utils/JsonUtil.java
delivery_report
called by 0
SalesTransactionGenerator/main.py
main
called by 0
src/main/java/FlinkCommerce/DataStreamJob.java
open
called by 0
src/main/java/Deserializer/JSONValueDeserializationSchema.java
deserialize
called by 0
src/main/java/Deserializer/JSONValueDeserializationSchema.java
isEndOfStream
called by 0
src/main/java/Deserializer/JSONValueDeserializationSchema.java

Shape

Class 7
Method 6
Function 3

Languages

Java81%
Python19%

Modules by API surface

src/main/java/Deserializer/JSONValueDeserializationSchema.java5 symbols
SalesTransactionGenerator/main.py3 symbols
src/main/java/utils/JsonUtil.java2 symbols
src/main/java/FlinkCommerce/DataStreamJob.java2 symbols
src/main/java/Dto/Transaction.java1 symbols
src/main/java/Dto/SalesPerMonth.java1 symbols
src/main/java/Dto/SalesPerDay.java1 symbols
src/main/java/Dto/SalesPerCategory.java1 symbols

Datastores touched

postgresDatabase · 1 repos

For agents

$ claude mcp add FlinkCommerce \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact