How jdavidcruzc/infocom-ilo works
Purpose and Runtime
INFOCOM SOLUCIONES is a full-stack commercial-management platform for a computer retailer and repair shop: public e-commerce, POS/backoffice, technical-service workflow, accounting, inventory, staff, and reporting. It is a React 18/TypeScript SPA built by Vite and deployed to Vercel; Supabase supplies PostgreSQL, Auth, Storage, Realtime, and Edge Functions.
Entry points: src/main.tsx mounts the application; src/App.tsx composes routing and top-level feature access. SPA deep-link handling is deployed through vercel.json.
Feature Segmentation and Navigation
The UI is organized by business feature rather than a generic pages layer:
• Public shop: home, catalog, product details, company/contact/account pages in src/features/shop/pages/HomePage.tsx, src/features/shop/pages/CatalogPage.tsx, src/features/shop/pages/ProductDetailPage.tsx.
• Purchase journey: shared cart state and drawer, then checkout at src/hooks/use-cart.ts, src/features/cart/components/CartDrawer.tsx, src/features/checkout/pages/CheckoutPage.tsx.
• Protected backoffice is mounted in src/features/admin/layout/AdminLayout.tsx and consists of independently scoped operational pages.
Identity, Authorization, and Security Boundary
Supabase Auth establishes browser sessions; frontend hooks expose identity and roles through src/features/auth/hooks/useAuth.tsx and src/features/auth/hooks/usePermissions.tsx. Route guards enforce authenticated and permission-scoped admin access in src/features/auth/components/ProtectedRoute.tsx and src/features/auth/components/PermissionRoute.tsx.
The browser is not the final authorization boundary: Supabase PostgreSQL Row Level Security, represented by the ordered SQL history under supabase/migrations/, must govern sensitive reads and writes. Input normalization/sanitization is centralized in src/lib/sanitize.ts.
Commerce, Inventory, and Finance Operations
Admin operations center on product/catalog maintenance, sales, purchasing, inventory movement, and accounting:
• Catalog and stock definition: src/features/admin/pages/ProductsPage.tsx, src/features/admin/pages/CategoriesPage.tsx, src/features/admin/pages/KardexPage.tsx.
• POS and transactions: src/features/admin/pages/SalesPage.tsx, with print output through src/features/admin/components/PrintReceipt.tsx.
• Unified financial records, receivables, and export-oriented accounting: src/features/admin/pages/AccountingPage.tsx, src/features/admin/components/SendToAccountingDialog.tsx.
The intended transaction flow is sale/checkout → persisted transaction and item records → stock/Kardex update → receipt/accounting representation. Database triggers and constraints defined in migrations are an important consistency boundary; frontend state must not become the source of truth.
Technical Service and Staff Operations
Technical service is a separate operational domain rather than a shop extension. Reception and lifecycle management are driven from src/features/admin/pages/ReceptionPage.tsx; encapsulated domain operations reside in src/features/admin/services/technicalService.ts; supporting transaction history is surfaced by src/features/admin/components/TransactionHistoryDialog.tsx. This supports intake, diagnosis/quotation, parts, repair status, delivery, and associated payments.
Internal workforce workflows include staff records, role setup, attendance, and appointments in src/features/admin/pages/StaffPage.tsx, src/features/admin/pages/AttendancePage.tsx, and src/features/admin/pages/AppointmentsPage.tsx.
Supabase Integration and External Services
The typed browser client is the main data-access gateway at src/integrations/supabase/client.ts, with generated/domain database types in src/integrations/supabase/types.ts. It communicates with Supabase via authenticated HTTPS/PostgREST, Storage for uploaded assets, and Realtime for shared operational updates.
Privileged or third-party work is isolated to Supabase Edge Functions: supabase/functions/create-staff-account/index.ts creates staff accounts, while supabase/functions/dni-lookup/index.ts performs DNI lookup against an external service. WhatsApp is used as an outbound/deep-link communication channel from shop and service flows, including src/features/shop/components/WhatsAppButton.tsx.
Presentation System and Deployment
Reusable primitives are housed in src/components/ui/; feature pages compose these instead of owning base controls. Global visual state is provided by src/features/theme/ThemeProvider.tsx and src/features/theme/FloatingThemeToggle.tsx. Shared cart and business utilities live outside feature UI at src/lib/cart.ts and src/lib/types.ts.
Infrastructure is serverless: Vercel hosts the static SPA/CDN deployment, while Supabase owns backend persistence and execution. Schema evolution is migration-driven under supabase/migrations/; changes affecting transactions, roles, inventory, or service workflows should be planned as coordinated frontend, RLS/schema, and data-migration work.
Main entry points: client.ts Typed Supabase client · AdminLayout.tsx Admin shell · App.tsx App routing · HomePage.tsx Public shop
Components 21
React SPA
Vite-built browser application.
- Application mount
src/main.tsx - App routing · Composes public, checkout, and protected feature access.
src/App.tsx - Public shop · Home, catalog, product detail, and account-facing pages.
src/features/shop/pages/HomePage.tsx - Cart & checkout · Shared cart state feeds checkout and persisted sales.
src/hooks/use-cart.ts - Auth & route guards · Exposes sessions and roles, then guards admin routes.
src/features/auth/hooks/useAuth.tsx - UI & theme system · Shared controls and global visual state.
Business Operations
Protected operational feature domains.
- Admin shell · Mount point for backoffice domains.
src/features/admin/layout/AdminLayout.tsx - Catalog & inventory · Products, categories, and Kardex stock movement.
src/features/admin/pages/ProductsPage.tsx - POS & sales · Records sales and produces printable receipts.
src/features/admin/pages/SalesPage.tsx - Accounting · Financial records, receivables, and accounting export.
src/features/admin/pages/AccountingPage.tsx - Technical service · Reception, repair lifecycle, parts, delivery, and payments.
src/features/admin/services/technicalService.ts - Staff operations · Staff, roles, attendance, and appointments.
src/features/admin/pages/StaffPage.tsx
Supabase Backend
Persistence, authorization, realtime, and server-side execution.
- Typed Supabase client · Authenticated access to database, storage, and realtime.
src/integrations/supabase/client.ts - Supabase Auth
- PostgreSQL data · Canonical records for commerce, inventory, finance, service, and staff.
- Schema, RLS & triggers · Migration-defined authorization, constraints, and transaction consistency.
- Realtime & Storage · Shared operational updates and uploaded assets.
- Edge Functions · Creates staff accounts and performs DNI lookup.
supabase/functions/create-staff-account/index.ts
Deployment & External
- Vercel SPA hosting · Hosts the SPA with deep-link handling.
vercel.json - DNI lookup service
- WhatsApp · Outbound shop and service communication deep links.
src/features/shop/components/WhatsAppButton.tsx
Connections 29
- Application mount → App routing: mounts
- App routing → Public shop: public routes
- App routing → Cart & checkout: checkout route
- App routing → Auth & route guards: protects admin access
- Auth & route guards → Admin shell: authorized access
- Admin shell → Catalog & inventory: hosts
- Admin shell → POS & sales: hosts
- Admin shell → Accounting: hosts
- Admin shell → Technical service: hosts
- Admin shell → Staff operations: hosts
- Public shop → Cart & checkout: adds products
- Cart & checkout → Typed Supabase client: persists checkout
- Catalog & inventory → Typed Supabase client: manages stock
- POS & sales → Typed Supabase client: persists transactions
- Accounting → Typed Supabase client: reads financial records
- Technical service → Typed Supabase client: persists service lifecycle
- Staff operations → Edge Functions: provisions accounts
- Auth & route guards → Supabase Auth: reads session and roles
- Typed Supabase client → PostgreSQL data: authenticated data access
- Typed Supabase client → Realtime & Storage: subscribes and uploads
- Schema, RLS & triggers → PostgreSQL data: defines schema and enforcement
- PostgreSQL data → Catalog & inventory: transaction updates stock/Kardex
- PostgreSQL data → Accounting: transaction feeds accounting
- Edge Functions → Supabase Auth: creates staff identities
- Edge Functions → DNI lookup service: performs lookup
- Vercel SPA hosting → Application mount: serves SPA
- Public shop → WhatsApp: opens contact channel
- Technical service → WhatsApp: sends service communication
- App routing → UI & theme system: composes shared presentation