How surakal/nationalidconvertor-2 works
1. Overall shape
- This is a client-side React application built with Vite + TypeScript, with Supabase providing the backend services.
- The repo is organized as a typical single-page app: route-level pages in src/pages, shared feature components in src/components, app-wide state in src/contexts, and backend/schema code under supabase/.
2. Route and page layer
- The main user-facing entry points are Index, Login, Register, ForgotPassword, Dashboard, Admin, and NotFound.
- That implies two major navigation zones:
- a public/auth zone for onboarding and password recovery
- an authenticated application zone for dashboard and admin workflows
3. Authentication boundary
- src/contexts/AuthContext.tsx is the main app-level auth boundary.
- It likely owns session state, user identity, and protected-route behavior, and it is the point where the frontend connects to Supabase auth.
- Password reset and account creation are not purely client-side: they are backed by Supabase edge functions.
4. Business feature modules
- The feature components suggest the app is centered on identity/document processing and account operations:
- IDUploader, PrintableID, ResultsPanel
- WalletTopUp, PaymentMethods, PaymentRequests
- PackageManagement
- These are separate feature areas rather than generic UI, so they likely map to distinct dashboard tabs/cards and backend entities.
5. OCR/document-processing flow
- src/lib/ocr.ts and src/lib/ocr-v1.ts indicate a dedicated OCR layer with at least one versioned implementation.
- IDUploader is the entry point for document input; OCR runs in the client-side library layer; the extracted results are then displayed through ResultsPanel and likely used to populate a printable identity view.
- This is a key architecture boundary: user uploads → OCR processing → structured results → downstream profile/ID rendering.
6. Payments and wallet subsystem
- WalletTopUp, PaymentMethods, and PaymentRequests form a focused payment/workflow area.
- The naming suggests the UI supports funding a wallet, selecting payment rails, and handling incoming/outgoing payment requests.
- In diagram terms, this is a distinct business subsystem that likely persists transactional state in Supabase tables.
7. Admin subsystem
- src/pages/Admin.tsx plus src/components/admin/AdminSidebar.tsx and AdminUsers.tsx define a separate administrative surface.
- This area is isolated from normal dashboard usage and likely depends on role-based access control from Supabase/auth claims and database policies.
- The admin side appears focused on user management rather than general content editing.
8. Supabase backend layer
- src/integrations/supabase/client.ts and types.ts are the frontend’s typed access layer to Supabase.
- The supabase/migration/*.sql files show that schema and policy changes are versioned in the repo, so the database is part of the source of truth.
- This likely includes auth-related tables, application records, and access control rules.
9. Serverless backend functions
- supabase/functions/create-user and supabase/functions/reset-password-otp are backend execution boundaries outside the browser.
- These functions handle privileged workflows that should not be done directly from the client:
- user provisioning
- password reset / OTP handling
- In the architecture diagram, they sit alongside Supabase auth and database services, not inside the React app.
10. UI system and design layer
- The app uses a large src/components/ui library, which is characteristic of shadcn/ui style composition.
- This means the product UI is assembled from reusable primitives like dialogs, tables, tabs, forms, sidebars, etc., rather than a custom design system built from scratch.
- tailwind.config.ts, src/index.css, and src/App.css provide the styling layer.
11. State, responsiveness, and cross-cutting utilities
- use-toast, sonner, and the toast components indicate a global notification mechanism for async feedback.
- use-mobile.tsx suggests responsive behavior is handled in app code, not only via CSS.
- src/lib/utils.ts is the shared helper layer for component composition and formatting.
12. Build, testing, and delivery
- The project is built and served by Vite, tested with Vitest, and linted with ESLint.
- public/robots.txt and public/images are static assets served directly by the frontend bundle.
- The README describes Lovable-based editing and deployment, but the actual runtime architecture remains a static SPA plus Supabase backend.
13. How data flows through the system
- Typical flow is: user/browser → React page/component → auth context / feature UI → Supabase client or edge function → Supabase database/auth → UI updates and notifications.
- OCR and document generation stay primarily on the client side, while authentication, account creation, reset flows, user management, and persistent business data go through Supabase.
14. Key diagram boundaries to draw
- Draw separate boxes for:
- Frontend SPA
- Auth/session management
- OCR/document processing
- Payments/wallet business logic
- Admin console
- Supabase auth + database
- Supabase edge functions
- The most important boundary is between the browser-based React app and the Supabase backend services, with OCR as a client-side processing subflow.
Main entry points: App.tsx App Shell · Dashboard.tsx Dashboard · client.ts Supabase Client · Register.tsx Register
Components 27
Frontend SPA
React client, route pages, shared UI, and browser-side processing.
- Entry · Browser entry that mounts the React app.
src/main.tsx - App Shell · Top-level routing and application composition.
src/App.tsx - Auth State · Session and identity boundary for protected flows.
src/contexts/AuthContext.tsx - Home · Landing or entry page for the public zone.
src/pages/Index.tsx - Login · Sign-in entry point.
src/pages/Login.tsx - Register · Account creation entry point.
src/pages/Register.tsx - Recover · Password reset and recovery entry point.
src/pages/ForgotPassword.tsx - Dashboard · Authenticated workspace for core product workflows.
src/pages/Dashboard.tsx - Admin · Restricted administrative surface.
src/pages/Admin.tsx - Not Found · Fallback route for unknown paths.
src/pages/NotFound.tsx - ID Upload · Captures identity document images for processing.
src/components/IDUploader.tsx - OCR Engine · Client-side OCR and extraction logic.
src/lib/ocr.ts - Results · Displays OCR output and structured data.
src/components/ResultsPanel.tsx - Printable ID · Formats extracted identity data for printable output.
src/components/PrintableID.tsx - Wallet Top-Up · Funds wallet balance and payment activity.
src/components/WalletTopUp.tsx - Payment Methods · Selects or manages payment rails.
src/components/PaymentMethods.tsx - Payment Requests · Tracks incoming and outgoing payment requests.
src/components/PaymentRequests.tsx - Packages · Manages package or service bundles.
src/components/PackageManagement.tsx - Admin Sidebar · Navigation and layout for the admin console.
src/components/admin/AdminSidebar.tsx - User Admin · Administrative user management surface.
src/components/admin/AdminUsers.tsx - UI Primitives · Reusable component library for the app UI.
Supabase Backend
Auth, database schema, and privileged serverless workflows.
- Supabase Client · Typed frontend client for Supabase services.
src/integrations/supabase/client.ts - Supabase Core · Hosted auth and database services behind the frontend.
- Schema & Policies · Versioned database schema and access policy definitions.
supabase/migration - Edge Functions · Privileged backend workflows executed outside the browser.
supabase/functions - Create User · Provisions users through a privileged backend path.
supabase/functions/create-user/index.ts - Reset OTP · Handles password reset and OTP workflows.
supabase/functions/reset-password-otp/index.ts
Connections 30
- Entry → App Shell: bootstraps · Mounts the application shell.
- App Shell → Auth State: wraps · Provides session and protection context.
- App Shell → Home: routes · Public landing route.
- App Shell → Login: routes · Authentication route.
- App Shell → Register: routes · Account creation route.
- App Shell → Recover: routes · Password recovery route.
- App Shell → Dashboard: routes · Authenticated application route.
- App Shell → Admin: routes · Restricted admin route.
- App Shell → Not Found: fallback · Unknown route handler.
- Dashboard → ID Upload: uses · Starts document capture flow.
- ID Upload → OCR Engine: processes · Runs OCR on uploaded identity documents.
- OCR Engine → Results: feeds · Produces structured extraction output.
- OCR Engine → Printable ID: feeds · Supplies data for printable ID rendering.
- Dashboard → Wallet Top-Up: uses · Exposes wallet top-up workflow.
- Dashboard → Payment Methods: uses · Exposes payment method management.
- Dashboard → Payment Requests: uses · Exposes payment request workflow.
- Dashboard → Packages: uses · Exposes package management workflow.
- Admin → Admin Sidebar: contains · Admin navigation and layout.
- Admin → User Admin: contains · User management surface.
- Login → Supabase Client: auth · Signs users in through Supabase.
- Register → Supabase Client: auth · Creates accounts through Supabase.
- Recover → Reset OTP: calls · Invokes privileged recovery flow.
- Register → Create User: calls · Invokes privileged provisioning flow.
- Auth State → Supabase Client: reads session · Keeps app state aligned with Supabase auth.
- Supabase Client → Supabase Core: connects · Frontend access to hosted Supabase services.
- Supabase Core → Schema & Policies: governed by · Database behavior defined by migrations and policies.
- Edge Functions → Supabase Core: runs beside · Serverless execution boundary adjacent to core services.
- Create User → Supabase Core: provisions · Creates or updates backend user records.
- Reset OTP → Supabase Core: recovery · Coordinates password reset and OTP state.
- UI Primitives → App Shell: supports · Shared component primitives used across the SPA.