Introduction to Minimal Apis
We will create an event API to build on the concept of minimal APIs. This API will help you learn about:
Project structure
REST API
CRUD Functionality
We will use an in-memory database for now, meaning the data will not be permanently saved to the database.
Requirements
Code Editor - Visual Studio is preferred
Fundamental concepts of C# language
Readiness to learn 🙂
Create an Empty .NET Core Project
Understanding Project Structure
You should have the following code in the Program.cs file. Program.cs is the entry point of the application, and we will be referencing it several times.

Press the keys Ctrl + F5 or click the "Run without debugging" button to run the application.
You should have a browser launched with Hello World being displayed. This shows that the project configuration looks good.
Let's break down the scaffolded project:
Properties/launchSettings.json
This file tells Visual Studio or dotnet run how to launch the app during development, including:
Ports
Whether a browser should open
Environment variables
HTTPS or HTTP settings
Schema
The above line defines the JSON Schema - this helps editors like VS Code with IntelliSense and validation.
Profiles
Defines a way to run the application - we have two profiles: "http" and "https"
[ ] commandName: tells dotnet to launch the main project with dotnet run
[ ] dotnetRunMessages: shows the usual logs like ("now listening on http://")
[ ] launchBrowser: used to auto-launch the browser
[ ] applicationUrl: Port where the application will be running
[ ] environmentVariables: Sets the environment variables like "Development"
To avoid having the browser launch every time you run your project, head to the Properties folder and open the launchSettings.json file. You should see a property called ***launchBrowser: "true"***. Change that to launchBrowser: "false" for both the profiles (http and https).

The Dependencies folder will hold all the packages we will be installing from NuGet Package Manager
What is NuGet?
NuGet is the package manager for .NET. The NuGet client tools provide the ability to produce and consume packages. The NuGet Gallery is the central package repository used by all package authors and consumers.
Connected Services Folder
This folder provides tooling to connect your application to external services like:
[ ] Web APIs - OpenAPI/Swagger for API calls
[ ] gRPC services - Add and consume gRPC endpoints
[ ] Azure Services - Connect to older SOAP/WCF services
[ ] Databases - connect to a database and generate models with EF
Program.cs File
This is the entry point of the application. Let's break it down:
var builder = WebApplication.CreateBuilder(args);
Used to create a WebApplicationBuilder instance
It configures services, logging, environment, and app settings
var app = builder.Build();
This builds the application
Creates a WebApplication instance, making the app ready to define endpoints and middlewares
app.MapGet("/", () => "Hello World!");
This is where you define your first API endpoint. Whenever you visit the endpoint, it returns "Hello World".
() => "Hello World!" - this is a lambda function that returns a string. Lambda is a concept in C#.
app.Run();
This starts the web server.
It starts listening for HTTP requests on the specified port(s)
It keeps the application running
Create Models Folder
Add a folder at the root of the project and name it Models. The Models folder will hold all the entities we will be using. An entity is similar to a table in relational databases.
Inside the newly created Models folder, add a class named Event. This will hold the properties of an event.

All the fields are made public, meaning they can be accessed from anywhere in the application
These properties are of different data types which simulate the real-world object of an event
The string property has "?" because by default, all strings are nullable
Concept of Nullable Reference Types
This is a concept that was introduced in C# 8.0. In older versions of C#, you could not be warned if there was a potential null value. With nullable reference types, C# became more strict and smart by helping you catch null issues at compile time.
public string Description { get; set; } - This means that you guarantee that the Description will never be null. If you do not initialize any value, the compiler will warn you.
public string? Description { get; set; } - This means that Description can be null. This tells the compiler that it's okay if the property is null, and it won't warn you.
Turning Nullable ON and OFF
This behavior is controlled by a setting in the .csproj file:

.csproj File
This is an important file - it's like the heart of the project configuration. It is an XML file that defines:
What files are part of the project
What dependencies (NuGet packages) are needed
What version of .NET to use
Build settings, project properties, and more