Back to Documentation
Technical Specification
v1.0\u2022MVP Implementation\u2022March 2026
Table of Contents
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
| Layer | Technology | Version | Purpose |
|---|---|---|---|
| Framework | Next.js | 14.2.x | Full-stack React framework with API routes |
| Language | TypeScript | 5.2.x | Type-safe development across frontend and backend |
| Database | PostgreSQL | 16.x | Relational storage for job metadata and results |
| ORM | Prisma | 6.7.x | Type-safe database access with migrations |
| Object Storage | AWS S3 | SDK v3 | File storage with presigned URL uploads |
| AI/LLM | Abacus.AI (GPT-4.1) | v1 API | AI-powered data extraction and structuring |
| UI Library | React | 18.2.x | Component-based user interface |
| Styling | Tailwind CSS | 3.3.x | Utility-first CSS framework |
| Animation | Framer Motion | 10.18.x | Page transitions and micro-interactions |
| Icons | Lucide React | 0.446.x | Consistent SVG icon library |
| Document Parsing | Mammoth | Latest | DOCX 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 assets1.4 Key Architectural Decisions
| Decision | Choice | Rationale | Trade-off |
|---|---|---|---|
| Framework | Next.js monolith | Fast MVP iteration, SSR, API routes in one codebase | Will need decomposition at scale |
| File Storage | Direct-to-S3 presigned URLs | No server bottleneck, handles large files natively | Requires client-side upload logic |
| AI Processing | Synchronous SSE streaming | Real-time progress, simple implementation | Ties up server connection per job |
| Database | PostgreSQL with JSONB | Flexible result storage, strong consistency | JSON queries less performant than dedicated doc store |
| Auth | API key (MVP) | Simple, sufficient for beta | Needs OAuth/SSO for enterprise |