A modern e-commerce platform for trading card shops built with SvelteKit 2, Svelte 5, and PostgreSQL.
User Shopping Experience
Admin Dashboard
Authentication
git clone <your-repo-url>
cd cardshop
bun install
Copy .env.example to .env and configure:
cp .env.example .env
Required environment variables:
# Database
DATABASE_URL="postgres://user:password@host:port/db-name"
# Authentication
BETTER_AUTH_SECRET="<generate-a-random-secret>"
BETTER_AUTH_URL="http://localhost:5173"
# Google OAuth
GOOGLE_CLIENT_ID="<your-google-client-id>"
GOOGLE_CLIENT_SECRET="<your-google-client-secret>"
# Site URL
PULIC_SITE_URL="http://localhost:5173"
Generating a secure secret:
openssl rand -base64 32
Setting up Google OAuth:
http://localhost:5173/api/auth/callback/google# Push schema to database
bun run db:push
# Or generate migrations
bun run db:generate
bun run db:migrate
After signing in with Google for the first time, manually set your role to admin:
UPDATE "user" SET role = 'admin' WHERE email = '[email protected]';
Admin users can access /admin/* routes to manage inventory, categories, items, and orders.
If you want sample data, you can run the seed script:
bun run src/lib/server/db/seed.ts
This creates:
bun run dev
Visit http://localhost:5173 to see your app.
| Command | Description |
|---|---|
bun run dev |
Start development server |
bun run build |
Build for production |
bun run preview |
Preview production build |
bun run check |
Run TypeScript and Svelte checks |
bun run lint |
Lint code with ESLint and Prettier |
bun run format |
Auto-format code with Prettier |
bun run db:push |
Push schema changes to database |
bun run db:generate |
Generate migration files |
bun run db:migrate |
Run migrations |
bun run db:studio |
Open Drizzle Studio (database GUI) |
src/
├── lib/
│ ├── components/ # UI components
│ ├── queries/ # TanStack Query hooks
│ ├── server/db/ # Database schemas & migrations
│ ├── auth.ts # Auth configuration
│ └── utils.ts # Utility functions
├── routes/
│ ├── admin/ # Admin dashboard
│ ├── api/ # API endpoints
│ ├── auth/ # Authentication
│ ├── cart/ # Shopping cart
│ ├── checkout/ # Checkout flow
│ └── orders/ # Order history
└── hooks.server.ts # Server hooks
Key tables:
user - User accounts with role-based accesssession - Authentication sessionscategory - Product categoriesitem - Trading card itemscart - User shopping cartscartItem - Cart line itemsorder - Customer ordersorderItem - Order line itemslowStockAlert - Admin alertsSee AGENTS.md for code style guidelines and development best practices.
bun run build
Update BETTER_AUTH_URL and PULIC_SITE_URL to your production domain.
Run migrations in production:
bun run db:migrate
The app uses @sveltejs/adapter-node and can be deployed to any Node.js hosting platform:
BETTER_AUTH_SECRET is setBETTER_AUTH_URL matches your domainDATABASE_URL is correctGOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRETSELECT role FROM "user" WHERE email = '[email protected]'UPDATE "user" SET role = 'admin' WHERE email = '[email protected]'bun run lint before committing[Your License Here]
For issues and questions, please open an issue on GitHub.