A modern chat application built with TypeScript, tRPC, SQLite, and SvelteKit. This project demonstrates real-time messaging, user authentication, and AI integration.
- Real-time Chat: Server-sent events (SSE) for instant messaging
- User Authentication: GitHub OAuth integration
- AI Integration: Support for various LLM providers
- Modern Stack: TypeScript, tRPC, SQLite, SvelteKit
- Type Safety: End-to-end type safety with shared types
- Responsive UI: Modern, clean interface
- Bun (v1.2.15 or later)
- Node.js (for compatibility)
- Git
git clone it
cd t3ChatClone
bun installCopy the example environment file and configure it:
cp .env.example .envEdit .env with your actual values:
ENVIRONMENT="DEV"
PUBLIC_BACKEND_HOST="localhost"
PUBLIC_BACKEND_PORT=3000
PUBLIC_BACKEND_HTTP_PROTOCOL="http"
PUBLIC_FRONTEND_HOST="localhost"
PUBLIC_FRONTEND_PORT=5173
PUBLIC_FRONTEND_HTTP_PROTOCOL="http"
SQLITE_PATH=".db"
GITHUB_CLIENT_ID="your_github_client_id_here"
GITHUB_CLIENT_SECRET="your_github_client_secret_here"
API_KEY_ENCRYPTION_SECRET="your_secret_key_here"Open a terminal and navigate to the backend:
cd apps/backend
bun devOpen a second terminal and run the database migrations:
cd apps/backend
bun run db:migrateOpen a third terminal and start the frontend:
cd apps/frontend
bun run devVisit http://localhost:5173 in your browser.
t3ChatClone/
βββ apps/
β βββ backend/ # tRPC API server
β β βββ src/
β β β βββ auth/ # Authentication logic
β β β βββ chat/ # Chat functionality
β β β βββ llm/ # LLM integration
β β β βββ sse/ # Server-sent events
β β β βββ ...
β β βββ drizzle/ # Database migrations
β βββ common/ # Shared types and utilities
β βββ frontend/ # SvelteKit frontend
β βββ src/
β β βββ lib/ # Shared components and utilities
β β βββ routes/ # Page routes
β βββ ...
βββ data/ # Local data storage
bun dev- Start development serverbun run db:migrate- Run database migrationsbun run db:studio- Open Drizzle Studio (if available)
bun run dev- Start development serverbun run build- Build for productionbun run preview- Preview production buildbun run test- Run tests
bun install- Install all dependenciesbun run build- Build all packages
This project uses GitHub OAuth for authentication. To set it up:
- Go to GitHub Developer Settings
- Create a new OAuth App
- Set the authorization callback URL to:
http://localhost:3000/auth/oauth/github/callback - Copy the Client ID and Client Secret to your
.envfile
The project uses SQLite with Drizzle ORM for database management. The database file is stored locally based on the SQLITE_PATH environment variable.
When you make changes to the database schema:
cd apps/backend
bun run db:generate # Generate migration files
bun run db:migrate # Apply migrationsThe application supports various LLM providers. Configure your API keys in the settings page after authentication.
If you get a "port already in use" error:
- Backend (port 3000):
lsof -ti:3000 | xargs kill -9 - Frontend (port 5173):
lsof -ti:5173 | xargs kill -9
- Delete the
.dbfile and run migrations again - Check that
SQLITE_PATHis correctly set in.env
- Ensure all required environment variables are set
- Check that
.envfile is in the project root - Restart the development servers after changing environment variables
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Commit your changes:
git commit -am 'Add some feature' - Push to the branch:
git push origin feature/your-feature - Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with Bun - A fast all-in-one JavaScript runtime
- tRPC - End-to-end typesafe APIs
- SvelteKit - The fastest way to build svelte apps
- Drizzle ORM - TypeScript ORM