A modern full-stack web application built with SvelteKit, featuring authentication, database integration, and social media functionality.
- Authentication: Secure user authentication with Better Auth
- Social Login: Google and GitHub OAuth integration
- Database: SQLite/Turso database with Drizzle ORM
- Modern UI: Responsive design with Tailwind CSS and shadcn/ui components
- AI Integration: Google Generative AI for content generation
- Real-time Features: Post creation, comments, likes, and user interactions
- Image Upload: File upload functionality (development mode)
- Type Safety: Full TypeScript support
- Production Ready: Optimized for Vercel deployment
- Framework: SvelteKit
- Authentication: Better Auth
- Database: Drizzle ORM with SQLite/Turso
- Styling: Tailwind CSS + shadcn/ui
- AI: Google Generative AI
- State Management: TanStack Query
- Language: TypeScript
- Deployment: Vercel
-
Clone the repository
git clone <repository-url> cd svelte-x-demo
-
Install dependencies
pnpm install
-
Set up environment variables
cp .env.example .env
Update the
.envfile with your configuration:DATABASE_URL=file:local.db BETTER_AUTH_URL=http://localhost:5173 BETTER_AUTH_SECRET=your-secret-key GOOGLE_CLIENT_ID=your-google-client-id GOOGLE_CLIENT_SECRET=your-google-client-secret GITHUB_CLIENT_ID=your-github-client-id GITHUB_CLIENT_SECRET=your-github-client-secret GOOGLE_GENERATIVE_AI_API_KEY=your-google-ai-api-key TURSO_DATABASE_URL=your-turso-database-url TURSO_AUTH_TOKEN=your-turso-auth-token
-
Initialize the database
pnpm db:generate pnpm db:migrate pnpm db:seed
Start the development server:
pnpm devThe application will be available at http://localhost:5173
pnpm dev- Start development serverpnpm build- Build for productionpnpm preview- Preview production buildpnpm db:generate- Generate database migrationspnpm db:migrate- Run database migrationspnpm db:seed- Seed database with sample datapnpm db:migrate:prod- Run production migrationspnpm db:migrate:data- Migrate data to cloud database
The project uses SQLite for local development. The database file (local.db) is automatically created when you run migrations.
For production, we recommend using Turso or another cloud database:
- Set up cloud database (see DATABASE_SETUP.md)
- Update production environment variables in your deployment platform
- Run production migrations
pnpm db:migrate:prod
- Go to Google Cloud Console
- Create a new project or select existing one
- Enable Google+ API
- Create OAuth 2.0 credentials
- Add authorized redirect URIs:
http://localhost:5173/api/auth/callback/google(development)https://your-domain.vercel.app/api/auth/callback/google(production)
- Go to GitHub Settings > Developer settings > OAuth Apps
- Create a new OAuth App
- Set Authorization callback URL:
http://localhost:5173/api/auth/callback/github(development)https://your-domain.vercel.app/api/auth/callback/github(production)
-
Push to GitHub
git add . git commit -m "Initial commit" git push origin main
-
Connect to Vercel
- Import your GitHub repository on Vercel
- Configure environment variables in Vercel dashboard
-
Set Environment Variables Add the following variables in Vercel dashboard:
DATABASE_URL=your-cloud-database-url BETTER_AUTH_URL=https://your-app.vercel.app BETTER_AUTH_SECRET=your-production-secret GOOGLE_CLIENT_ID=your-google-client-id GOOGLE_CLIENT_SECRET=your-google-client-secret GITHUB_CLIENT_ID=your-github-client-id GITHUB_CLIENT_SECRET=your-github-client-secret GOOGLE_GENERATIVE_AI_API_KEY=your-google-ai-api-key TURSO_DATABASE_URL=your-turso-database-url TURSO_AUTH_TOKEN=your-turso-auth-token -
Deploy and run migrations After successful deployment, run production migrations if needed.
src/
βββ lib/
β βββ components/ # Reusable UI components
β βββ server/ # Server-side utilities
β β βββ db/ # Database schema and utilities
β βββ stores/ # Svelte stores
β βββ utils/ # Utility functions
β βββ auth.ts # Authentication configuration
β βββ auth-client.ts # Client-side auth utilities
βββ routes/ # SvelteKit routes
β βββ api/ # API endpoints
β βββ auth/ # Authentication routes
β βββ users/ # User-related pages
βββ app.html # HTML template
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
π This project is implemented and optimized from https://github.com/fiston-user/yappz-yt.
For support and questions:
- Check the DATABASE_SETUP.md for database configuration
- Review the SvelteKit documentation
- Open an issue for bug reports or feature requests
