Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions kits/dq-issue-detector/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Lamatic API configuration
LAMATIC_API_KEY=your_lamatic_api_key_here
LAMATIC_PROJECT_ID=your_lamatic_project_id_here
LAMATIC_ENDPOINT=https://your-project-endpoint.lamatic.dev

# Deployed Flow IDs
DATA_QUALITY_AGENT=your_data_quality_agent_flow_id_here
4 changes: 4 additions & 0 deletions kits/dq-issue-detector/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.lamatic/
node_modules/
.env
.env.local
79 changes: 79 additions & 0 deletions kits/dq-issue-detector/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Data Quality Issue Detector Kit

## 1. The Problem
Before analyzing data or training machine learning models, cleaning raw data is always the first and most critical step. Identifying null/missing values, duplicates, out-of-range numerical fields, formatting syntax problems (e.g. invalid emails or dates), and status casing inconsistencies is usually done manually with custom Python/Pandas scripts. This can be time-consuming, repetitive, and inaccessible to non-technical users who just want a quick audit of their files.

## 2. The Approach
We built an AI-powered data quality audit agent using Next.js and the Lamatic API.
- **Workflow:** The user loads or pastes a dataset (CSV) and provides optional instructions (e.g. "Focus on validating emails and ignore columns without names").
- **Agent Action:** The LLM-backed agent scans the dataset row-by-row, identifying anomalies, missing information, schema mismatches, and duplicated records.
- **Interactive UI:** The Next.js frontend previews the CSV as an interactive table, triggers the Server Action to invoke the Lamatic flow, and renders the detailed audit report side-by-side using markdown.

## 3. The Result
An instantly usable web tool to run automated health checks on dataset CSVs. Teams receive a clear, prioritized checklist of data clean-up items, complete with column-specific summaries, issues categorized by severity (High, Medium, Low), and actionable cleaning steps to feed into their ETL scripts.

---

## AgentKit Collection (1 flow)

This AgentKit contains 1 flow:
- **Data Quality Agent** (`flows/data-quality-agent.ts`)

---

## Prerequisites
* **Node.js** (v18 or higher recommended)
* **npm** or **pnpm** package manager
* A valid **Lamatic API Key**, **Project ID**, and **API URL/Endpoint**

---

## Setup Instructions

1. **Initialize the App Directory**
```bash
cd apps
npm install
```

2. **Configure Environment Variables**
Create a local env file:
```bash
cp .env.example .env.local
```
Open `.env.local` and add your Lamatic credentials:
```env
LAMATIC_API_KEY=your_api_key_here
LAMATIC_PROJECT_ID=your_project_id_here
LAMATIC_ENDPOINT=https://your-endpoint.lamatic.dev
DATA_QUALITY_AGENT=your_deployed_flow_id_here
```

3. **Start the Development Server**
```bash
npm run dev
```
The application will be available at `http://localhost:3000`.

---

## Programmatic Usage Example

The Next.js frontend calls the Lamatic flow via Next.js Server Actions:

```typescript
import { analyzeDatasetQuality } from "@/actions/orchestrate";

const checkData = async () => {
const csvContent = `id,name,email,age
1,John Doe,john@example.com,28
2,Jane Smith,,thirty-four
1,John Doe,john@example.com,28`;

const result = await analyzeDatasetQuality(csvContent, "Check for schema issues and duplicates.");

if (result.success) {
console.log("Analysis Report:", result.data);
}
};
```
22 changes: 22 additions & 0 deletions kits/dq-issue-detector/agent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Data Quality Issue Detector

You are a data quality assistant.

Your job is to analyze uploaded tabular data and identify:
- missing values
- duplicate rows
- invalid formats
- outliers
- inconsistent categories
- suspicious values
- data type mismatches

Return:
1. Dataset summary
2. Issues found
3. Severity
4. Suggested fixes
5. Quality score out of 100
6. Final recommendation

Be concise, practical, and easy to understand.
7 changes: 7 additions & 0 deletions kits/dq-issue-detector/apps/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Lamatic API configuration
LAMATIC_API_KEY=your_lamatic_api_key_here
LAMATIC_PROJECT_ID=your_lamatic_project_id_here
LAMATIC_ENDPOINT=https://your-project-endpoint.lamatic.dev

# Deployed Flow IDs
DATA_QUALITY_AGENT=your_data_quality_agent_flow_id_here
7 changes: 7 additions & 0 deletions kits/dq-issue-detector/apps/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.env
.env.local
node_modules
.next
out
dist
tsconfig.tsbuildinfo
55 changes: 55 additions & 0 deletions kits/dq-issue-detector/apps/actions/orchestrate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"use server";

import { lamaticClient } from "../lib/lamatic-client"
import lamaticConfig from "../../lamatic.config"

export async function orchestrateAnalysis(formData: FormData) {
try {
const file = formData.get("file") as File | null;
if (!file) throw new Error("File is required");

const fileContent = await file.text();

const step = lamaticConfig.steps.find((s) => s.id === "data-quality-agent") as any;
let workflowId = step?.workflowId || (step?.envKey ? process.env[step.envKey] : undefined);
if (!workflowId) {
workflowId = process.env.DATA_QUALITY_AGENT;
}
if (!workflowId) {
throw new Error("Data Quality Agent workflow ID is not configured. Please define it in lamatic.config.ts or the DATA_QUALITY_AGENT env variable.");
}

const query = `
query ExecuteWorkflow($workflowId: String!, $file: JSON) {
executeWorkflow(
workflowId: $workflowId
payload: { file: $file }
) {
status
result
}
}`;

const variables = {
workflowId,
file: {
name: file.name,
content: fileContent
}
};

const response = await lamaticClient.executeGraphQL(query, variables);

let report = response.result;
if (typeof report === "object" && report !== null) {
report = report.report || JSON.stringify(report, null, 2);
}

return { success: true, data: report };

} catch (error: unknown) {
console.error("Data Quality Analysis Error:", error);
const message = error instanceof Error ? error.message : String(error);
return { success: false, error: message };
}
}
Comment thread
donallsiby marked this conversation as resolved.
65 changes: 65 additions & 0 deletions kits/dq-issue-detector/apps/app/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
@import "tailwindcss";

:root {
color-scheme: light;
--background: #f8fafc;
--foreground: #0f172a;
--surface: #ffffff;
--surface-muted: #f1f5f9;
--border: #e2e8f0;
--border-strong: #cbd5e1;
--muted: #64748b;
--muted-strong: #334155;
--heading: #0f172a;
--primary: #4f46e5;
--primary-hover: #4338ca;
--primary-foreground: #ffffff;
--primary-soft: #e0e7ff;
--primary-soft-foreground: #4338ca;
--danger: #dc2626;
--danger-soft: #fef2f2;
--danger-border: #fecaca;
--success: #16a34a;
--success-soft: #f0fdf4;
--success-border: #bbf7d0;
}

* {
box-sizing: border-box;
}

body {
margin: 0;
background: var(--background);
color: var(--foreground);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
sans-serif;
}

button,
input,
textarea {
font: inherit;
}

textarea {
resize: vertical;
}

/* Custom markdown rendering styling */
.prose h1, .prose h2, .prose h3 {
font-weight: 700;
color: var(--heading);
margin-top: 1.5em;
margin-bottom: 0.5em;
}
.prose h1 { font-size: 1.5rem; border-bottom: 2px solid var(--border); padding-bottom: 0.3em; }
.prose h2 { font-size: 1.25rem; }
.prose h3 { font-size: 1.1rem; }
.prose p { margin-top: 0.5em; margin-bottom: 0.5em; line-height: 1.6; }
.prose ul, .prose ol { padding-left: 1.5rem; margin-top: 0.5em; margin-bottom: 0.5em; }
.prose li { margin-top: 0.25em; margin-bottom: 0.25em; }
.prose strong { color: var(--heading); font-weight: 600; }
.prose code { background-color: var(--surface-muted); padding: 0.15rem 0.3rem; rounded: 0.25rem; font-family: monospace; font-size: 0.9em; }
Comment thread
donallsiby marked this conversation as resolved.
.prose blockquote { border-left: 4px solid var(--border-strong); padding-left: 1rem; color: var(--muted); font-style: italic; }
19 changes: 19 additions & 0 deletions kits/dq-issue-detector/apps/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { Metadata } from "next";
import "./globals.css";

export const metadata: Metadata = {
title: "Data Quality Issue Detector",
description: "Scans datasets for anomalies, missing values, duplicates, and formatting issues with Lamatic.",
};

export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en">
<body>{children}</body>
</html>
);
}
Loading
Loading