sveltekit-nestjs-starter Svelte Themes

Sveltekit Nestjs Starter

SvelteKit-NestJS-Starter

A full-stack starter template for building modern web applications with SvelteKit frontend and NestJS backend API in a monorepo structure.

✨ Features

  • Monorepo Structure: npm workspaces for managing multiple packages
  • Frontend: SvelteKit with TypeScript
  • Backend: NestJS with TypeScript
  • Database: PostgreSQL with Prisma ORM
  • API Documentation: Swagger/OpenAPI integration
  • Docker Support: Docker and Docker Compose configuration for easy development and deployment
  • Railway Deployment: One-click deployment to Railway

šŸš€ Quick Start

Prerequisites

  • Node.js (v18 or later)
  • PostgreSQL database

Development

  1. Clone the repository:
git clone https://github.com/yourusername/sveltekit-nestjs-starter.git
cd sveltekit-nestjs-starter
  1. Install dependencies:
npm install
  1. Set up environment variables:
cp .env.example .env

Update the .env file with your database credentials and other configuration.

  1. Start the development servers:
npm run dev

This will start both the frontend and backend in development mode.

Using Docker

You can also use Docker to run the entire application stack:

docker-compose up -d

šŸ“ Project Structure

ā”œā”€ā”€ apps/
│   ā”œā”€ā”€ api/              # NestJS backend
│   │   ā”œā”€ā”€ prisma/       # Prisma schema and migrations
│   │   └── src/          # Backend source code
│   └── frontend/         # SvelteKit frontend
│       └── src/          # Frontend source code
ā”œā”€ā”€ packages/             # Shared packages
└── docker-compose.yml    # Docker configuration

šŸ› ļø Development

Backend (NestJS)

# Start backend in development mode
npm run dev:api

# Run backend tests
npm run test --workspace=apps/api

# Generate Prisma client
cd apps/api && npx prisma generate

# Run database migrations
cd apps/api && npx prisma migrate dev

Frontend (SvelteKit)

# Start frontend in development mode
npm run dev:web

# Build frontend for production
npm run build:web

🚢 Deployment

Railway

The easiest way to deploy this application is using the Railway button at the top of this README. This will automatically set up all the necessary services.

Manual Deployment

You can also deploy the application manually:

  1. Build the application:
npm run build
  1. Start the production server:
cd apps/api && npm run start:prod
cd apps/frontend && npm run preview

šŸ“š Documentation

  • API Documentation: Access Swagger UI at http://localhost:5000/api when running in development mode
  • Frontend Routes:
    • / - Home page

🧰 Common Issues and Solutions

  • TypeScript type declaration issues: Create global.d.ts with proper type declarations
  • Prisma initialization problems: Ensure .env file exists with correct DATABASE_URL
  • Value imports being used as types: Use typeof keyword
  • Running Prisma in workspace structure: Run commands from /apps/api directory

šŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

Top categories

Loading Svelte Themes