diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
new file mode 100644
index 0000000..3251b59
--- /dev/null
+++ b/.devcontainer/devcontainer.json
@@ -0,0 +1,35 @@
+// For format details, see https://aka.ms/devcontainer.json. For config options, see the
+// README at: https://github.com/devcontainers/templates/tree/main/src/dotnet
+{
+ "name": "MuiCharts",
+ // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
+ "image": "mcr.microsoft.com/devcontainers/dotnet:1-8.0-bookworm",
+ // Features to add to the dev container. More info: https://containers.dev/features.
+ "features": {
+ "ghcr.io/devcontainers/features/node:1": {
+ "nodeGypDependencies": true,
+ "version": "latest",
+ "nvmVersion": "latest"
+ }
+ },
+
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
+ // "forwardPorts": [5000, 5001],
+ // "portsAttributes": {
+ // "5001": {
+ // "protocol": "https"
+ // }
+ // }
+
+ // Use 'postCreateCommand' to run commands after the container is created.
+ "postCreateCommand": {
+ "backend": "cd backend && dotnet restore"
+ // "frontend": "cd frontend && yarn install"
+ }
+
+ // Configure tool-specific properties.
+ // "customizations": {},
+
+ // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
+ // "remoteUser": "root"
+}
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 0000000..f33a02c
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,12 @@
+# To get started with Dependabot version updates, you'll need to specify which
+# package ecosystems to update and where the package manifests are located.
+# Please see the documentation for more information:
+# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
+# https://containers.dev/guide/dependabot
+
+version: 2
+updates:
+ - package-ecosystem: "devcontainers"
+ directory: "/"
+ schedule:
+ interval: weekly
diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 0000000..edc366b
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,35 @@
+{
+ "version": "0.2.0",
+ "configurations": [
+ {
+ // Use IntelliSense to find out which attributes exist for C# debugging
+ // Use hover for the description of the existing attributes
+ // For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md.
+ "name": ".NET Core Launch (web)",
+ "type": "coreclr",
+ "request": "launch",
+ "preLaunchTask": "build",
+ // If you have changed target frameworks, make sure to update the program path.
+ "program": "${workspaceFolder}/MuiCharts.Api/bin/Debug/net8.0/MuiCharts.Api.dll",
+ "args": [],
+ "cwd": "${workspaceFolder}/MuiCharts.Api",
+ "stopAtEntry": false,
+ // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
+ "serverReadyAction": {
+ "action": "openExternally",
+ "pattern": "\\bNow listening on:\\s+(https?://\\S+)"
+ },
+ "env": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ },
+ "sourceFileMap": {
+ "/Views": "${workspaceFolder}/Views"
+ }
+ },
+ {
+ "name": ".NET Core Attach",
+ "type": "coreclr",
+ "request": "attach"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
new file mode 100644
index 0000000..48ea68a
--- /dev/null
+++ b/.vscode/tasks.json
@@ -0,0 +1,41 @@
+{
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "label": "backend: build",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "build",
+ "${workspaceFolder}/MuiCharts.sln",
+ "/property:GenerateFullPaths=true",
+ "/consoleloggerparameters:NoSummary;ForceNoAlign"
+ ],
+ "problemMatcher": "$msCompile"
+ },
+ {
+ "label": "backend: publish",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "publish",
+ "${workspaceFolder}/MuiCharts.sln",
+ "/property:GenerateFullPaths=true",
+ "/consoleloggerparameters:NoSummary;ForceNoAlign"
+ ],
+ "problemMatcher": "$msCompile"
+ },
+ {
+ "label": "backend: watch",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "watch",
+ "run",
+ "--project",
+ "${workspaceFolder}/MuiCharts.sln"
+ ],
+ "problemMatcher": "$msCompile"
+ }
+ ]
+}
diff --git a/backend/.gitignore b/backend/.gitignore
new file mode 100644
index 0000000..6f08c89
--- /dev/null
+++ b/backend/.gitignore
@@ -0,0 +1,488 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+##
+## Get latest from `dotnet new gitignore`
+
+# dotenv files
+.env
+
+# User-specific files
+*.rsuser
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Mono auto generated files
+mono_crash.*
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+[Ww][Ii][Nn]32/
+[Aa][Rr][Mm]/
+[Aa][Rr][Mm]64/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+[Ll]ogs/
+
+# Visual Studio 2015/2017 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# Visual Studio 2017 auto generated files
+Generated\ Files/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUnit
+*.VisualState.xml
+TestResult.xml
+nunit-*.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+# Tye
+.tye/
+
+# ASP.NET Scaffolding
+ScaffoldingReadMe.txt
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
+*_i.c
+*_p.c
+*_h.h
+*.ilk
+*.meta
+*.obj
+*.iobj
+*.pch
+*.pdb
+*.ipdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*_wpftmp.csproj
+*.log
+*.tlog
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# Visual Studio Trace Files
+*.e2e
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Coverlet is a free, cross platform Code Coverage Tool
+coverage*.json
+coverage*.xml
+coverage*.info
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# Note: Comment the next line if you want to checkin your web deploy settings,
+# but database connection strings (with potential passwords) will be unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# NuGet Symbol Packages
+*.snupkg
+# The packages folder can be ignored because of Package Restore
+**/[Pp]ackages/*
+# except build/, which is used as an MSBuild target.
+!**/[Pp]ackages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/[Pp]ackages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+*.appx
+*.appxbundle
+*.appxupload
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!?*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+orleans.codegen.cs
+
+# Including strong name files can present a security risk
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+#*.snk
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+ServiceFabricBackup/
+*.rptproj.bak
+
+# SQL Server files
+*.mdf
+*.ldf
+*.ndf
+
+# SQLite database files
+*.sqlite
+*.db
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+*.rptproj.rsuser
+*- [Bb]ackup.rdl
+*- [Bb]ackup ([0-9]).rdl
+*- [Bb]ackup ([0-9][0-9]).rdl
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# Visual Studio 6 auto-generated project file (contains which files were open etc.)
+*.vbp
+
+# Visual Studio 6 workspace and project file (working project files containing files to include in project)
+*.dsw
+*.dsp
+
+# Visual Studio 6 technical files
+*.ncb
+*.aps
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# CodeRush personal settings
+.cr/personal
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
+
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder
+.mfractor/
+
+# Local History for Visual Studio
+.localhistory/
+
+# Visual Studio History (VSHistory) files
+.vshistory/
+
+# BeatPulse healthcheck temp database
+healthchecksdb
+
+# Backup folder for Package Reference Convert tool in Visual Studio 2017
+MigrationBackup/
+
+# Ionide (cross platform F# VS Code tools) working folder
+.ionide/
+
+# Fody - auto-generated XML schema
+FodyWeavers.xsd
+
+# VS Code files for those working on multiple tools
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+*.code-workspace
+
+# Local History for Visual Studio Code
+.history/
+
+# Windows Installer files from build outputs
+*.cab
+*.msi
+*.msix
+*.msm
+*.msp
+
+# JetBrains Rider
+*.sln.iml
+.idea
+
+##
+## Visual studio for Mac
+##
+
+
+# globs
+Makefile.in
+*.userprefs
+*.usertasks
+config.make
+config.status
+aclocal.m4
+install-sh
+autom4te.cache/
+*.tar.gz
+tarballs/
+test-results/
+
+# Mac bundle stuff
+*.dmg
+*.app
+
+# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
+# General
+.DS_Store
+.AppleDouble
+.LSOverride
+
+# Icon must end with two \r
+Icon
+
+
+# Thumbnails
+._*
+
+# Files that might appear in the root of a volume
+.DocumentRevisions-V100
+.fseventsd
+.Spotlight-V100
+.TemporaryItems
+.Trashes
+.VolumeIcon.icns
+.com.apple.timemachine.donotpresent
+
+# Directories potentially created on remote AFP share
+.AppleDB
+.AppleDesktop
+Network Trash Folder
+Temporary Items
+.apdisk
+
+# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
+# Windows thumbnail cache files
+Thumbs.db
+ehthumbs.db
+ehthumbs_vista.db
+
+# Dump file
+*.stackdump
+
+# Folder config file
+[Dd]esktop.ini
+
+# Recycle Bin used on file shares
+$RECYCLE.BIN/
+
+# Windows Installer files
+*.cab
+*.msi
+*.msix
+*.msm
+*.msp
+
+# Windows shortcuts
+*.lnk
+
+# Vim temporary swap files
+*.swp
diff --git a/backend/MuiCharts.Api/Controllers/ApiControllerBase.cs b/backend/MuiCharts.Api/Controllers/ApiControllerBase.cs
new file mode 100644
index 0000000..745970a
--- /dev/null
+++ b/backend/MuiCharts.Api/Controllers/ApiControllerBase.cs
@@ -0,0 +1,57 @@
+using ErrorOr;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.ModelBinding;
+
+namespace MuiCharts.Api.Controllers;
+
+///
+/// Base class for API controllers that provides common functionality and error handling.
+///
+/// The type of the derived controller.
+[ApiController]
+[Route("[controller]")]
+public abstract class ApiControllerBase(ILogger logger)
+ : ControllerBase where T : ApiControllerBase
+{
+ ///
+ /// Gets the logger instance used for logging.
+ ///
+ protected ILogger Logger { get; } = logger;
+
+ ///
+ /// Handles the response for a list of errors.
+ ///
+ /// The list of errors.
+ /// An representing the response.
+ protected IActionResult Problem(List errors)
+ {
+ if (errors.All(error => error.Type == ErrorType.Validation))
+ {
+ ModelStateDictionary modelState = new();
+
+ foreach (Error error in errors)
+ modelState.AddModelError(error.Code, error.Description);
+
+ return ValidationProblem(modelState);
+ }
+
+ Error firstError = errors[0];
+
+ Logger.LogError("An error occured during request processing: {Error}", firstError);
+
+ int statusCode = firstError.Type switch
+ {
+ ErrorType.Validation => StatusCodes.Status400BadRequest,
+ ErrorType.Unauthorized => StatusCodes.Status401Unauthorized,
+ ErrorType.Forbidden => StatusCodes.Status403Forbidden,
+ ErrorType.NotFound => StatusCodes.Status404NotFound,
+ ErrorType.Conflict => StatusCodes.Status409Conflict,
+ _ => StatusCodes.Status500InternalServerError
+ };
+
+ return Problem(
+ statusCode: statusCode,
+ detail: firstError.Description
+ );
+ }
+}
diff --git a/backend/MuiCharts.Api/Controllers/ErrorController.cs b/backend/MuiCharts.Api/Controllers/ErrorController.cs
new file mode 100644
index 0000000..5caaff0
--- /dev/null
+++ b/backend/MuiCharts.Api/Controllers/ErrorController.cs
@@ -0,0 +1,19 @@
+using Microsoft.AspNetCore.Mvc;
+
+namespace MuiCharts.Api;
+
+///
+/// Controller for handling errors.
+///
+[ApiController]
+[Route("[controller]")]
+public class ErrorController: ControllerBase
+{
+ ///
+ /// Handles the HTTP GET request for the error endpoint.
+ ///
+ /// An IActionResult representing the error response.
+ [HttpGet]
+ [ProducesResponseType(StatusCodes.Status500InternalServerError)]
+ public IActionResult Error() => Problem();
+}
diff --git a/backend/MuiCharts.Api/Controllers/PointsController.cs b/backend/MuiCharts.Api/Controllers/PointsController.cs
new file mode 100644
index 0000000..4801491
--- /dev/null
+++ b/backend/MuiCharts.Api/Controllers/PointsController.cs
@@ -0,0 +1,219 @@
+using ErrorOr;
+using Microsoft.AspNetCore.Mvc;
+using MuiCharts.Contracts.Point;
+using MuiCharts.Domain.Models;
+using MuiCharts.Domain.Repositories;
+
+namespace MuiCharts.Api.Controllers;
+
+///
+/// Controller for managing points.
+///
+public class PointsController(
+ ILogger logger,
+ IPointRepository pointRepository
+) : ApiControllerBase(logger)
+{
+ private readonly IPointRepository _repository = pointRepository;
+
+ ///
+ /// Creates a new point.
+ ///
+ /// The new point model.
+ /// An representing the asynchronous operation result.
+ [HttpPost]
+ [ProducesResponseType(StatusCodes.Status201Created)]
+ [ProducesResponseType(StatusCodes.Status400BadRequest)]
+ [ProducesDefaultResponseType(typeof(ProblemDetails))]
+ public async Task CreatePointAsync(UpsertPointRequest request)
+ {
+ Logger.LogInformation("Creating point with name {Name} and height {Height}", request.Name, request.Height);
+
+ Point point = new()
+ {
+ Id = default,
+ Name = request.Name,
+ Height = request.Height
+ };
+
+ ErrorOr createResult = await _repository.AddPointAsync(point);
+
+ if (createResult.IsError)
+ return Problem(createResult.Errors);
+
+ Logger.LogInformation("Point created with id {Id}", createResult.Value.Id);
+
+ return CreatedAtPointResult(createResult.Value);
+ }
+
+ ///
+ /// Retrieves an array of points based on the provided IDs.
+ ///
+ /// The array of point IDs.
+ /// An representing the asynchronous operation result.
+ [HttpPost("Array")]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status206PartialContent)]
+ [ProducesResponseType(StatusCodes.Status404NotFound)]
+ [ProducesResponseType(StatusCodes.Status400BadRequest)]
+ [ProducesDefaultResponseType(typeof(ProblemDetails))]
+ public async Task GetPointsArrayAsync(int[] ids)
+ {
+ Logger.LogInformation("Getting points with ids {Ids}", ids);
+
+ IQueryable query = await _repository.GetPointsRangeAsync();
+
+ PointResponse[] points = [
+ .. query
+ .Where(point => ids.Contains(point.Id))
+ .Select(point => MapPointResponse(point))
+ ];
+
+ if (points.Length == 0)
+ {
+ Logger.LogInformation("No points found with ids {Ids}", ids);
+ return NotFound();
+ }
+
+ if (points.Length != ids.Length)
+ {
+ Logger.LogInformation("Not all points found with ids {Ids}", ids);
+ return StatusCode(StatusCodes.Status206PartialContent, points);
+ }
+
+ Logger.LogInformation("Returning {Count} points", points.Length);
+
+ return Ok(points);
+ }
+
+ ///
+ /// Retrieves a range of points based on the specified page and count.
+ ///
+ /// The request object containing the page and count parameters.
+ /// An representing the asynchronous operation result.
+ [HttpGet]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status400BadRequest)]
+ [ProducesDefaultResponseType(typeof(ProblemDetails))]
+ public async Task GetPointsAsync([FromQuery] GetPointsRequest request)
+ {
+ Logger.LogInformation("Getting points with page {Page} and count {Count}", request.Page, request.Count);
+
+ IQueryable query = await _repository.GetPointsRangeAsync();
+
+ PointResponse[] points = [
+ .. query
+ .Skip((request.Page - 1) * request.Count)
+ .Take(request.Count)
+ .Select(point => MapPointResponse(point))
+ ];
+
+ GetPointsResponse response = new(
+ points,
+ query.Count(),
+ points.Length,
+ request.Page
+ );
+
+ Logger.LogInformation("Returning {Count} points", response.Count);
+
+ return Ok(response);
+ }
+
+ ///
+ /// Retrieves a point with the specified ID.
+ ///
+ /// The ID of the point to retrieve.
+ /// An representing the asynchronous operation result.
+ [HttpGet("{id:int}")]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status404NotFound)]
+ [ProducesDefaultResponseType(typeof(ProblemDetails))]
+ public async Task GetPointAsync(int id)
+ {
+ Logger.LogInformation("Getting point with id {Id}", id);
+
+ ErrorOr getResult = await _repository.GetPointAsync(id);
+
+ if (getResult.IsError)
+ return Problem(getResult.Errors);
+
+ Logger.LogInformation("Returning point with id {Id}", id);
+
+ return Ok(MapPointResponse(getResult.Value));
+ }
+
+ ///
+ /// Upserts a point with the specified ID and request data.
+ ///
+ /// The ID of the point.
+ /// The request data for the point.
+ /// An representing the asynchronous operation result.
+ [HttpPut("{id:int}")]
+ [ProducesResponseType(StatusCodes.Status201Created)]
+ [ProducesResponseType(StatusCodes.Status204NoContent)]
+ [ProducesResponseType(StatusCodes.Status400BadRequest)]
+ [ProducesDefaultResponseType(typeof(ProblemDetails))]
+ public async Task UpsertPointAsync(int id, UpsertPointRequest request)
+ {
+ Logger.LogInformation("Upserting point with id {Id}", id);
+
+ Point point = new()
+ {
+ Id = id,
+ Name = request.Name,
+ Height = request.Height
+ };
+
+ ErrorOr upsertResult = await _repository.AddOrUpdatePointAsync(point);
+
+ if (upsertResult.IsError)
+ return Problem(upsertResult.Errors);
+
+ if (upsertResult.Value is Point value)
+ {
+ Logger.LogInformation("Point created with id {Id}", value.Id);
+ return CreatedAtPointResult(value);
+ }
+
+ Logger.LogInformation("Point updated with id {Id}", id);
+ return NoContent();
+ }
+
+ ///
+ /// Deletes a point with the specified ID.
+ ///
+ /// The ID of the point to delete.
+ /// An representing the asynchronous operation result.
+ [HttpDelete("{id:int}")]
+ [ProducesResponseType(StatusCodes.Status204NoContent)]
+ [ProducesResponseType(StatusCodes.Status404NotFound)]
+ [ProducesDefaultResponseType(typeof(ProblemDetails))]
+ public async Task DeletePointAsync(int id)
+ {
+ Logger.LogInformation("Deleting point with id {Id}", id);
+
+ ErrorOr deleteResult = await _repository.DeletePointAsync(id);
+
+ if (deleteResult.IsError)
+ return Problem(deleteResult.Errors);
+
+ Logger.LogInformation("Point deleted with id {Id}", id);
+
+ return NoContent();
+ }
+
+ private CreatedAtActionResult CreatedAtPointResult(Point point) =>
+ CreatedAtAction(
+ actionName: nameof(GetPointAsync),
+ routeValues: new { id = point.Id },
+ value: MapPointResponse(point)
+ );
+
+ private static PointResponse MapPointResponse(Point value) =>
+ new(
+ value.Id,
+ value.Name,
+ value.Height
+ );
+}
diff --git a/backend/MuiCharts.Api/Controllers/TracksController.cs b/backend/MuiCharts.Api/Controllers/TracksController.cs
new file mode 100644
index 0000000..a4395e3
--- /dev/null
+++ b/backend/MuiCharts.Api/Controllers/TracksController.cs
@@ -0,0 +1,180 @@
+using ErrorOr;
+using Microsoft.AspNetCore.Mvc;
+using MuiCharts.Contracts.Track;
+using MuiCharts.Domain.Models;
+using MuiCharts.Domain.Repositories;
+
+namespace MuiCharts.Api.Controllers;
+
+///
+/// Controller for managing tracks.
+///
+/// The logger.
+/// The track repository.
+public class TracksController(
+ ILogger logger,
+ ITrackRepository trackRepository
+) : ApiControllerBase(logger)
+{
+ private readonly ITrackRepository _repository = trackRepository;
+
+ ///
+ /// Creates a new track.
+ ///
+ /// The request containing the track details.
+ /// An representing the asynchronous operation result.
+ [HttpPost]
+ [ProducesResponseType(StatusCodes.Status201Created)]
+ [ProducesResponseType(StatusCodes.Status400BadRequest)]
+ [ProducesResponseType(StatusCodes.Status409Conflict)]
+ [ProducesDefaultResponseType(typeof(ProblemDetails))]
+ public async Task CreateTrackAsync(UpsertTrackRequest request)
+ {
+ // TODO: Check if points exist
+ Logger.LogInformation("Creating track with first ID {FirstId} and second ID {SecondId}", request.FirstId, request.SecondId);
+
+ if (request.FirstId == request.SecondId)
+ return Problem([Error.Validation(description: "First ID and second ID cannot be the same.")]);
+
+ Track track = new()
+ {
+ FirstId = request.FirstId,
+ SecondId = request.SecondId,
+ Distance = request.Distance,
+ Surface = request.Surface,
+ MaxSpeed = request.MaxSpeed
+ };
+
+ ErrorOr