This small project was built to explore SvelteKit’s SSR/CSR model, component design, and client-server communication patterns — while applying software architecture and code-quality practices.
✅ Add, edit, delete, complete, search, and list todos.
✅ Reusable modal component for both adding and editing tasks.
✅ SSR for initial data loading.
✅ Clean separation between server and client logic.
1️⃣ Clone the repository
git clone https://github.com/myasul/svelte-todo.git
cd svelte-todo
2️⃣ Install dependencies
npm install
3️⃣ Run the development server
npm run dev
Then open your browser and visit:
4️⃣ (Optional) Build for production npm run build npm run preview
TodoService
— Server-Side LogicLocated in src/lib/server/TodoService.ts
/api/todos
endpoints for SSR and data persistenceTodoApi
— Client-Side Fetch LayerLocated in src/lib/client/TodoApi.ts
fetch()
calls for CRUD operations+page.svelte
— Frontend UILocated in src/routes/+page.svelte
SSR fetches all todos on first paint
Local reactive states:
allTodos
: source of truthvisibleTodos
: current filtered viewpageState
: app mode (Idle
, Adding
, Editing
)selectedTodo
: currently edited todoTodoModal
reused for both add and edit workflows
filterTodos
utility handles client-side search logic
Layer | Responsibility |
---|---|
TodoService | Server: business logic and file persistence |
TodoApi | Client: API interaction and error handling |
+page.svelte | UI logic, state management, and rendering |
This pattern mirrors a clean architecture approach — easy to scale or replace data sources later.
load
function) + CSR updates