How bhaveshg-22/data-alchemist works
Project type and purpose
• This is a full-stack web application built with Next.js (App Router), React, and TypeScript.
• Purpose: “Data Alchemist” ingests CSV/XLSX datasets, runs comprehensive validations, applies AI-powered transformations, lets users configure business rules, and then exports cleaned data and rule sets.
File structure
• Top-level:
• next.config.ts, tsconfig.json, package.json → Next.js + TypeScript configuration.
• public/sample → Static sample CSV/XLSX and JSON.
• src/app/… → Next.js App Router:
• src/app/page.tsx, layout.tsx → UI shell, pages.
• src/app/api/[ai-column-mapping, ai-fix, nl-modify, validation]/route.ts → Serverless API endpoints.
• src/components → React UI components (file upload, editable tables, AI rule input, validation summary, export).
• src/hooks → Custom React hooks (state management for command templates, toast notifications, undo/redo history).
• src/utils → Pure utility modules (file parsing, export wrangling, NLP helpers).
• src/validators → Domain logic modules implementing 12+ validation rules.
• config, validators/types.ts → Shared type definitions, prioritization criteria.
README for insights
• Confirms Next.js 15 + React 19 + Tailwind CSS.
• Walks through core and bonus AI features, specifies which files implement which features.
• No traditional database — data flows through in-memory React state and stateless API calls, with all persistence via file export.
a. Main components
1. Client Browser (React SPA)
2. Next.js Server (App Router):
• Page rendering
• Serverless API routes
3. AI Service (external OpenAI API)
4. Validation Engine (stateless JS modules in /src/validators)
5. File Parsing & Export Utils
6. Static Assets (public/sample)
b. Relationships & data flows
• Browser → Next.js page/ui components → Redux-style React state via hooks.
• FileUpload component pushes CSV/XLSX to fileParser → data stored in client state.
• EditableDataTable ↔ ValidationView triggers client-side validator modules.
• When user invokes AI mapping/fixes or NL modifications, UI calls the respective Next.js API route → the route forwards requests to OpenAI (via LangChain/OpenAI API) → receives suggestions → returns JSON to UI → UI updates state.
• ExportButton component calls exportUtils to generate CSVs/ZIP, then triggers file-saver.
• No central database: persistence is ephemeral until user exports.
c. Architectural patterns and design principles
• Separation of concerns: UI (components) vs. domain logic (validators, utils) vs. API layer.
• Serverless functions: each feature’s AI/validation endpoint is isolated.
• Pure functions for data parsing and validation—stateless, side-effect-free modules.
• Hooks for cross-cutting client state (history, toasts, command templates).
d. Key technologies/frameworks
• Next.js App Router (React server components + API routes)
• React 19 + TypeScript
• Tailwind CSS for styling
• PapaParse & XLSX.js for file parsing
• OpenAI API (+ LangChain) for AI features
• Custom JS validator modules
• file-saver & JSZip for export