Backend API in ASP.NET Core for my portfolio project.
Used this as an opportunity to learn how to write APIs in multiple languages.
It handles storing messages from the contact form, emailing me the message contents,
and fetching pinned GitHub repositories for me to display on the frontend.
- RESTful API endpoints
- Save and manage contact form messages
- Fetch pinned / selected GitHub repos
- Email me each new message via BREVO
- Built with ASP.NET Core Web API
- CORS enabled for frontend integration
- CI/CD flow with Github actions
- ASP.NET Core (C#)
- Entity Framework Core
- xUnit testing
- PostgreSQL
- GitHub API integration
- Brevo API integration
- Azure App Service
- .NET 9 SDK
- PostgreSQL DB hosted on Render (for development preferably use a docker container running PostgreSQL)
- GitHub presonal access token
- Brevo API key
git clone https://github.com/cfrank3N/portfolio_api.git
cd portfolio_apiAdd a Properties directory from root and add launchSettings.json to it
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "http://localhost:5182",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:7138;http://localhost:5182",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}dotnet user-secrets init
dotnet user-secrets set "ApiKeys:BrevoApiKey" "<your_brevo_key>"
dotnet user-secrets set "ApiKeys:GitHubToken" "<your_github_token>"
dotnet user-secrets set "ConnectionStrings:DefaultConnection" "<your_connection_string>"
dotnet user-secrets set "EmailList:SenderName" "<sender_name>"
dotnet user-secrets set "EmailList:SenderEmail" "<your_brevo_authenticated_email>"
dotnet user-secrets set "EmailList:RecipientName" "<recipient_name>"
dotnet user-secrets set "EmailList:RecipientEmail" "<recipient_email>"Add your secrets to Github secrets (if you initialize a remote repo) Github secret name: APIKEYS__BREVOAPIKEY Dotnet translates __ into :
dotnet restore
dotnet runThe API will run by default on http://localhost:5182 or https://localhost:7138 if you're running https.
| Method | Path | Description | Request Body / Query |
|---|---|---|---|
GET |
/api/repos/pinned |
Fetch pinned / selected GitHub repos | — |
POST |
/api/savemessage |
Save contact form message | { senderName, senderEmail, content } |
POST /api/savemessage
Content-Type: application/json
{
"senderName": "Adam",
"senderEmail": "adam@example.com",
"content": "Hello, please contact me!"
}Response: 201 Created
{
"senderName": "Adam",
"senderEmail": "adam@example.com",
"content": "Hello, please contact me!"
}GET /api/repos/pinnedResponse:
[
{
"name": "portfolio_api",
"url": "https://github.com/cfrank3N/portfolio_api",
"description": "API in ASP.NET for my portfolio project.
Used this as an opportunity to learn how to write API's in multiple languages.
Hosted on Azure. Implements an emailing service via Brevo and fetches my pinned
repos on Github via their GraphQL API."
}
]- Model validation with Data Annotations
- Returns appropriate HTTP codes (400 for validation errors, 500 for server issues)
This API can be deployed to Azure App Service, Docker, or any host supporting .NET.
Steps:
- Build the project:
dotnet publish -c Release
- Deploy the published output from
bin/Release/netX/publish/. - Configure environment variables on the host.
Or use this guide to deploy to azure and use github actions as your CD flow.
Contributions, issues, and feature requests are welcome.
- Fork the repo
- Create a branch (
feature/your_featureorfix/your_fix) - Commit your changes
- Open a PR