AI Data Translation Layer
Back to Documentation

Technical Specification

v1.0\u2022MVP Implementation\u2022March 2026

1.1 Architecture Overview

The AI Data Translation Layer follows a monolithic Next.js architecture designed with clear separation of concerns to enable future decomposition into microservices. The system implements a three-layer intelligence pipeline: Extract → Analyze → Remediate. Layer 1 (ERP Connectors) ingests data from enterprise systems, Layer 2 (AI Insights Engine) identifies risks and compliance gaps, and Layer 3 (ERP Remediation Engine) generates specific, actionable fix instructions with ERP transaction codes — the core USP.

System Architecture Diagram
┌─────────────────────────────────────────────────────────────────┐
│                     CLIENT LAYER                                │
│  Next.js React UI  |  REST API Consumers  |  SSE Clients       │
└────────────────────────────┬────────────────────────────────────┘
                             │
┌────────────────────────────┼────────────────────────────────────┐
│                  NEXT.JS API LAYER                              │
│                                                                 │
│  /api/upload/*        Upload & Storage Management               │
│  /api/process/:id     AI Extraction (SSE Streaming)             │
│  /api/connectors/*    ERP Connector Management (Layer 1)        │
│  /api/insights/*      AI Insights Engine (Layer 2)              │
│  /api/insights/*/remediation  ERP Remediation (Layer 3 — USP)   │
│  /api/jobs/*          Job CRUD & Management                     │
│  /api/stats           Dashboard Analytics                       │
└───────┬──────────┬──────────┬──────────┬────────────────────────┘
        │          │          │          │
┌───────┴────┐ ┌───┴────┐ ┌───┴────┐ ┌───┴──────────────────────┐
│ PostgreSQL │ │ AWS S3  │ │ Abacus │ │  Three-Layer Pipeline   │
│ (Jobs,     │ │ (File   │ │ LLM API│ │                         │
│  Connectors│ │ Storage)│ │ (GPT-  │ │  L1: ERP Connectors     │
│  Insights, │ │         │ │  4.1)  │ │  L2: AI Insights        │
│  Remediate)│ │         │ │        │ │  L3: Remediation (USP)  │
└────────────┘ └────────┘ └────────┘ └─────────────────────────┘

1.2 Technology Stack

LayerTechnologyVersionPurpose
FrameworkNext.js14.2.xFull-stack React framework with API routes
LanguageTypeScript5.2.xType-safe development across frontend and backend
DatabasePostgreSQL16.xRelational storage for job metadata and results
ORMPrisma6.7.xType-safe database access with migrations
Object StorageAWS S3SDK v3File storage with presigned URL uploads
AI/LLMAbacus.AI (GPT-4.1)v1 APIAI-powered data extraction and structuring
UI LibraryReact18.2.xComponent-based user interface
StylingTailwind CSS3.3.xUtility-first CSS framework
AnimationFramer Motion10.18.xPage transitions and micro-interactions
IconsLucide React0.446.xConsistent SVG icon library
Document ParsingMammothLatestDOCX to text extraction

1.3 Directory Structure

Project Layout
nextjs_space/
├── app/
│   ├── api/                      # REST API endpoints
│   │   ├── upload/               # File upload management
│   │   │   ├── presigned/        #   Presigned URL generation
│   │   │   ├── complete/         #   Upload confirmation
│   │   │   └── multipart/        #   Large file multipart flow
│   │   ├── process/[id]/         # AI extraction (SSE streaming)
│   │   ├── jobs/                 # Job CRUD operations
│   │   ├── connectors/           # ERP connector management (Layer 1)
│   │   │   └── [id]/             #   Single connector + test endpoint
│   │   │       └── test/         #     Connection testing
│   │   ├── insights/             # AI insights engine (Layer 2)
│   │   │   ├── generate/         #   LLM-powered insight generation
│   │   │   ├── stats/            #   Aggregated insight statistics
│   │   │   └── [id]/             #   Single insight + actions
│   │   │       └── remediation/  #     ERP remediation engine (Layer 3 — USP)
│   │   └── stats/                # Dashboard statistics
│   ├── components/               # Shared UI components
│   ├── upload/                   # Upload page
│   ├── jobs/                     # Job list + detail pages
│   ├── connectors/               # ERP connector management page
│   ├── insights/                 # Insights & remediation page
│   ├── api-docs/                 # API documentation page
│   ├── docs/                     # Product & Technical specs
│   ├── layout.tsx                # Root layout
│   ├── page.tsx                  # Dashboard (home)
│   └── globals.css               # Global styles & CSS vars
├── lib/                          # Core utilities
│   ├── prisma.ts                 #   Prisma singleton
│   ├── aws-config.ts             #   S3 client configuration
│   ├── s3.ts                     #   S3 operations
│   ├── extraction.ts             #   LLM prompts & output conversion
│   ├── file-processing.ts        #   File type handling & text extraction
│   └── utils.ts                  #   General utilities
├── prisma/
│   └── schema.prisma             # Database schema (Job, Connector, Insight, Remediation)
└── public/                       # Static assets

1.4 Key Architectural Decisions

DecisionChoiceRationaleTrade-off
FrameworkNext.js monolithFast MVP iteration, SSR, API routes in one codebaseWill need decomposition at scale
File StorageDirect-to-S3 presigned URLsNo server bottleneck, handles large files nativelyRequires client-side upload logic
AI ProcessingSynchronous SSE streamingReal-time progress, simple implementationTies up server connection per job
DatabasePostgreSQL with JSONBFlexible result storage, strong consistencyJSON queries less performant than dedicated doc store
AuthAPI key (MVP)Simple, sufficient for betaNeeds OAuth/SSO for enterprise