The foundation for a fullstack web app using ASP.NET / C#, Postgres, and SvelteKit.
This is an MVC application which means that the frontend sends requests to the backend and the response is displayed in a UI to the user. The example provided is in the form of a simple todo list app.
The frontend uses SvelteKit as well as other NPM packages using Yarn.
The backend uses ASP.NET through C# with Postgres for its database through Npgsql. This project is configured for Omnisharp, but your LSP or IDE shouldn't matter much.
All of these extensions can be easily installed when you open this repo in VS Code.
git clone https://github.com/njs-templates/aspnet-postgres-svelte.git
..git/
folder from the project root. Alternatively, you can use degit to do this for you.cd frontend
yarn
Create a .env
file at the root of the project and fill out the values with your preferences. You can just copy the .env.example
to make sure it works, but the username and password should be changed in a production environment.
While still in the root, run docker-compose up -d
to create and run the Postgres database in the background. You can run docker-compose down
to stop it.
While still in the root, run the following to install nuget packages. The aspnet-codegenerator is optional but recommended.
cd backend
dotnet restore
dotnet tool install --global dotnet-ef
dotnet tool install --global dotnet-aspnet-codegenerator
dotnet ef database update
dotnet run
cd frontend
yarn dev
If you can see both pages and you can add, delete, and edit the todo items, you should be good to go.