Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/marchena96/Paradigma-lab1/llms.txt

Use this file to discover all available pages before exploring further.

appsettings.json contains only the placeholder password [SUPABASE-PASSWORD] in the DefaultConnection string — the file is safe to commit and push to a public repository. The real connection string (with the actual Supabase password) is stored in .NET User Secrets, a local, per-developer secret store that lives outside the repository on your machine. User Secrets are loaded automatically by Host.CreateDefaultBuilder only when ASPNETCORE_ENVIRONMENT is set to Development, so the placeholder is never replaced in CI or production builds.

Why User Secrets?

.NET User Secrets implement the 12-factor app principle: configuration that differs between environments — especially credentials — should never live in source code. Keeping the password in appsettings.json would mean committing it to git, where it would be visible in the history forever even if you tried to remove it later. With User Secrets:
  • The repository contains only the placeholder, so it is safe to push to GitHub or hand to a reviewer.
  • Each developer holds their own copy of the real password locally; a compromised machine does not expose the repository.
  • Rotating the Supabase password requires updating only the local secret on each machine — no git commits needed.

Setup steps

1

Navigate to the project directory

All dotnet user-secrets commands must run from (or target) the HackerRank1/ directory, because that is where HackerRank1.csproj — which carries the UserSecretsId — lives.
cd HackerRank1
2

Register the real connection string

Run the following command, substituting your actual Supabase password for <your-supabase-password>:
dotnet user-secrets set "ConnectionStrings:DefaultConnection" \
  "Host=aws-1-us-west-2.pooler.supabase.com;Port=5432;Database=postgres;Username=postgres.gyktxhzyeyisdbafvvpm;Password=<your-supabase-password>;SSL Mode=Require;Trust Server Certificate=true;Pooling=false"
The key name ConnectionStrings:DefaultConnection uses : as a path separator — exactly what Configuration.GetConnectionString("DefaultConnection") resolves in Startup.cs.
3

Verify the secret is registered

Confirm the secret was written correctly:
dotnet user-secrets list
You should see output similar to:
ConnectionStrings:DefaultConnection = Host=aws-1-us-west-2.pooler.supabase.com;Port=5432;...
4

Run the API

Start the application normally. The secret automatically overrides the placeholder in appsettings.json at runtime:
dotnet run --project HackerRank1
The API will be available at https://localhost:7098. Swagger UI is served at https://localhost:7098/swagger.

Where secrets are stored

User Secrets are stored in a JSON file outside the repository, in your operating system’s user profile directory. The location is determined by the UserSecretsId declared in HackerRank1/HackerRank1.csproj:
<UserSecretsId>9cbbfeab-44b3-447c-8aa1-4d5adea68ef6</UserSecretsId>
OSPath
Windows%APPDATA%\Microsoft\UserSecrets\9cbbfeab-44b3-447c-8aa1-4d5adea68ef6\secrets.json
Linux / macOS~/.microsoft/usersecrets/9cbbfeab-44b3-447c-8aa1-4d5adea68ef6/secrets.json
The folder name is always the UserSecretsId GUID — .NET uses it to look up secrets for this specific project. The expected structure of secrets.json is:
{
  "ConnectionStrings:DefaultConnection": "Host=aws-1-us-west-2.pooler.supabase.com;Port=5432;Database=postgres;Username=postgres.gyktxhzyeyisdbafvvpm;Password=<your-supabase-password>;SSL Mode=Require;Trust Server Certificate=true;Pooling=false"
}
Because this file lives under %APPDATA% (or ~/.microsoft/), it is completely outside the cloned repository directory and will never be picked up by git.

Environment loading

User Secrets are only loaded when ASPNETCORE_ENVIRONMENT is set to Development. This value is pre-configured in Properties/launchSettings.json:
"ASPNETCORE_ENVIRONMENT": "Development"
The loading itself is handled by a single line in Program.cs:
Host.CreateDefaultBuilder(args)
    .ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup<Startup>());
CreateDefaultBuilder automatically appends the User Secrets configuration provider when it detects the Development environment, before Startup.ConfigureServices runs. The final configuration chain is:
SourceValue for DefaultConnection
appsettings.json...Password=[SUPABASE-PASSWORD]... (placeholder)
User Secrets...Password=<real>...wins, overrides placeholder
Environment variables(not set)
In staging or production, remove or don’t set ASPNETCORE_ENVIRONMENT=Development. Use OS environment variables, Azure Key Vault, or another secrets manager to supply the connection string instead.

Onboarding checklist

Follow these steps whenever you clone the repository onto a new machine or set up a fresh development environment:
  1. Clone the repository
    git clone https://github.com/marchena96/Paradigma-lab1.git
    cd Paradigma-lab1
    
  2. Install the dotnet-ef global tool (required for migration commands)
    dotnet tool install --global dotnet-ef --version 8.0.2
    
  3. Obtain PostgreSQL credentials Either request access to the existing Supabase project, or create a new Supabase project and note its host, username, and password from the Supabase dashboard under Settings → Database.
  4. Register the connection string in User Secrets (from the HackerRank1/ directory)
    dotnet user-secrets set "ConnectionStrings:DefaultConnection" \
      "Host=<host>;Port=5432;Database=postgres;Username=<user>;Password=<password>;SSL Mode=Require;Trust Server Certificate=true;Pooling=false"
    
  5. Build and run the API
    dotnet run --project HackerRank1
    
    The app starts at https://localhost:7098. On first run, db.Database.Migrate() will automatically apply any pending EF Core migrations to your PostgreSQL database.
Without a valid connection string in place, the application compiles successfully but crashes at startup when db.Database.Migrate() is called in Startup.Configure. The connection attempt fails immediately because the placeholder [SUPABASE-PASSWORD] is not a real password. Always register the User Secret before running the API.
If you change machines or the local secrets.json is lost, you can retrieve or reset the Supabase database password from the Supabase dashboard → Settings → Database → Reset database password. After resetting, re-run the dotnet user-secrets set command with the new password on every machine that runs the project.

Build docs developers (and LLMs) love