Everything you need to build a Svelte project, powered by sv.
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
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
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.
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.
public/ folder (HTML, CSS, JS files)README.md with new architectureIf you have questions during implementation:
Good luck! ๐ Build something amazing!
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.
Analyze and document:
bun:sqlite with a Node-compatible SQLite library (e.g., better-sqlite3)public/ folder (HTML, CSS, JS files)README.md with new architecturebulk-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
API Endpoints:
POST /auth/register - Create new userPOST /auth/login - Authenticate userPOST /auth/logout - End sessionGET /auth/me - Get current user infoFeatures:
API Endpoints:
GET /config/smtp - Get all user configsPOST /config/smtp - Create new configPUT /config/smtp/:id - Update configDELETE /config/smtp/:id - Delete configPOST /config/smtp/:id/test - Test connectionPOST /config/smtp/:id/set-default - Set as defaultSending Modes:
Batch Settings:
API Endpoints:
POST /send - Send emails (all modes)POST /send/preview - Preview emailGET /send/status - Get current batch statusPOST /send/pause - Pause batch jobPOST /send/resume - Resume batch jobPOST /send/cancel - Cancel batch jobReal-time Features:
API Endpoints:
GET /dashboard/poll-status - Check if polling neededGET /dashboard/stats - Get dashboard statisticsGET /dashboard/scheduled-jobs - Get scheduled jobs listAPI Endpoints:
GET /report - Get logs and statsGET /report/export/csv - Export as CSVGET /report/export/json - Export as JSONDELETE /report/clear - Clear all logsAPI Endpoints:
GET /schedule/jobs - Get all scheduled jobsGET /schedule/jobs/:id - Get job detailsDELETE /schedule/jobs/:id - Cancel scheduled jobGET /schedule/status - Get scheduler statusCREATE 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
);
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
);
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
);
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
);
#667eea (purple-blue gradient)#28a745 (green)#dc3545 (red)#ffc107 (yellow)#17a2b8 (cyan)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
import { Hono } from "hono";
import Database from "bun:sqlite"; // โ Bun-specific
const db = new Database("./data/users.db");
import { Hono } from "hono";
import Database from "better-sqlite3"; // โ
Node-compatible
const db = new Database("./data/users.db");
bun:sqlite with better-sqlite3 or sqlite3fs instead of Bun APIs)package.jsonmulter middleware for file uploads (already using it){
"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"
}
}
# 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
npx tailwindcss init -p
# Option 1: Svelte-Quill
npm install svelte-quill
# Option 2: TipTap (recommended for Svelte)
npm install @tiptap/core @tiptap/starter-kit @tiptap/extension-placeholder
// 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();
},
};
bun:sqlite with better-sqlite3.env valuesuploads/ directory persistsVITE_API_URLSolution: Configure Hono CORS middleware to allow SvelteKit dev server origin
Solution: Ensure credentials: 'include' in fetch calls and sameSite: 'lax' in cookies
Solution: Use better-sqlite3 with proper connection handling
Solution: Check multer configuration and ensure upload directory exists
Solution: Implement smart polling with proper intervals (see dashboard example)
โ 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)
If you have questions during implementation:
Good luck! ๐ Build something amazing!