How adilmunawar/adiarc works
1. What this repo is
- AdiARC is a single Next.js dashboard for land-record operations: scanning, auditing, OCR/AI assistance, SQL generation, database status checks, inheritance calculations, and image forensics.
- It is not a generic CRUD app; the architecture centers on operational tools for legacy SQL-backed land-record workflows.
2. Primary runtime boundary
- The main application lives in Next.js App Router under src/app.
- Most routes are thin page shells that load a corresponding tool panel from src/components/dashboard-tabs, so the UI is organized as a dashboard of specialized modules rather than independent apps.
3. UI composition
- Shared shell components in src/components/layout provide the app-wide structure: authentication, route protection, sidebar navigation, persistent tabs, splash/trial gating, and employee header.
- Reusable UI primitives in src/components/ui supply the local design system, likely based on a component library such as shadcn/ui + Tailwind.
4. Main feature modules
- The dashboard tabs represent distinct subsystems: AI assistant, OCR, mauza scanning/tracking, sync, DB status, daily progress, inventory, image tools, mutation tools, range-gap analysis, SQL generation, PowerShell queries, login management, and wirasat.
- Each module is isolated at the component level, which makes the diagram best modeled as a shared shell feeding multiple tool-specific views.
5. Backend API layer
- Server-side functionality is exposed through src/app/api/* route handlers.
- The notable API boundaries are database status, mauza scanning, saving scan results, scanning all mauzas, and sync; these are the app’s integration points for long-running or server-side operations.
6. AI subsystem
- src/ai contains a Genkit-based AI pipeline, including flows/db-assistant-flow.ts and a schema file for LRIMS domain knowledge.
- This is a separate service-like layer inside the repo: the UI can invoke AI assistance, but the model logic is isolated from the presentation layer.
7. Data and computation libraries
- src/lib holds the reusable domain logic: inheritance calculations, image/forensic utilities, generic helpers, and a Supabase client wrapper.
- These utilities are the bridge between UI/API and backend services, especially for image analysis, forensic metadata extraction, and wirasat calculations.
8. Background processing
- src/workers/inventory-scanner.worker.ts indicates client-side worker-based processing for inventory scanning.
- This creates a distinct execution path for heavy file/directory scanning so the main UI thread stays responsive.
9. External systems and operational scripts
- The repo includes extensive SQL assets in nodeconfigs, Schemas, and database-test, plus PowerShell query bundles under powershellQueries.
- Architecturally, these are not just docs; they are part of the operational toolchain for SQL Server auditing, reporting, mutation lookups, sync, and cleanup workflows.
10. Persistence and asset layer
- Static/manual assets live in public, including manuals and robots metadata.
- Database interaction appears to be a core external dependency, with the app acting as a control plane over SQL scripts, reports, and live DB checks rather than owning the primary business data store itself.
11. Security and access flow
- Auth and access control are handled at the layout level through AuthProvider, RouteGuard, and trial-expiration UI.
- This implies the app has an authenticated shell around most functionality, with gated access before users reach the operational tabs.
12. How data flows through the system
- User action starts in a dashboard page, passes into a specialized tab/component, then either:
- calls a local library for computation,
- invokes an API route for server-side work,
- triggers the AI flow for OCR/db assistance, or
- uses stored SQL/PowerShell assets for database operations.
- That makes the architecture a multi-tool control surface over legacy land-record data, with clear boundaries between UI, AI, worker processing, and external database automation.
Main entry points: AiAssistantTab.tsx Tool tabs · wirasat-calculator.ts Core libs · page.tsx Dashboard pages · AuthProvider.tsx Auth shell
Components 17
Next.js App
App Router routes and page shells
- App shell · Root App Router layout and global styling entry point.
src/app/layout.tsx - Dashboard pages · Thin page routes that mount the operational dashboard tools.
src/app/page.tsx
Dashboard UI
Shared shell and feature tabs
- Auth shell · Authentication, route protection, sidebar, tabs, header, splash, and trial gating.
src/components/layout/AuthProvider.tsx - Tool tabs · Main feature panels for AI, OCR, scanning, DB status, inventory, mutations, sync, and related tools.
src/components/dashboard-tabs/AiAssistantTab.tsx - Wirasat UI · Specialized inheritance visualization component.
src/components/wirasat/FamilyTreeDiagram.tsx - UI kit · Reusable design-system primitives used across the dashboard.
src/components/ui/button.tsx
API Routes
Server-side route handlers
- DB status API · Server endpoint for database status checks.
src/app/api/db-status/route.ts - Scan API · Server endpoints for mauza scanning and persisting scan results.
src/app/api/mauza-scanner/route.ts - Sync API · Server endpoint for sync operations.
src/app/api/sync/route.ts
AI Layer
Genkit assistant pipeline and schema
Domain Libs
Reusable computation and integration helpers
- Core libs · Inheritance, image forensics, Supabase access, and shared utilities.
src/lib/wirasat-calculator.ts - Inventory worker · Background scanning path for inventory processing.
src/workers/inventory-scanner.worker.ts
Operational Assets
SQL, PowerShell, and manual assets
- SQL assets · Operational SQL bundles for reports, audits, mutations, and cleanup.
nodeconfigs/Daily Progress Query.sql - Schema assets · CSV and SQL schema references for land-record structures.
Schemas/schema.sql - PowerShell queries · PowerShell query bundle used for database operations.
powershellQueries/dailyprogressMutations_JSON - Manuals · User-facing manual and static public assets.
public/Manual
Connections 17
- App shell → Auth shell: wraps · Root layout provides the authenticated application shell.
- Auth shell → Dashboard pages: hosts · Protected shell renders the dashboard route pages.
- Dashboard pages → Tool tabs: mounts · Pages are thin shells that load the corresponding tool tabs.
- Tool tabs → UI kit: uses · Tool panels compose shared UI primitives.
- Tool tabs → DB status API: calls · DB status tools invoke the status endpoint.
- Tool tabs → Scan API: calls · Scanning tools invoke mauza scan endpoints.
- Tool tabs → Sync API: calls · Sync tools invoke the sync endpoint.
- Tool tabs → AI flow: invokes · AI assistant UI routes requests into the Genkit flow.
- AI flow → AI schema: uses · Assistant flow is grounded in LRIMS schema knowledge.
- Tool tabs → Core libs: computes · Operational tabs rely on local domain logic for calculations and forensic helpers.
- Core libs → Inventory worker: offloads · Heavy inventory scanning can be delegated to a worker.
- Tool tabs → SQL assets: references · SQL generation, auditing, and reporting tools are backed by bundled SQL scripts.
- Tool tabs → PowerShell queries: references · PowerShell query tools expose stored query bundles.
- Tool tabs → Schema assets: references · DB and mutation tools use schema reference files.
- Tool tabs → Manuals: documents · User workflows are supported by static manuals.
- Core libs → DB status API: supports · Shared helpers may back server-side DB checks.
- Core libs → Scan API: supports · Shared helpers may support scan persistence and processing.