How screamonei2/oms works
Project Type and Purpose
• This is a full-stack web application built with SvelteKit (frontend + server-side routes) and Supabase (BaaS for Auth, Postgres database, Realtime, Storage).
• It manages orders, clients, products, categories, uses role-based permissions, notifications, and real-time updates.
File Structure
• Top-level:
• src/: SvelteKit app (app.html, hooks.server.ts for request hooks).
• src/lib/: reusable modules—components (UI), services (data access), stores (client state), db init, supabase client, utils, types.
• src/routes/: page endpoints (+page.svelte, +server.ts) organized by feature (auth, categories, clients, orders, products, dashboard, init).
• supabase/: local CLI config + SQL migrations for database schema.
• schema.sql & dummy_data.sql: defines tables & seed data.
• Config: svelte.config.js, vite.config.ts, tsconfig.json define build and TypeScript settings.
Key Components
a. Frontend/UI Layer (Browser)
• SvelteKit pages & components: authentication flows, dashboards, modals, forms, notifications bar, sidebar, header.
• Client-side stores for auth state, permissions, notifications.
b. SvelteKit Server/Route Layer
• +server.ts endpoints (e.g., auth callback) for SSR or form actions.
• Hooks (hooks.server.ts) for injecting session info.
c. Data Access / Services
• src/lib/services/database.ts and supabase.ts: wrapper around Supabase JS client.
• Functions that CRUD orders, clients, products, categories.
d. Supabase Backend
• Auth service for login, registration, role-based permissions.
• PostgreSQL database (tables defined in migrations & schema.sql).
• Realtime subscriptions for notifications.
• Storage (if used).
e. External Interfaces
• Developer’s browser, Supabase cloud APIs (Auth, Postgres REST/GraphQL, Realtime).
Relationships & Data Flow
• User → Browser UI (Svelte components) → SvelteKit page & stores.
• UI invokes services → supabase.js client → Supabase Auth or Database.
• Supabase returns data → services → Svelte stores → reactive UI updates.
• Realtime events (notifications) flow from Supabase → client subscription → notifications store → UI.
• SSR routes use server-side services via hooks.server.ts injecting session.
Architectural Patterns & Principles
• Modular separation: UI components, services (business logic), stores (state), routes (presentation + SSR), utils (shared helpers).
• Unidirectional data flow: services → stores → UI.
• Role-based access guard (PermissionGuard component).
• Schema migrations managed under supabase/migrations.