MCPcopy Index your code
hub / github.com/Marcus0086/formdata-etl_ai

github.com/Marcus0086/formdata-etl_ai @main

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

FormData ETL Pipeline System

A simple Extract, Transform, Load (ETL) pipeline system designed to be modular, scalable, and capable of handling various data synchronization strategies, including full overrides, incremental syncs, and deduplication.

Table of Contents

Architecture Overview

Architecture Diagram

The system consists of the following key components:

  • PocketBase Server: Acts as the central data store and admin interface.
  • ETL Orchestrator: Manages the scheduling and execution of ETL workflows.
  • Docker Manager: Handles the creation and management of Docker containers for extractors and loaders.
  • Extractors and Loaders: Modular components that perform data extraction and loading.
  • RabbitMQ: Facilitates communication between extractors and loaders through message queues.

Components

PocketBase Server

PocketBase is used as the backend server for managing configurations, states, and other metadata. It provides an easy-to-use admin UI and RESTful API for interacting with the system.

  • Stores definitions for sources, loaders, and connections.
  • Maintains state information for incremental syncs and deduplication.
  • Provides an admin interface for managing the ETL pipeline.

ETL Orchestrator

The orchestrator is responsible for coordinating the ETL workflows based on the configurations stored in PocketBase.

  • Schedules ETL jobs using cron expressions.
  • Initiates the ETL workflow by starting extractors and loaders as Docker containers.
  • Manages the state and execution flow of ETL jobs.

Docker Manager

A custom Go package (dockermanager) that handles the creation, starting, and stopping of Docker containers.

  • Connects to the Docker daemon to manage containers.
  • Passes environment variables and configurations to containers.
  • Handles networking and volume mounting for containers.

Extractors and Loaders

Modular components that perform the actual data extraction and loading.

  • Extractors: Fetch data from various sources (files, APIs, databases).
  • Loaders: Load transformed data into target destinations (files, databases, message queues).
  • Implement a common interface for consistency and extensibility.
  • Use environment variables to receive configurations and state information.

RabbitMQ

RabbitMQ is used as a message broker to facilitate communication between extractors and loaders.

  • Each ETL job can have its own dedicated queue.
  • Supports dynamic queue creation and deletion based on connectionId.
  • Enables scalable and decoupled data processing.

Features

  • Modular Design: Easily add new extractors and loaders.
  • Flexible Scheduling: Supports manual and scheduled ETL jobs using cron expressions.
  • Dynamic Container Management: Starts and stops Docker containers for extractors and loaders as needed.
  • State Management: Maintains state for incremental syncs and deduplication.
  • Scalability: Potential to integrate with Kubernetes for scaling workloads.
  • Extensibility: Designed to accommodate various data sources and synchronization strategies.

Getting Started

Prerequisites

  • Docker: Ensure Docker is installed and running on your machine.
  • Docker Compose: For orchestrating multi-container applications.
  • Go: Version 1.20 or higher for building Go applications.

Setup Instructions

  1. Run the server stack with RabbitMq
docker compose up --build -d // this will build the server image and start the server and rabbitmq
  1. Build extractors and loaders
> docker build -t [extractor_name]:latest -f build/sources/[extractor_name]/Dockerfile .
> docker build -t [loader_name]:latest -f build/loaders/[loader_name]/Dockerfile .

Usage

  • Create a new admin account on pocketbase installer at localhost:8090/_
  • Inside the dashboard create a new user record under user collection.
  • Get authorization token for the user from admin api.
curl -X POST "http://localhost:8090/api/collections/users/auth-with-password" \
-H "Content-Type: application/json" \
-d '{ "identity": "example@gmail.com", "password": "example" }'

Defining Source and Loaders

Create a Source

curl -X POST "{{formdata_backend}}/api/source" \
-H "Authorization: {{user_token}}" \
-H "Content-Type: application/json" \
-d '{ "name": "extractor_name", "type": "file_extractor", "config": {} }'

Create a Loader

curl -X POST "{{formdata_backend}}/api/loader" \
-H "Authorization: {{user_token}}" \
-H "Content-Type: application/json" \
-d '{ "name": "loader_name", "type": "json_loader", "config": {} }'

Creating Connections

Manual sync

curl -X POST "{{formdata_backend}}/api/connection" \
-H "Authorization: {{user_token}}" \
-H "Content-Type: application/json" \
-d '{ "source_id": "source_id", "loader_id": "loader_id", "sync_type": "manual", "config": {} }'

Scheduled sync

curl -X POST "{{formdata_backend}}/api/connection" \
-H "Authorization: {{user_token}}" \
-H "Content-Type: application/json" \
-d '{ "source_id": "source_id", "loader_id": "loader_id", "sync_type": "scheduled", "schedule": "* * * * *", "config": {} }'

Running ETL Jobs

curl -X POST "{{formdata_backend}}/api/sync" \
-H "Authorization: {{user_token}}" \
-H "Content-Type: application/json" \
-d '{ "connection_id": "connection_id" }'

Extension points exported contracts — how you extend this code

Config (Interface)
(no doc) [3 implementers]
pkg/models/db_models.go
MessageQueueClient (Interface)
(no doc) [1 implementers]
pkg/messagequeues/client.go
WorkerFunc (FuncType)
(no doc)
pkg/wokrerpool/workerpool.go

Core symbols most depended-on inside this repo

Close
called by 8
pkg/messagequeues/client.go
NewChannel
called by 5
pkg/messagequeues/rabbitmq_client.go
NewETLProcess
called by 3
pkg/utils/etl_process.go
Publish
called by 3
pkg/messagequeues/client.go
Start
called by 3
pkg/wokrerpool/workerpool.go
Cleanup
called by 3
pkg/models/etl_process.go
saveCollection
called by 3
pkg/db/db.go
ConfigToEnv
called by 2
pkg/utils/transform.go

Shape

Function 27
Method 18
Struct 12
Interface 2
FuncType 1

Languages

Go100%

Modules by API surface

pkg/wokrerpool/workerpool.go8 symbols
pkg/messagequeues/rabbitmq_client.go6 symbols
pkg/models/db_models.go5 symbols
pkg/utils/transform.go4 symbols
pkg/messagequeues/client.go4 symbols
pkg/dockermanager/dockermanager.go4 symbols
pkg/orchestrator/orchestrator.go3 symbols
pkg/models/etl_process.go3 symbols
pkg/models/web_scraper.go2 symbols
pkg/models/json_loader.go2 symbols
pkg/models/file_extractor.go2 symbols
pkg/messagequeues/message.go2 symbols

For agents

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

⬇ download graph artifact