A modern, type-safe full-stack template featuring ASP.NET Core 9.0 as Backend for Frontend (BFF) with SvelteKit 2.22 (Svelte 5) frontend, implementing Clean Architecture and DDD-inspired patterns.
This template demonstrates best practices for building full-stack applications using:
Perfect for developers looking to build scalable, maintainable full-stack applications.
This application follows a DDD-inspired Clean Architecture with clear separation of concerns:
๐ Project Structure
โโโ MySvelteApp.Client/ # SvelteKit Frontend (Svelte 5)
โโโ MySvelteApp.Server/ # .NET 9.0 Backend (Clean Architecture)
โโโ CLAUDE.md # AI Assistant Documentation
โโโ structure.md # Code Organization Guide
โโโ README.md # This file
$state
, $derived
)Clone the repository
git clone https://github.com/refactor-gremlin/svelte-NET-Test.git
cd svelte-NET-Test
Install dependencies
# Install backend dependencies
dotnet restore
# Install frontend dependencies
npm ci --prefix MySvelteApp.Client
Start development servers
# Start both frontend and backend concurrently
npm run dev
# Or start individually:
# Backend (port 7216)
dotnet run --project MySvelteApp.Server
# Frontend (port 5173)
npm run dev --prefix MySvelteApp.Client
Open your browser
For full-stack development with all services:
# Start all services
npm run docker:dev
# Or use docker-compose directly
docker-compose -f docker-compose.dev.yml up
npm run dev # Start both client and server concurrently
npm run build # Build for production
npm run docker:dev # Start development containers
npm run docker:prod # Start production containers
npm run dev # Start dev server (port 5173)
npm run build # Production build
npm run check # TypeScript type checking
npm run lint # ESLint code quality
npm run format # Prettier code formatting
npm run test:unit # Vitest unit tests
npm run test:e2e # Playwright E2E tests
npm run generate-api-classes # Regenerate API client
dotnet run # Start development server (port 7216)
dotnet build # Build the solution
dotnet test # Run unit tests
dotnet restore # Restore NuGet packages
This template implements the Backend for Frontend (BFF) pattern with ASP.NET Core serving as a dedicated API layer for the Svelte frontend.
# Run all backend tests
dotnet test MySvelteApp.Server/Tests/
# Run with code coverage
dotnet test MySvelteApp.Server/Tests/ --collect:"XPlat Code Coverage"
# Unit tests
npm run test:unit --prefix MySvelteApp.Client
# End-to-end tests
npm run test:e2e --prefix MySvelteApp.Client
# Type checking
npm run check --prefix MySvelteApp.Client
Build the application
npm run build
Using Docker
# Production containers
npm run docker:prod
# Or manually
docker-compose -f docker-compose.yml up -d
Manual deployment
Create .env
files for different environments:
# Frontend (.env)
VITE_API_URL=http://localhost:7216
# For production, update to your deployed API URL
# VITE_API_URL=https://your-api-domain.com
// Backend (appsettings.Production.json)
{
"ConnectionStrings": {
"DefaultConnection": "Server=your-server;Database=your-db;..."
},
"Jwt": {
"Secret": "your-256-bit-secret-key-here",
"Issuer": "your-app-name",
"Audience": "your-app-name"
}
}
The backend provides comprehensive API documentation:
POST /Auth/login
- User authenticationPOST /Auth/register
- User registrationGET /RandomPokemon
- Get random Pokemon dataGET /WeatherForecast
- Sample weather data# Run all quality checks
npm run lint --prefix MySvelteApp.Client
npm run check --prefix MySvelteApp.Client
dotnet test MySvelteApp.Server/Tests/
npm run generate-api-classes
This project uses SvelteKit's experimental remote functions for type-safe client-server communication:
// Remote function (server-side)
export const getData = query(async () => {
// Server-side logic
return data;
});
// Component usage (client-side)
const data = $derived(await getData());
git checkout -b feature/your-feature
npm run lint && npm run check && dotnet test
git commit -m "feat: add new feature"
svelte-NET-Test/
โโโ MySvelteApp.Client/ # SvelteKit frontend (Svelte 5)
โโโ MySvelteApp.Server/ # ASP.NET Core BFF (Clean Architecture)
โโโ CLAUDE.md # AI assistant development guide
โโโ structure.md # Complete architecture documentation
โโโ docker-compose.yml # Production deployment
โโโ docker-compose.dev.yml # Development environment
โโโ .github/ # CI/CD workflows
For Your Project:
MySvelteApp.Client
and MySvelteApp.Server
to your app namesKey Documentation:
This project is licensed under the MIT License - see the LICENSE file for details.
Professional full-stack template built with โค๏ธ
Frontend: SvelteKit 5 + TypeScript + Tailwind CSS Backend: ASP.NET Core 9.0 + Clean Architecture + DDD patterns BFF Pattern: Type-safe communication between frontend and backend DevOps: Docker + GitHub Actions + Observability
# 1. Clone this template
git clone https://github.com/refactor-gremlin/svelte-NET-Test.git my-awesome-app
cd my-awesome-app
# 2. Customize for your needs
# - Rename projects and namespaces
# - Configure your database
# - Update environment variables
# - Add your business logic
# 3. Start developing!
npm run dev
This template gives you a production-ready foundation so you can focus on building your application's unique features! ๐