How kenjidavila/rd works
Project type and purpose
• This is a full-stack web application: a Next.js 14 (App Router) TypeScript front-end coupled with serverless API routes and a Supabase backend.
• Purpose: complete electronic invoicing system (e-CF) for the Dominican Republic, complying with DGII regulations (XML validation, digital signatures, NCF management, real-time DGII queries), plus multi-tenant company and user management, PDF/XML generation, and audit trails.
File structure
• app/
• app/page.tsx, app/layout.tsx: root layout and entry page
• app/[route]/page.tsx: each UI section (dashboard, emitir, consultas, configuracion, etc.)
• app/api/**/route.ts: Next.js serverless API endpoints organized by feature (auth, comprobantes, clientes, DGII, pdf-storage, etc.)
• components/
• ui/: low-level reusable UI controls (buttons, dialogs, tables)
• auth/, dashboard/, invoices/, configuracion/, items/, pdf-storage/, system/: domain-specific React components
• layout/: header, sidebar, navigation
• lib/
• services/: business logic (base-service.ts, empresa-service, contingency-manager, pdf-generator, dgii-services)
• repositories/: data access layer for Postgres via Supabase (cliente-repository, item-repository)
• middleware/: auth-middleware for protecting API routes
• supabase-client/server-utils/auth: Supabase clients and utilities
• notification-service, monitoring-service, logger
• scripts/: SQL migrations, seeds, and deployment helper scripts
• public/: static assets (images, JSON data)
• config files: next.config.mjs, tailwind.config.ts, tsconfig.json, ESLint, Prettier
README for additional insights
• Next.js SSR/SSG frontend, tailwind + Radix UI + React Hook Form + Zod for validation.
• Supabase BaaS: Auth, RLS, PostgreSQL, Storage.
• External DGII webservices for RNC/NCF validation, plus official XSD schemas in libraries/.
• Workflow: front end → API routes → service layer → Supabase (DB, Auth, Storage) & DGII → back to UI with PDF/XML.
Diagramming conventions
• Labels: each component must have a clear name (e.g., “Next.js API Routes,” “Supabase PostgreSQL DB”).
• UI / Client: light blue rectangle
• API / Serverless: green hexagon
• External Services: gray cloud
• Security layers (JWT token flows, RLS enforcement).