The news site of the Schönherz Dormitory and the Budapest University of Technology and Economics. Built with ASP.NET, Blazor, Entity Framework, and Lit.
Instructions on how to quickly set up a development environment.
- .NET 10 SDK
- make sure you can run
dotnet --infoand it shows10.x.xunder .NET SDKs installed
- make sure you can run
- bun
- make sure you can run
bun
- make sure you can run
https://auth.sch.bme.hu > Bejelentkezés > Fejlesztői konzol > Új hozzáadása, set Átirányítási cím to
http://localhost:5264/signin-oidc,
then use the created credentials in the following commands:
git clone https://github.com/kir-dev/StartSCH
cd StartSCH/StartSch
dotnet user-secrets set AuthSch:ClientId YOUR_AUTHSCH_CLIENTID
dotnet user-secrets set AuthSch:ClientSecret YOUR_AUTHSCH_CLIENTSECRET
dotnet runI recommend using JetBrains' .NET IDE, Rider for working on StartSCH. Below you can find instructions on how run StartSCH in debug mode using it:
- Install Rider
- Open
StartSCH.slnx - Ensure AuthSCH credentials are correctly set up: Explorer > StartSch > right-click > Tools > .NET User Secrets
- Click Debug 'StartSch' (the green bug icon in the top right) or press
F5
Hot reloading allows updating the code of the app while it is running without restarting it. Rider's built-in hot reloading is not that great, so I highly recommend just running StartSCH from the terminal if you don't need a debugger:
cd StartSCH/StartSch
# Run StartSCH with hot reloading:
dotnet watchcd StartSCH/StartSch
# Use Bun to automatically bundle TypeScript and CSS files when they change
# (this is handled by dotnet build when not using hot reloading)
bun watchIf you don't like reading, check out these files and directories for a quick overview of the project:
StartSch/Program.cs: the entrypoint of the serverStartSch.csproj: NuGet dependenciespackage.json: NPM dependencies and CSS/TS build scripts
StartSch.Wasm/: C# code and Blazor components that can run in the user's browser. Currently unused..config/kubernetes.yaml: Kubernetes resource definitions required to run the production version of StartSCH in Kir-Dev's vCluster in the KSZK's Kubernetes cluster.
We use ASP.NET, which is a free, open-source, cross-platform, and high-performance HTTP server built on .NET, that supports a boatload of different use cases.
I recommend reading the following sections of its documentation to get a feel for it:
- ASP.NET docs: Configuration: environment variables,
appsettings.*.json,dotnet user-secrets, etc. - ASP.NET docs: Options pattern: accessing the above using type-safe C# classes
To send push notifications, most push services, for example, Apple, require a VAPID key pair.
If you want to try out push notifications, you can use a VAPID key generator to generate these, then configure StartSCH to use them:
cd StartSCH/StartSch
dotnet user-secrets set Push:PublicKey "..."
dotnet user-secrets set Push:PrivateKey "..."
# Push service providers use this if there are issues with a sender, probably not important when developing
dotnet user-secrets set Push:Subject "mailto:[email protected]"The production version of StartSCH uses PostgreSQL to persist data, but to simplify setting up a dev environment, SQLite is also supported, as it does not require any configuration.
We use Entity Framework to access the database from C# code. For most changes, you can get by with only a basic knowledge of Entity Framework, but if you have the time, I highly recommend also reading the documentation for Postgres and SQLite (the Postgres one is especially good).
If you are new to Entity Framework, I recommend skimming through the Entity Framework introduction, then the Overview pages for the sections in the table of contents on the left.
If needed, use the below commands to work with EF migrations:
cd StartSCH/StartSch
# Make sure you can run `dotnet ef`.
# One of these commands, ideally the first one, should install it.
dotnet tool restore
dotnet tool install dotnet-ef
dotnet tool install dotnet-ef --global
# Describe the migration
export MIGRATION_MESSAGE=AddSomethingToSomeOtherThing
# Add migration
dotnet ef migrations add --context SqliteDb $MIGRATION_MESSAGE
dotnet ef migrations add --context PostgresDb $MIGRATION_MESSAGE
# Remove latest migration
dotnet ef migrations remove --context SqliteDb
dotnet ef migrations remove --context PostgresDb
# Reset migrations
rm -r Data/Migrations/Postgres Data/Migrations/Sqlite
dotnet ef migrations add --context SqliteDb --output-dir Data/Migrations/Sqlite $MIGRATION_MESSAGE
dotnet ef migrations add --context PostgresDb --output-dir Data/Migrations/Postgres $MIGRATION_MESSAGENew migrations are applied automatically by StartSCH before it starts serving requests.
- EF docs: DbContext Lifetime, Configuration, and Initialization
- EF docs: ASP.NET Core Blazor with Entity Framework Core
Depending on where you want to access the database, you have to decide between injecting Db or IDbContextFactory<Db>.
For example, static forms or API controllers that run in a scope should use Db, while methods in an interactive Blazor component should request a new Db instance every time they run.
Might be useful when trying to reverse-engineer some APIs or debugging issues while developing StartSCH.
- Run StartSCH using the
SSLKEYLOGFILEenvironment variable set to a path to a non-existent file (e.g./home/USER/keylog.txt)- This is easiest using
StartSch/Properties/launchSettings.json: add"SSLKEYLOGFILE": "/home/USER/keylog.txt"to theenvironmentVariablessection under the launch profile you are using (httpby default)
- This is easiest using
- Add a
AppContext.SetSwitch("System.Net.EnableSslKeyLogging", true);line to the top ofProgram.cs - Set Wireshark/Edit/Preferences/Protocols/TLS/(Pre)-Master-Secret log filename to the path in the above environment variable
- Run StartSCH
SSLKEYLOGFILE also works in Firefox and Chrome:
SSLKEYLOGFILE=~/keylog.txt firefoxMake sure the browser is not already running (in the background), otherwise it won't pick up the env var.
- (Optional) Create or choose an issue to work on and assign it to yourself
- Create and checkout a new Git branch named
feature/...based onorigin/maingit checkout -b feature/something
- Write code
- Commit
git add .git commit -m "Add ..."
- Push your changes to GitHub
git push
- Open a pull request. If you want to keep working on it, mark it as a draft.
- Repeat 3-5. until satisfied
- Request a review on your pull request
We use squash merging for pull requests (commits from a PR get squashed into a single commit on the main branch). Try to keep pull requests focused on a single feature.