How szuhaydv/mrchili-v2 works
Project Type and Purpose
• This is a full-stack SvelteKit web application.
• The frontend is built with Svelte components (under src/routes and src/lib).
• The backend is lightweight, using SvelteKit’s filesystem-based server routes for API endpoints (e.g. send-email).
• Purpose: a content-driven site (product catalog, cart, order pages) with email notifications.
High-Level Architecture Components
a. Frontend Layer
• Svelte components under src/routes (+layout, +page files, UI components like HeaderComponent, CardComponent, etc.)
• Styling: Tailwind CSS (tailwind.config.ts) + global input.css
• Static assets under static/ (PDFs, images, etc.)
b. Backend/API Layer
• Server endpoints in src/routes/api/send-email/+server.js – processes form submissions
• Utility module src/lib/utils/send-email.server.js – encapsulates email-sending logic
• Data services in src/routes/dataService.ts and src/routes/cartService.ts – business logic for products, cart
• Email templates in src/routes/order/emailTemplates.js
c. Build & Deployment
• Vite as build tool (vite.config.ts)
• SvelteKit config (svelte.config.js) – defines adapter, SSR options
d. External Services
• Email provider (e.g. SendGrid/Mailgun) invoked by send-email.server.js
• Potential payment gateway (not shown but cart/order services could integrate)
Relationships & Data Flows
• User’s browser sends HTTP requests for pages; SvelteKit renders SSR or serves static JS/CSS.
• Interaction with site (contact form, placing order) triggers fetch() calls to /api/send-email or other endpoints.
• API layer calls into dataService/cartService for business logic, then into utils/send-email.server.js for outbound emails.
• Email provider responds; API returns status to the frontend.
• Cart state may live client-side (using sessionStorage) or server-session via cookies/hooks.server.js.
Architectural Patterns & Principles
• Filesystem-based routing: src/routes directory maps URL paths to endpoints and pages.
• Separation of concerns:
• UI components in routes and lib/components
• Business logic in service modules (dataService, cartService)
• Infrastructure logic (email transport) in server utilities
• SSR + SPA: SvelteKit handles SSR for faster loads, then hydrates to SPA.
• Convention over configuration: minimal routing config; uses SvelteKit defaults.
Elements
• Clear labels: e.g. “Contact Page (+page.svelte)”, “Email API (/api/send-email)”