A SvelteKit + PostgreSQL deployment sample. This modern guestbook application demonstrates how to build and deploy full-stack web applications with a PostgreSQL database.
This repository serves as a deployment sample, showcasing:
- How to structure a SvelteKit application for deployment
- Integration with PostgreSQL for database operations
- Best practices for environment configuration
- Production-ready code patterns and architecture
- 📝 Digital Guestbook - Interactive message board for visitors
- 🚀 SvelteKit - Full-stack framework with SSR/SSG
- 🔧 TypeScript - Type safety throughout
- 🎨 Tailwind CSS - Beautiful, responsive design
- 🗄️ PostgreSQL - Robust relational database
- 🏗️ Component Architecture - Reusable UI components
- 📱 Mobile-First - Works perfectly on all devices
-
Clone and install dependencies:
git clone <your-repo> cd sveltekit-sample bun install
-
Set up PostgreSQL:
- Install PostgreSQL locally or use a cloud provider
- Create a new database for the application
- Copy
.env.exampleto.envand fill in your database URL - Run the schema setup:
psql -d your_database_name -f schema.sql
-
Run the development server:
bun run dev
src/
├── lib/
│ ├── components/ # Reusable UI components
│ │ ├── Header.svelte # Page header component
│ │ ├── Navigation.svelte # Site navigation
│ │ ├── MessageCard.svelte # Individual message display
│ │ ├── MessageForm.svelte # Guestbook entry form
│ │ └── FeatureCard.svelte # Feature showcase card
│ ├── database.ts # PostgreSQL client setup
│ └── index.ts # Component exports
├── routes/
│ ├── +layout.svelte # Root layout with navigation
│ ├── +page.svelte # Guestbook home page
│ ├── +page.server.ts # Server-side data loading & form actions
│ ├── about/
│ │ └── +page.svelte # About page
│ └── api/
│ └── messages/
│ └── +server.ts # REST API endpoints for messages
└── app.html # HTML template
Create a .env file with the following required variables:
# PostgreSQL Configuration (Required)
DATABASE_URL=postgresql://username:password@localhost:5432/database_name
# Optional Environment Variables
NODE_ENV=development
PORT=3000Required Variables:
DATABASE_URL- Your PostgreSQL connection string
Optional Variables:
NODE_ENV- Environment mode (development, production)PORT- Port number for the application (defaults to 3000)
The guestbook uses a messages table with optional fields for rich entries:
CREATE TABLE guestbook_messages (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
email TEXT,
message TEXT NOT NULL,
location TEXT,
website TEXT,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);This app is configured for deployment with the Node.js adapter. For other platforms:
- Vercel/Netlify: Change adapter in
svelte.config.js - Docker: Use the Node.js adapter (already configured)
- Static: Switch to
@sveltejs/adapter-staticfor static sites
bun run dev- Start development serverbun run build- Build for productionbun run preview- Preview production buildbun run check- Run TypeScript checksbun run lint- Lint codebun run format- Format code