How l4nci/doprava-kalkulacka works
Project type and purpose
• This is a full-stack web application (“Doprava Kalkulačka 3.0”) for calculating optimal shipment costs (packages and pallets), supporting real-time pricing, multi-currency and multi-country, and providing an admin interface.
• The README specifies React + Vite for the frontend, Supabase for backend/auth and Postgres, TailwindCSS for styling.
File structure
• Top-level:
• netlify/ + netlify/functions/audit-log.js → custom serverless function(s) deployed on Netlify
• server.js + src/server/** → an Express-style local or secondary API with audit route
• supabase/…sql → DB schema and migration scripts for Supabase
• public/, index.html, vite.config.js → static assets and Vite config
• src/ contains the React app:
• src/main.jsx, src/App.jsx → entry points
• src/components/ → UI components (Login, Admin, Products, AuditLog, etc.)
• src/contexts/AuthContext.jsx → global auth state (Supabase Auth)
• src/lib/supabaseClient.js & src/supabaseClient.js → Supabase JS client wrappers
• src/services/auditService.js → audit-logging abstraction
• src/hooks/, src/utils/ → data fetching & utility functions
• config files: .env(.example/.production), netlify.toml, tailwind.config.js, postcss.config.js, eslint.config.js.
Extract architecture hints from README
• Emphasis on:
• Frontend SPA using React + Vite, hosted on Netlify
• Backend powered by Supabase (Auth + Postgres + Realtime) and custom serverless/API logic
• Tailwind for styling
Main components
A. Frontend (React SPA)
• Entry: index.html → main.jsx → App.jsx → components
• Styling: TailwindCSS via postcss
• Data access via supabaseClient and custom REST hooks (useProducts, useCurrency, etc.)
B. Hosting/CDN
• Netlify serves static build artifacts and Netlify Functions
C. API Layer
• Netlify Functions (audit-log.js) for audit logging
• Express/API in server.js or src/server routes (e.g., /audit)
D. Database & Auth
• Supabase (Postgres + Auth + Policies + Triggers)
• SQL migration scripts under supabase/
Relationships and data flow
1. User’s browser → requests static SPA from Netlify CDN
2. SPA → Supabase Auth API (login, token)
3. SPA → Supabase Database via supabaseClient for products, pricing, notifications
4. SPA → Netlify Function / Express API for audit logging and admin operations
5. Functions/API → Supabase Database (write audit logs, update products/couriers, etc.)
6. Supabase Realtime (optional) pushes price updates back to SPA
Architectural patterns & principles
• SPA + API (decoupled frontend/backend)
• Serverless functions for on-demand backend logic
• Centralized DB as source of truth (Supabase)
• Context API for auth state management
• Hooks & services for data access separation
• SQL migration/versioning for database schema
Essential details to capture
• All API endpoints (Netlify function vs. Express routes)
• Supabase DB schema origin (SQL scripts folder)
• Build & deploy pipeline (Vite → Netlify build)
• Environment variables (.env vs .env.production)