How sakii1231/learnwith works
Project type and purpose
• This is a full-stack, server‐side-rendered (SSR) SvelteKit web application with file-based routing, component-based UI, and a MongoDB data layer.
• It serves dynamic pages (course listing, student enrollment, contact, etc.), exposes RESTful API endpoints under /api/student, and persists data in MongoDB.
File structure
• Top‐level: configuration files (svelte.config.js, vite.config.ts, Tailwind/PostCSS configs), package.json + lock files, and README.md.
• src/: application source.
• src/app.html, src/app.css, and src/app.d.ts: the HTML shell, global styles, and TypeScript definitions.
• src/hooks.server.ts: global server hooks (e.g., session management, auth).
• src/db/: contains mongo.ts (DB client setup), mongo_insert.js (seed script), and token.js (JWT or token logic).
• src/lib/: shared code:
– utils.ts and index.ts helper modules
– components/: global, UI, and atomic Svelte components (buttons, inputs, nav bar, etc.)
– svg/ assets
• src/routes/: SvelteKit’s file-based routes:
– +layout.* for shared layout,
– +page.svelte for pages,
– +server.js/ts under /api/student for data endpoints.
README
• It is the default create-svelte README, outlines standard dev/build scripts and points to SvelteKit adapters for deployment.
a. Main components
• Client (Browser) – runs SvelteKit-hydrated UI, makes navigation/API calls
• SvelteKit App Server – handles SSR, route handlers, and API endpoints
• UI Component Library – reusable Svelte components under src/lib/components
• Data Layer – MongoDB (external service) with client in src/db/mongo.ts
• Build Toolchain – Vite + Tailwind + PostCSS for dev and prod bundling
b. Relationships & interactions
• Browser → (HTTP GET/POST) → SvelteKit Server for page loads & API calls
• SvelteKit Server → (MongoDB driver) → MongoDB Atlas/Instance for data reads/writes
• Build Toolchain → produces static assets → deployed alongside server
• UI Components → used by SvelteKit Server to produce HTML/CSS/JS
c. Architectural patterns & design principles
• File-based routing (SvelteKit)
• Server‐side rendering + client hydration
• Component-driven UI with atomic design in lib/components/ui
• Separation of concerns: routes vs. components vs. database logic vs. hooks
d. Key technologies, frameworks, libraries
• SvelteKit (SSR, file routing, hooks)
• Vite (dev server, bundler)
• Tailwind CSS + PostCSS (styles)
• TypeScript (type safety)
• MongoDB Node.js driver (data layer)
• npm (package & script management)
Final advice
• Be exhaustive: represent all moving parts (hooks, routes, components, build tools).
• Layering: Presentation (UI) → Business logic (SvelteKit handlers) → Data access (Mongo).
• Keep it readable: group related files/features into aggregate nodes (e.g., “UI Component Library”, “API Endpoints”).