Skip to content
ganshyam135Public

About

Generic FastAPI-based API ingestion framework with pluggable connectors, job tracking, Docker support, and automated testing.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

DataForge

A generic API ingestion framework built with FastAPI, featuring pluggable connectors, job tracking, Docker support, and automated testing.

Live Demo

Due to time constraints and free-tier deployment limitations, the project is provided with Docker support for one-command local execution.

Run:

docker compose up --build

Swagger UI:

http://localhost:8000/docs

Tech Stack

  • Python 3.14
  • FastAPI
  • SQLAlchemy 2.x
  • SQLite
  • Pydantic v2
  • Loguru
  • Pytest
  • Docker
  • Docker Compose
  • HTTPX

Screenshots

Swagger Documentation

Swagger Documentation

Successful Ingestion

Successful Ingestion

Job History

Job History

Automated Tests

Pytest Results


Overview

DataForge is a generic REST API ingestion service designed to fetch data from external APIs, persist the raw JSON payloads, and track ingestion history.

Rather than building a connector for a single API, the project was designed around reusable abstractions so that additional APIs and storage backends can be integrated with minimal changes.

The architecture emphasizes clean separation of concerns by isolating HTTP communication, storage, business logic, and API orchestration into independent components.


Features

  • Generic REST API ingestion
  • Pluggable connector architecture
  • Pluggable storage architecture
  • Ingestion job tracking
  • Raw JSON payload storage
  • OpenAPI/Swagger documentation
  • SQLAlchemy ORM
  • Dependency Injection
  • Structured logging using Loguru
  • Automated tests using Pytest
  • Docker & Docker Compose support

Architecture

                    FastAPI

                        │

               POST /ingest

                        │

                PipelineService

          ┌─────────────┴─────────────┐

          ▼                           ▼

 GenericHTTPConnector           SQLiteStorage

          │

          ▼

     External REST APIs

          │

          ▼

      SQLite Database

          │

          ▼

Job Tracking & Stored Records

The API layer remains thin and is responsible only for request handling. Business logic is delegated to the PipelineService, while connectors and storage implementations remain interchangeable through abstract interfaces.


Project Structure

DataForge/

├── app/
│   ├── api/
│   ├── connectors/
│   ├── core/
│   ├── database/
│   ├── models/
│   ├── schemas/
│   ├── services/
│   └── storage/
│
├── tests/
│
├── assets/
│
├── Dockerfile
├── docker-compose.yml
├── pytest.ini
├── pyproject.toml
└── README.md

API Endpoints

Method Endpoint Description
GET /health Health check
POST /ingest Start a new ingestion job
GET /jobs Retrieve ingestion history
GET /jobs/{id} Retrieve a specific ingestion job
GET /records/{job_id} Retrieve records belonging to an ingestion job

Demo Walkthrough

Demo 1 — JSONPlaceholder

Request

{
  "url": "https://jsonplaceholder.typicode.com/posts",
  "method": "GET",
  "source": "jsonplaceholder"
}

Expected Result

  • 100 records fetched
  • 100 records stored

Demo 2 — GitHub Users

{
  "url": "https://api.github.com/users",
  "method": "GET",
  "source": "github"
}

Expected Result

  • GitHub user data successfully ingested through the same pipeline.

Design Decisions

Generic Connector

The ingestion pipeline depends on an abstract connector rather than a concrete HTTP implementation.

This allows future connectors (GitHub, Shopify, Stripe, Salesforce, etc.) to be added without modifying the pipeline itself.


Generic Storage

Storage is abstracted behind a common interface.

Although SQLite is currently implemented, the same pipeline can support PostgreSQL, MongoDB, Redis, or cloud object storage with minimal changes.


Pipeline Service

The PipelineService orchestrates the ingestion workflow.

Responsibilities:

  1. Fetch data from the connector
  2. Validate and normalize the response
  3. Persist records
  4. Return ingestion statistics

Keeping orchestration separate from the API layer improves maintainability, readability, and testability.


Job Tracking

Every ingestion creates an IngestionJob that stores:

  • Job status
  • Start timestamp
  • Completion timestamp
  • Number of fetched records
  • Number of stored records
  • Error message (if any)

Each stored record is linked back to its ingestion job through a foreign key, allowing complete traceability.


Testing

Automated tests were written using Pytest.

The test suite validates:

  • Job retrieval endpoint
  • Individual job lookup
  • Record retrieval
  • Empty record handling
  • Invalid job requests

Run tests:

uv run pytest

Current Status

========================
4 passed
========================

Docker

Build and run the application:

docker compose up --build

The application will be available at:

http://localhost:8000/docs

Running Locally

Install dependencies:

uv sync

Run the application:

uv run uvicorn app.main:app --reload

Open Swagger:

http://127.0.0.1:8000/docs

Example APIs Tested

The project was successfully tested against multiple public REST APIs:

JSONPlaceholder

https://jsonplaceholder.typicode.com/posts

GitHub Users API

https://api.github.com/users

Both APIs were ingested successfully using the same generic pipeline implementation.


AI Usage

AI tools were used as engineering assistants throughout development.

ChatGPT

Used for:

  • Architecture discussions
  • System design
  • SOLID principles
  • Dependency injection
  • Code reviews
  • Refactoring suggestions
  • Backend design decisions

GitHub Copilot / Codex

Used for:

  • Boilerplate generation
  • SQLAlchemy model scaffolding
  • FastAPI endpoint generation
  • Docker configuration
  • Test scaffolding

All generated code was manually reviewed, integrated, tested, and refactored where necessary.

One notable architectural refinement involved introducing a relationship between ingestion jobs and stored records (job_id). This improved traceability and enabled record retrieval for individual ingestion runs.

Authentication and advanced pagination strategies were intentionally left as future enhancements to keep the assignment focused on the generic ingestion architecture.

The GenericConnector already supports custom headers, making API-key and bearer-token authentication straightforward to add.

Pagination strategies differ across APIs (page-based, cursor-based, offset-based), so the connector abstraction was designed to accommodate future pagination implementations.

One example where AI assistance required human review involved introducing the relationship between ingestion jobs and ingested records.

Although the AI correctly updated the application code, it overlooked the existing SQLite schema. I identified the issue after runtime testing and recreated the development database. In a production system this would be handled through Alembic migrations.


Trade-offs

To keep the implementation focused within the assignment timeline, several production-grade features were intentionally deferred:

  • Database migrations using Alembic
  • Retry & exponential backoff
  • Advanced pagination strategies

Future Improvements

  • Alembic database migrations
  • PostgreSQL support
  • S3 storage backend
  • Background workers using Celery
  • Retry and exponential backoff
  • Multiple pagination strategies
  • OAuth/API key authentication
  • Scheduled ingestion jobs
  • Deployment to cloud platforms (Render, Railway, AWS)

Lessons Learned

This project provided practical experience with:

  • Designing extensible backend architectures
  • Applying SOLID principles
  • Dependency Injection
  • Abstract base classes
  • REST API design
  • SQLAlchemy ORM
  • Dockerizing FastAPI applications
  • Writing automated tests
  • Integrating AI-assisted development into a software engineering workflow

Author

Ganshyam Suthar

Backend Developer | Python | FastAPI | SQLAlchemy

About

Generic FastAPI-based API ingestion framework with pluggable connectors, job tracking, Docker support, and automated testing.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages