Blood Donation.
🩸 Blood Donation App
An ASP.NET Core 9 web app for managing blood-donation events and registrations: users sign up with a blood type, register for events, and admins manage events, users, registrations, and per-event reports. The solution comprises a backend Web API (BloodDonationAPI) with Entity Framework Core + SQL Server and a Blazor WebAssembly client (BloodDonationClient).
Project Status
Personal/portfolio project. The event, registration, user, and reporting flows are implemented. Not under active development.
⚠️ Security notice (read me).
BloodDonationAPI/appsettings.jsonwas committed with live secrets (a JWT signing key, Mailtrap SMTP credentials, and an admin-registration code). Do not reuse the committed values. Rotate the JWT key, the Mailtrap credentials, and the admin-registration code, and replace them with values stored out of source (e.g., User Secrets, environment variables, or a secret manager). Removing them from the current file does not remove them from Git history; that requires a separate history rewrite, which is outside the scope of this read-only documentation update.
Key Features
- User registration and login with role-based access (
admin,user) - Event management: create, update, delete, view donation events
- Event registration: users register for events and manage their registrations
- Admin dashboard for users, events, registrations, and reports
- Email notifications via SMTP (the API uses
System.Net.Mail.SmtpClient; Mailtrap was used in development) - Profile management for users
- JWT-based API authorization with role checks
- Admin functions: user management, event report generation, aggregated blood-variant/participation statistics, and role management
Architecture
Loading architecture diagram…
Diagram source
flowchart LR
C["Blazor WebAssembly client<br/>(BloodDonationClient)"] -->|HTTPS / JWT| A["ASP.NET Core 9 Web API<br/>(BloodDonationAPI)"]
A --> EC["EF Core 9 + SQL Server"]
A --> SMTP["SMTP<br/>(System.Net.Mail / Mailtrap)"]
A --> S["Services (EmailService, etc.)"]
- Backend (API): ASP.NET Core 9 controllers, EF Core 9 with SQL Server, JWT bearer auth + role authorization, password hashing via BCrypt.Net-Next, Swagger.
- Frontend (client): Blazor WebAssembly 9 with Blazorise + Bootstrap UI.
- Database: SQL Server. Schema is managed by EF Core migrations (
BloodDonationAPI/Migrations/).
Technology Stack
- Backend: .NET 9, ASP.NET Core 9 Web API, Entity Framework Core 9, SQL Server,
Microsoft.AspNetCore.Authentication.JwtBearer, BCrypt.Net-Next - Auth: JWT bearer tokens (custom
Usermodel; ASP.NET Core Identity is referenced in the client csproj but not used for data) - Email: SMTP via
System.Net.Mail.SmtpClient(Mailtrap was used in development) - Frontend: .NET 9 Blazor WebAssembly, Blazorise 1.7.1, Bootstrap
- API docs: Swagger / OpenAPI
- IDE: Visual Studio / VS Code with the .NET 9 SDK
Repository Structure
.
├── BloodDonationAPI/ # ASP.NET Core 9 Web API
│ ├── Controllers/ # auth/admin/events/registrations/reports/controllers
│ ├── Services/ # EmailService, etc.
│ ├── Models/ # entities + DTOs
│ ├── Data/ # ApplicationDbContext
│ ├── Migrations/ # EF Core migrations
│ └── appsettings.json # ⚠️ contains committed secrets — rotate and move out of source
├── BloodDonationClient/ # Blazor WebAssembly client
│ ├── Pages/ / Components/ # UI
│ └── Program.cs / Services/ # HttpClient wiring
├── BloodDonationApp.sln
└── README.md
Prerequisites
- .NET 9 SDK
- SQL Server (LocalDB, Express, or full) or a SQL Database you can connect to
- Visual Studio 2022 / VS Code with the .NET 9 workload (or the .NET CLI)
- An SMTP mailbox (Mailtrap is fine for development)
Getting Started
-
Clone the repository:
git clone https://github.com/dilrukshax/BloodDonationApp cd BloodDonationApp -
Configure the API. Open
BloodDonationAPI/appsettings.jsonand replace the committed secrets with your own values — store them via User Secrets or environment variables rather than committing them. The required keys are:{ "ConnectionStrings": { "DefaultConnection": "Server=YOUR_SERVER;Database=BloodDonationDB;Trusted_Connection=True;TrustServerCertificate=True;" }, "Jwt": { "Key": "YOUR_LONG_RANDOM_SIGNING_KEY", "Issuer": "YourApp", "Audience": "YourAppUsers", "DurationInMinutes": "60" }, "AdminRegistration": { "Code": "YOUR_ADMIN_REGISTRATION_CODE" }, "EmailSettings": { "Mailtrap": { "Host": "smtp.mailtrap.io", "Port": 587, "Username": "your-username", "Password": "your-password", "FromEmail": "no-reply@example.com", "FromName": "Blood Donation App" } } } -
Apply the existing migrations (migrations are already included in the repo — do not run
migrations add InitialCreate):cd BloodDonationAPI dotnet ef database update -
Run the API:
dotnet run --project BloodDonationAPI/BloodDonationAPI.csprojThe API serves on
http://localhost:5234andhttps://localhost:7252(perlaunchSettings.json) and exposes Swagger at/swagger. -
In a second terminal, run the Blazor client:
dotnet run --project BloodDonationClient/BloodDonationClient.csprojThe client serves on
http://localhost:5063andhttps://localhost:7071(perlaunchSettings.json). Configure the client'sHttpClientbase address (inProgram.cs) to point at the API host if your setup differs from localhost.
Database Setup
The database is created by EF Core. After setting ConnectionStrings:DefaultConnection, run dotnet ef database update inside BloodDonationAPI/ to apply the migrations and create the schema.
Testing
There is no automated test suite in the solution; tests were not executed. Build the solution to confirm it compiles:
dotnet build BloodDonationApp.sln
Deployment
No deployment URL is configured. Deploy the API and the Blazor client as separate apps to any .NET 9-capable host, or publish the client to static hosting and the API to a managed service, then point the client at the API's public base URL.
Security
- API access is gated by JWT bearer tokens with role-based authorization (
admin,user). - Passwords are hashed with BCrypt.Net-Next.
- The admin-registration code is required to sign up the first admin.
- Action required: rotate the committed JWT key, Mailtrap credentials, and admin code, and move secrets out of
appsettings.json(User Secrets / env vars / a secret manager). The app is not safe to reuse as-is.
Limitations
- Secrets were committed to
appsettings.jsonin Git history; this documentation change does not remove them from history. A separate history rewrite is required if they must be purged. - No automated tests.
- The committed
bin//obj/artifacts and.vs//.userfiles are present in the repository.
Contributing
This is a personal project and not accepting external contributions.
License
Licensed under the MIT License.
Author
Dilan Dilruksha
Software Engineer | Backend & Full-Stack Development
Portfolio: https://dilandilruksha.dev
LinkedIn: https://www.linkedin.com/in/dilan-dilruksha
GitHub: https://github.com/dilrukshax
Donor management platform with event scheduling, blood inventory tracking, and registration workflows. Donors and organisers get automated email updates as event status changes, and the inventory view stays in sync with each donation.
ASP.NET Core with SQL Server. JWT-secured REST APIs documented in Swagger, MailKit for transactional notifications. Blazor on the front for donor and admin surfaces. Create, update, and cancel event flows tracked through to participation reporting across blood variants.