email_sender Svelte Themes

Email_sender

Bulk Email Sender is a full stack web application designed for sending emails at scale with advanced features such as batch processing, scheduling, and real-time monitoring. The application uses a Hono-based backend for efficient API handling and integrates a modern SvelteKit frontend for an enhanced user experience. its supports SMTP configue.

Sevelte + Talwind + Typescript(Frontend) + Bun (Backend) Project

Everything you need to build a Svelte project, powered by sv.

Creating a project

If you're seeing this, you've probably already done this step. Congrats!

# create a new project in the current directory
npx sv create

# create a new project in my-app
npx sv create my-app

Developing

Once you've created a project and installed dependencies with npm install (or pnpm install or yarn), start a development server:

npm run dev

# or start the server and open the app in a new browser tab
npm run dev -- --open

Building

To create a production version of your app:

npm run build

You can preview the production build with npm run preview.

To deploy your app, you may need to install an adapter for your target environment.

๐Ÿš€ Bulk Email Sender - SvelteKit Frontend Migration Project

๐Ÿ“‹ Project Overview

This is a Bulk Email Sender web application currently built with Hono (backend) and vanilla HTML/CSS/JavaScript (frontend). Your assignment is to migrate the frontend to SvelteKit while maintaining the existing Hono backend functionality.

Current Tech Stack

  • Backend: Hono (Bun runtime)
  • Frontend: Vanilla HTML/CSS/JS with Bootstrap 5, Quill Editor
  • Database: SQLite (via Bun:sqlite)
  • Authentication: Argon2 password hashing with session tokens
  • Email: Nodemailer with SMTP

Target Tech Stack

  • Backend: Hono (keep as-is, migrate to Node.js/Deno with npm/pnpm/yarn)
  • Frontend: SvelteKit (modern, enhanced version)
  • Database: SQLite (maintain existing schema)
  • State Management: TanStack Query (optional)
  • Authentication: Same logic, adapted for SvelteKit

๐ŸŽฏ Assignment Objectives

1. Implement SvelteKit Frontend

  • โœ… Create a modern, clean UI using SvelteKit
  • โœ… Implement all existing features with enhanced UX
  • โœ… Add client-side validation and error handling
  • โœ… Implement responsive design (mobile-friendly)

2. Remove Old Frontend

  • โœ… Delete public/ folder (HTML, CSS, JS files)
  • โœ… Remove static file serving routes from backend (except API endpoints)
  • โœ… Ensure no dependencies on old frontend code

3. Update Documentation

  • โœ… Update README.md with new architecture
  • โœ… Document setup instructions for both backend and frontend
  • โœ… Add API documentation
  • โœ… Include screenshots/demos of new UI

๐ŸŽจ UI/UX Requirements

Design Principles

  • Clean and modern design (avoid cluttered UI)
  • Intuitive navigation (clear tabs/sections)
  • Responsive layout (mobile, tablet, desktop)
  • Accessible (ARIA labels, keyboard navigation)
  • Fast and performant (lazy loading, optimistic updates)

๐Ÿ’ก Pro Tips

  1. Use TypeScript strictly - Helps catch errors early
  2. Component first - Build reusable components
  3. API client abstraction - Centralize API calls
  4. Form validation - Use Zod or similar library
  5. Loading states everywhere - Better UX
  6. Error boundaries - Graceful error handling
  7. Optimistic updates - Instant feedback
  8. Debounce searches - Reduce API calls
  9. Lazy load routes - Faster initial load
  10. Test on mobile - Responsive design matters

๐Ÿ“ž Questions?

If you have questions during implementation:

  1. Check existing backend code for API behavior
  2. Review types.ts for data structures
  3. Test API endpoints with Postman/Thunder Client
  4. Read SvelteKit docs for routing/forms
  5. Use browser DevTools for debugging

Good luck! ๐Ÿš€ Build something amazing!

๐Ÿš€ Bulk Email Sender - SvelteKit Frontend Migration Project

๐Ÿ“‹ Project Overview

This is a Bulk Email Sender web application currently built with Hono (backend) and vanilla HTML/CSS/JavaScript (frontend). Your assignment is to migrate the frontend to SvelteKit while maintaining the existing Hono backend functionality.

Current Tech Stack

  • Backend: Hono (Bun runtime)
  • Frontend: Vanilla HTML/CSS/JS with Bootstrap 5, Quill Editor
  • Database: SQLite (via Bun:sqlite)
  • Authentication: Argon2 password hashing with session tokens
  • Email: Nodemailer with SMTP

Target Tech Stack

  • Backend: Hono (keep as-is, migrate to Node.js/Deno with npm/pnpm/yarn)
  • Frontend: SvelteKit (modern, enhanced version)
  • Database: SQLite (maintain existing schema)
  • State Management: TanStack Query (optional but recommended)
  • Authentication: Same logic, adapted for SvelteKit

๐ŸŽฏ Assignment Objectives

1. Understand the Existing System

Analyze and document:

  • โœ… Backend API endpoints and routes
  • โœ… Database schema and user management
  • โœ… Authentication flow (login, register, sessions)
  • โœ… Email sending logic (single, batch, scheduled)
  • โœ… SMTP configuration management
  • โœ… File upload handling (Excel contacts, HTML templates)
  • โœ… Reporting and analytics features

2. Migrate Backend Runtime

  • โš ๏ธ Remove Bun dependency (optional but recommended)
  • โœ… Use Node.js or Deno with npm, pnpm, or yarn
  • โœ… Keep all Hono routes and logic intact
  • โœ… Replace bun:sqlite with a Node-compatible SQLite library (e.g., better-sqlite3)
  • โœ… Update file serving and middleware for Node.js compatibility

3. Implement SvelteKit Frontend

  • โœ… Create a modern, clean UI using SvelteKit
  • โœ… Implement all existing features with enhanced UX
  • โœ… Use proper folder structure (routes, components, stores, utils)
  • โœ… Integrate TanStack Query for server state management (optional)
  • โœ… Add client-side validation and error handling
  • โœ… Implement responsive design (mobile-friendly)

4. Remove Old Frontend

  • โœ… Delete public/ folder (HTML, CSS, JS files)
  • โœ… Remove static file serving routes from backend (except API endpoints)
  • โœ… Ensure no dependencies on old frontend code

5. Update Documentation

  • โœ… Update README.md with new architecture
  • โœ… Document setup instructions for both backend and frontend
  • โœ… Add API documentation
  • โœ… Include screenshots/demos of new UI

๐Ÿ“‚ Current Project Structure

bulk-email-sender-main/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ app.ts                    # Main Hono app setup
โ”‚   โ”œโ”€โ”€ types.ts                  # TypeScript interfaces
โ”‚   โ”œโ”€โ”€ middleware/
โ”‚   โ”‚   โ””โ”€โ”€ auth.ts              # Authentication middleware
โ”‚   โ”œโ”€โ”€ routes/
โ”‚   โ”‚   โ”œโ”€โ”€ auth.ts              # Login, register, logout
โ”‚   โ”‚   โ”œโ”€โ”€ config.ts            # SMTP configuration CRUD
โ”‚   โ”‚   โ”œโ”€โ”€ dashboard.ts         # Dashboard polling status
โ”‚   โ”‚   โ”œโ”€โ”€ index.ts             # Main routes
โ”‚   โ”‚   โ”œโ”€โ”€ report.ts            # Email logs and reports
โ”‚   โ”‚   โ””โ”€โ”€ send.ts              # Email sending (single, batch, scheduled)
โ”‚   โ””โ”€โ”€ services/
โ”‚       โ”œโ”€โ”€ batchService.ts      # Batch email processing
โ”‚       โ”œโ”€โ”€ emailService.ts      # Nodemailer integration
โ”‚       โ”œโ”€โ”€ fileService.ts       # Excel/HTML file parsing
โ”‚       โ”œโ”€โ”€ logService.ts        # Email log management
โ”‚       โ”œโ”€โ”€ notificationService.ts # Email notifications
โ”‚       โ”œโ”€โ”€ providerLimits.ts    # SMTP provider detection
โ”‚       โ”œโ”€โ”€ schedulerService.ts  # Job scheduling
โ”‚       โ””โ”€โ”€ userDatabase.ts      # SQLite user management
โ”œโ”€โ”€ public/                       # โŒ TO BE REMOVED
โ”‚   โ”œโ”€โ”€ index.html               # Main dashboard
โ”‚   โ”œโ”€โ”€ login.html               # Login/register page
โ”‚   โ”œโ”€โ”€ css/style.css            # Styles
โ”‚   โ””โ”€โ”€ js/app.js                # Frontend logic (2500+ lines)
โ”œโ”€โ”€ data/                         # SQLite databases
โ”‚   โ”œโ”€โ”€ users.db                 # Users, sessions, SMTP configs
โ”‚   โ””โ”€โ”€ scheduler.db             # Scheduled jobs
โ”œโ”€โ”€ uploads/                      # Uploaded files (Excel, HTML)
โ”œโ”€โ”€ logs/                         # Email logs (JSON/CSV)
โ”œโ”€โ”€ package.json
โ””โ”€โ”€ tsconfig.json

๐Ÿ”‘ Key Features to Implement

1. Authentication System

  • Login/Register pages with validation
  • Session management (HTTP-only cookies)
  • Protected routes (redirect to login if not authenticated)
  • User profile display (name, email)
  • Logout functionality

API Endpoints:

  • POST /auth/register - Create new user
  • POST /auth/login - Authenticate user
  • POST /auth/logout - End session
  • GET /auth/me - Get current user info

2. SMTP Configuration Management

  • List all user SMTP configurations
  • Add new SMTP config (Gmail, Outlook, custom)
  • Edit existing configurations
  • Delete configurations
  • Set default configuration
  • Test connection before saving

Features:

  • Multiple SMTP accounts per user
  • Secure password storage
  • Provider-specific help text
  • Connection validation

API Endpoints:

  • GET /config/smtp - Get all user configs
  • POST /config/smtp - Create new config
  • PUT /config/smtp/:id - Update config
  • DELETE /config/smtp/:id - Delete config
  • POST /config/smtp/:id/test - Test connection
  • POST /config/smtp/:id/set-default - Set as default

3. Email Sending (Main Feature)

  • Upload Excel file with contacts (Email, FirstName, LastName, Company, etc.)
  • WYSIWYG HTML editor (Quill or TipTap for Svelte)
  • HTML template upload (alternative to editor)
  • Subject line with variable placeholders
  • Variable replacement ({{FirstName}}, {{Email}}, {{Company}}, etc.)
  • Preview email before sending
  • Send immediately or schedule for later
  • Batch processing with configurable settings
  • Real-time progress tracking

Sending Modes:

  1. Immediate Send - Send all emails now
  2. Batch Send - Send in groups with delays
  3. Scheduled Send - Schedule for specific time

Batch Settings:

  • Batch size (emails per batch)
  • Email delay (seconds between emails)
  • Batch delay (minutes between batches)

API Endpoints:

  • POST /send - Send emails (all modes)
  • POST /send/preview - Preview email
  • GET /send/status - Get current batch status
  • POST /send/pause - Pause batch job
  • POST /send/resume - Resume batch job
  • POST /send/cancel - Cancel batch job

4. Dashboard & Monitoring

  • Active batch status (live updates)
  • Progress bars (emails sent/failed)
  • Scheduled jobs list
  • Recent activity timeline
  • Statistics cards (total sent, success rate, etc.)
  • Smart polling (only poll when jobs are active)

Real-time Features:

  • Countdown timer for next batch
  • Current batch progress
  • Email sending rate
  • Error notifications

API Endpoints:

  • GET /dashboard/poll-status - Check if polling needed
  • GET /dashboard/stats - Get dashboard statistics
  • GET /dashboard/scheduled-jobs - Get scheduled jobs list

5. Reports & Analytics

  • Email logs table (searchable, filterable, sortable)
  • Statistics (total sent, failed, success rate)
  • Export logs (CSV, JSON)
  • Clear logs functionality
  • Date range filtering
  • Status filtering (Sent, Failed, Error)

API Endpoints:

  • GET /report - Get logs and stats
  • GET /report/export/csv - Export as CSV
  • GET /report/export/json - Export as JSON
  • DELETE /report/clear - Clear all logs

6. Scheduled Jobs Management

  • List scheduled jobs (upcoming, running, completed)
  • View job details (contacts count, schedule time, settings)
  • Cancel scheduled jobs
  • Email notifications when job starts/completes
  • Browser notifications (optional)

API Endpoints:

  • GET /schedule/jobs - Get all scheduled jobs
  • GET /schedule/jobs/:id - Get job details
  • DELETE /schedule/jobs/:id - Cancel scheduled job
  • GET /schedule/status - Get scheduler status

๐Ÿ—„๏ธ Database Schema

users table

CREATE TABLE users (
  id TEXT PRIMARY KEY,
  email TEXT UNIQUE NOT NULL,
  name TEXT NOT NULL,
  password_hash TEXT NOT NULL,
  created_at TEXT DEFAULT CURRENT_TIMESTAMP,
  last_login TEXT,
  is_active INTEGER DEFAULT 1
);

user_sessions table

CREATE TABLE user_sessions (
  id TEXT PRIMARY KEY,
  user_id TEXT NOT NULL,
  token TEXT UNIQUE NOT NULL,
  expires_at TEXT NOT NULL,
  created_at TEXT DEFAULT CURRENT_TIMESTAMP,
  FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE
);

smtp_configs table

CREATE TABLE smtp_configs (
  id TEXT PRIMARY KEY,
  user_id TEXT NOT NULL,
  name TEXT NOT NULL,
  host TEXT NOT NULL,
  port INTEGER NOT NULL,
  secure INTEGER DEFAULT 0,
  user TEXT NOT NULL,
  pass TEXT NOT NULL,
  from_email TEXT NOT NULL,
  from_name TEXT,
  is_default INTEGER DEFAULT 0,
  created_at TEXT DEFAULT CURRENT_TIMESTAMP,
  updated_at TEXT DEFAULT CURRENT_TIMESTAMP,
  FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE
);

scheduled_jobs table

CREATE TABLE scheduled_jobs (
  id TEXT PRIMARY KEY,
  user_id TEXT NOT NULL,
  email_job TEXT NOT NULL,  -- JSON string
  batch_config TEXT,         -- JSON string
  scheduled_time TEXT NOT NULL,
  notify_email TEXT,
  notify_browser INTEGER DEFAULT 0,
  status TEXT DEFAULT 'scheduled',
  created_at TEXT DEFAULT CURRENT_TIMESTAMP,
  started_at TEXT,
  completed_at TEXT,
  contact_count INTEGER,
  subject TEXT,
  use_batch INTEGER DEFAULT 0,
  config_name TEXT
);

๐ŸŽจ UI/UX Requirements

Design Principles

  • Clean and modern design (avoid cluttered UI)
  • Intuitive navigation (clear tabs/sections)
  • Responsive layout (mobile, tablet, desktop)
  • Accessible (ARIA labels, keyboard navigation)
  • Fast and performant (lazy loading, optimistic updates)

Color Scheme (Suggested)

  • Primary: #667eea (purple-blue gradient)
  • Success: #28a745 (green)
  • Danger: #dc3545 (red)
  • Warning: #ffc107 (yellow)
  • Info: #17a2b8 (cyan)

UI Components Needed

  1. Navigation - Sidebar or top nav with active state
  2. Cards - For statistics, forms, content sections
  3. Tables - For logs, configs, scheduled jobs
  4. Forms - Input validation, error messages, loading states
  5. Modals - For confirmations, previews, details
  6. Toasts/Alerts - Success/error notifications
  7. Progress Bars - Batch job progress
  8. Badges - Status indicators (Running, Paused, Completed)
  9. Buttons - Primary, secondary, danger actions
  10. Rich Text Editor - Quill alternative for Svelte (TipTap, ProseMirror)

๐Ÿ› ๏ธ Suggested SvelteKit Folder Structure

frontend/                          # SvelteKit app
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ routes/
โ”‚   โ”‚   โ”œโ”€โ”€ (auth)/               # Auth layout group
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ login/
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ +page.svelte
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ register/
โ”‚   โ”‚   โ”‚       โ””โ”€โ”€ +page.svelte
โ”‚   โ”‚   โ”œโ”€โ”€ (app)/                # Protected app layout
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ +layout.svelte   # App shell with nav
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ +layout.server.ts # Auth check
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ dashboard/
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ +page.svelte
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ send/
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ +page.svelte
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ reports/
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ +page.svelte
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ config/
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ +page.svelte
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ scheduled/
โ”‚   โ”‚   โ”‚       โ””โ”€โ”€ +page.svelte
โ”‚   โ”‚   โ””โ”€โ”€ +layout.svelte        # Root layout
โ”‚   โ”œโ”€โ”€ lib/
โ”‚   โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ui/               # Reusable UI components
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Button.svelte
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Card.svelte
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Input.svelte
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Modal.svelte
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Table.svelte
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ Toast.svelte
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ email/            # Email-specific components
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ EmailEditor.svelte
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ContactUploader.svelte
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ BatchSettings.svelte
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ EmailPreview.svelte
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ dashboard/
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ StatsCard.svelte
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ActivityTimeline.svelte
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ BatchMonitor.svelte
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ config/
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ SMTPConfigList.svelte
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ SMTPConfigForm.svelte
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ SMTPTestButton.svelte
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ shared/
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ Navbar.svelte
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ Sidebar.svelte
โ”‚   โ”‚   โ”‚       โ””โ”€โ”€ Footer.svelte
โ”‚   โ”‚   โ”œโ”€โ”€ stores/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ auth.ts           # Auth store (user, session)
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ toast.ts          # Toast notifications
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ theme.ts          # Dark mode (optional)
โ”‚   โ”‚   โ”œโ”€โ”€ api/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ client.ts         # API client setup
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ auth.ts           # Auth API calls
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ config.ts         # Config API calls
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ email.ts          # Email API calls
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ reports.ts        # Reports API calls
โ”‚   โ”‚   โ”œโ”€โ”€ utils/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ validation.ts     # Form validation
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ formatters.ts     # Date, number formatters
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ helpers.ts        # Misc helpers
โ”‚   โ”‚   โ””โ”€โ”€ types/
โ”‚   โ”‚       โ””โ”€โ”€ index.ts          # TypeScript types
โ”‚   โ”œโ”€โ”€ app.html
โ”‚   โ””โ”€โ”€ app.css                   # Global styles
โ”œโ”€โ”€ static/
โ”‚   โ”œโ”€โ”€ favicon.png
โ”‚   โ””โ”€โ”€ robots.txt
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ svelte.config.js
โ”œโ”€โ”€ vite.config.ts
โ””โ”€โ”€ tsconfig.json

๐Ÿ”ง Backend Migration Guide

Current Backend (Bun)

import { Hono } from "hono";
import Database from "bun:sqlite"; // โŒ Bun-specific

const db = new Database("./data/users.db");

Migrated Backend (Node.js)

import { Hono } from "hono";
import Database from "better-sqlite3"; // โœ… Node-compatible

const db = new Database("./data/users.db");

Key Changes Needed:

  1. Replace bun:sqlite with better-sqlite3 or sqlite3
  2. Update file handling (use Node.js fs instead of Bun APIs)
  3. Change package manager scripts in package.json
  4. Update multer middleware for file uploads (already using it)
  5. Configure CORS for SvelteKit dev server

New package.json (Backend)

{
  "name": "bulk-email-sender-backend",
  "version": "2.0.0",
  "type": "module",
  "scripts": {
    "dev": "tsx watch src/app.ts",
    "build": "tsc",
    "start": "node dist/app.js"
  },
  "dependencies": {
    "hono": "^3.12.0",
    "@hono/node-server": "^1.12.0",
    "better-sqlite3": "^9.4.0",
    "nodemailer": "^6.9.8",
    "xlsx": "^0.18.5",
    "multer": "^1.4.5-lts.1",
    "csv-stringify": "^6.4.4",
    "dotenv": "^16.3.1",
    "argon2": "^0.31.2"
  },
  "devDependencies": {
    "@types/better-sqlite3": "^7.6.8",
    "@types/nodemailer": "^6.4.14",
    "@types/multer": "^1.4.11",
    "tsx": "^4.7.0",
    "typescript": "^5.3.3"
  }
}

๐Ÿ“ฆ Frontend Setup Guide

1. Initialize SvelteKit

# Using npm
npm create svelte@latest frontend
cd frontend
npm install

# Add dependencies
npm install @tanstack/svelte-query axios
npm install -D tailwindcss postcss autoprefixer

2. Configure TailwindCSS (or use Bootstrap)

npx tailwindcss init -p

3. Install Rich Text Editor

# Option 1: Svelte-Quill
npm install svelte-quill

# Option 2: TipTap (recommended for Svelte)
npm install @tiptap/core @tiptap/starter-kit @tiptap/extension-placeholder

4. Configure API Client

// src/lib/api/client.ts
const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:3000';

export const apiClient = {
  async fetch(endpoint: string, options?: RequestInit) {
    const response = await fetch(`${API_BASE_URL}${endpoint}`, {
      ...options,
      credentials: 'include', // Include cookies
      headers: {
        'Content-Type': 'application/json',
        ...options?.headers,
      },
    });
    
    if (!response.ok) {
      throw new Error(`API Error: ${response.statusText}`);
    }
    
    return response.json();
  },
};

โœ… Implementation Checklist

Phase 1: Backend Migration (Week 1)

  • Set up Node.js project with Hono
  • Replace bun:sqlite with better-sqlite3
  • Update file upload handling
  • Test all API endpoints
  • Configure CORS for frontend dev server
  • Update environment variables

Phase 2: SvelteKit Setup (Week 1)

  • Initialize SvelteKit project
  • Set up folder structure
  • Configure TailwindCSS/styling
  • Create base layout components
  • Set up API client

Phase 3: Authentication (Week 2)

  • Login page UI
  • Register page UI
  • Auth store (Svelte store)
  • Protected routes middleware
  • Session handling
  • Logout functionality

Phase 4: SMTP Configuration (Week 2)

  • Config list page
  • Config form (add/edit)
  • Delete confirmation modal
  • Test connection feature
  • Set default config
  • Provider-specific help UI

Phase 5: Email Sending (Week 3)

  • Contact uploader component
  • Excel file parsing
  • Rich text editor integration
  • HTML template upload
  • Variable placeholder system
  • Email preview modal
  • Batch settings UI
  • Schedule datetime picker
  • Send form submission
  • Progress tracking UI

Phase 6: Dashboard (Week 3)

  • Stats cards
  • Active batch monitor
  • Scheduled jobs list
  • Activity timeline
  • Smart polling implementation
  • Real-time updates

Phase 7: Reports (Week 4)

  • Logs table with sorting/filtering
  • Statistics display
  • Export functionality (CSV, JSON)
  • Clear logs confirmation
  • Date range picker

Phase 8: Polish & Testing (Week 4)

  • Responsive design fixes
  • Loading states
  • Error handling
  • Form validation
  • Toast notifications
  • Accessibility improvements
  • Performance optimization
  • E2E testing (optional)

Phase 9: Documentation (Week 4)

  • Update README.md
  • API documentation
  • Setup instructions
  • Environment variables guide
  • Screenshots/GIFs
  • Deployment guide

๐Ÿงช Testing Requirements

Backend Tests

  • User registration/login
  • SMTP config CRUD
  • Email sending (immediate, batch, scheduled)
  • File upload handling
  • Report generation
  • Session validation

Frontend Tests

  • Component rendering
  • Form validation
  • API integration
  • Navigation
  • State management
  • Responsive design

๐Ÿš€ Deployment Considerations

Backend Deployment

  • Node.js hosting: Heroku, Railway, Render, DigitalOcean
  • Environment variables: Set all .env values
  • Database: SQLite files in persistent storage
  • File uploads: Ensure uploads/ directory persists

Frontend Deployment

  • Static hosting: Vercel, Netlify, Cloudflare Pages
  • SvelteKit adapter: Install appropriate adapter
  • API proxy: Configure backend API URL
  • Environment variables: VITE_API_URL

๐Ÿ“š Resources

SvelteKit

TanStack Query

Rich Text Editors

UI Libraries (Optional)


๐ŸŽ“ Evaluation Criteria

Code Quality (30%)

  • Clean, readable code
  • Proper TypeScript usage
  • Component reusability
  • Error handling
  • Comments and documentation

Functionality (40%)

  • All features working correctly
  • Backend API integration
  • State management
  • Real-time updates
  • File uploads

UI/UX (20%)

  • Modern, clean design
  • Responsive layout
  • Intuitive navigation
  • Loading states
  • Error messages

Documentation (10%)

  • README updates
  • Code comments
  • Setup instructions
  • API documentation

๐Ÿ“ Deliverables

  1. SvelteKit Frontend - Fully functional app
  2. Migrated Backend - Node.js/Deno with Hono
  3. Updated README.md - Setup and usage guide
  4. API Documentation - Endpoint reference
  5. Screenshots/Demo - Visual proof of work

๐Ÿ’ก Pro Tips

  1. Use TypeScript strictly - Helps catch errors early
  2. Component first - Build reusable components
  3. API client abstraction - Centralize API calls
  4. Form validation - Use Zod or similar library
  5. Loading states everywhere - Better UX
  6. Error boundaries - Graceful error handling
  7. Optimistic updates - Instant feedback
  8. Debounce searches - Reduce API calls
  9. Lazy load routes - Faster initial load
  10. Test on mobile - Responsive design matters

๐Ÿ†˜ Common Issues & Solutions

Issue: CORS errors

Solution: Configure Hono CORS middleware to allow SvelteKit dev server origin

Issue: Session cookies not working

Solution: Ensure credentials: 'include' in fetch calls and sameSite: 'lax' in cookies

Issue: SQLite database locked

Solution: Use better-sqlite3 with proper connection handling

Issue: File uploads failing

Solution: Check multer configuration and ensure upload directory exists

Issue: Real-time updates not working

Solution: Implement smart polling with proper intervals (see dashboard example)


๐ŸŽฏ Success Indicators

โœ… All authentication flows work (login, register, logout, session) โœ… SMTP configs can be managed (add, edit, delete, test) โœ… Emails send successfully (immediate, batch, scheduled) โœ… Progress tracking works in real-time โœ… Reports display correctly with export functionality โœ… UI is responsive on mobile, tablet, desktop โœ… No old frontend code remains (public/ folder deleted) โœ… README is updated with clear instructions โœ… Backend runs on Node.js (not Bun)


๐Ÿ“ž Questions?

If you have questions during implementation:

  1. Check existing backend code for API behavior
  2. Review types.ts for data structures
  3. Test API endpoints with Postman/Thunder Client
  4. Read SvelteKit docs for routing/forms
  5. Use browser DevTools for debugging

Good luck! ๐Ÿš€ Build something amazing!

Top categories

Loading Svelte Themes