Status: Active Development
Current Phase: Phase 2 — Workflow Engine Data Layer (Shell + Versioned Graphs)
The AI Automation Platform (AAP) is a highly scalable, multi-tenant B2B SaaS platform designed to automate complex ERP, HR, and Financial System workflows.
At its core, AAP combines Autonomous AI Agents with a Visual Workflow Engine (powered by LangGraph) and Retrieval-Augmented Generation (RAG) to create intelligent, automated pipelines that can securely interact with sensitive enterprise data.
- Visual Workflow Builder: Drag-and-drop orchestration of LLM nodes, tools, and logic.
- Agentic Framework: Long-running, multi-step autonomous agents with memory, tool access, and dynamic routing.
- Enterprise RAG: Built-in Knowledge Base with hybrid search (HNSW pgvector + GIN keyword) and automated OCR ingestion pipelines.
- Strict Multi-Tenancy: Hardened Row Level Security (RLS) ensuring strict data isolation across organizations.
- Robust Auditing: Immutable, append-only audit trails for every material action.
We have completed the foundational Database Schema and Migration Layer (Volume 2 §1 - §3.8), the Authentication & RBAC Layer (Volume 2 §10 - §11), and the Workflow Engine data layer (Volume 2 §3.2) — workflow shell CRUD plus versioned graph storage.
- Docker Infrastructure: Configured
docker-compose.ymlwithpgvector/pgvector:pg16for PostgreSQL, alongside Redis and MinIO (S3 compatible object storage). - SQLAlchemy ORM Models: We mapped out 19 core tables divided across domains:
- Identity & Tenancy: Users, Roles, Organizations, API Keys, Workspaces.
- Workflow Engine: Workflows, Versions, Nodes, Edges, Runs, and Node Executions.
- Agents & RAG: Agents, Agent Sessions, Agent Memory (
Vector(1536)), Prompts, Tools, Knowledge Bases, and Document Chunks. - Audit & Chat: Immutable Audit Logs, Chats, Messages, and Notifications.
- Advanced Alembic Migrations:
- Initial schema generation incorporating
pgvectorandcitext. - Advanced manual indexes (HNSW for semantic search, GIN for full-text search, and composite B-trees).
- Manually authored Row Level Security (RLS) migration enforcing tenant isolation policies across the entire schema via
app.current_org_idcontext.
- Initial schema generation incorporating
- FastAPI & Core Security Foundations:
- Established the FastAPI application structure and environment configuration using Pydantic Settings.
- Implemented highly secure Authentication routes (
/register,/login,/switch-org,/refresh,/logout). - Hardened JWT patterns: The opaque
refresh_tokenis handled securely via anhttpOnly,Secure, andSameSite=Strictcookie, whilst theaccess_tokenis sent back in the JSON body. - Used Argon2 for advanced password hashing.
- Redis Integration & Security Controls:
- Implemented an asynchronous connection pool leveraging
redis-py(aioredis). - Implemented Refresh Token Rotation and a JWT Blocklist (by checking the
jticlaim). - Designed a highly-performant Role-Based Access Control (RBAC) permission dependency (
require_permission) that pulls directly from a Redis cache to avoid hitting the database on every authenticated request. - Secured the public Auth routes with a Redis-backed Sliding Window Rate Limiter (
RateLimiterdependency).
- Implemented an asynchronous connection pool leveraging
- Workflow Shell CRUD (
/api/v1/workflows):- Create, list, get, update, and soft-delete (archive) workflows scoped to organization and workspace.
- Workspace ownership verified explicitly at the service layer (clean 404, not RLS-dependent).
- Event bus hooks:
workflow.created,workflow.updated,workflow.archived.
- Workflow Version Graph Storage (
/api/v1/workflows/{id}/versions):- Save/update draft graphs as a single atomic request (nodes + edges together, not per-node CRUD).
- Structural validation at save and publish time: unique
node_key, edge referential integrity, start/end nodes required, orphan detection, cycle detection. - Draft lifecycle: re-saving a draft replaces its nodes/edges in-place; publishing creates immutability; a new save after publish creates the next version number.
- Publish sets
Workflow.current_version_id— the only code path that updates that field. - Event bus hooks:
workflow_version.saved,workflow_version.published. - Known gap:
agent_id/tool_id/prompt_idreferences in nodeconfigare stored as opaque UUIDs without FK validation (those modules don't exist yet). - Not yet built: LangGraph compiler (§6.1), execution runs, Celery workers, visual builder UI.
Want to spin this up on your local machine? Ensure you have Docker and Poetry (or Pipx) installed.
We use Docker to run the database, cache, and object storage.
cd infra
docker compose up -d postgresWe use pyproject.toml to manage our dependencies. If you have Poetry installed:
cd apps/api
poetry install(Alternatively, if you don't have Poetry, you can install the dependencies via pip manually):
cd apps/api
python -m pip install alembic sqlalchemy asyncpg psycopg2-binary pgvector pydantic-settings pydanticPush the database schemas, indexes, and RLS policies into the live Postgres container:
cd apps/api
alembic upgrade headcd apps/api
poetry run pytestConnect to the database using your favorite client (DBeaver, pgAdmin, VS Code SQLTools) with the following credentials:
- Host:
localhost - Port:
5432 - User:
aap_user - Password:
aap_pass - Database:
aap_db
This repository is actively being built. Next phases: graph compiler (LangGraph), workflow execution infrastructure, and the visual builder frontend.