Skip to content

Repository files navigation

FarroService — Backend

A clean-architecture REST API for booking plumbing & home-maintenance services.

.NET C# ASP.NET Core Entity Framework Core PostgreSQL MediatR JWT Scalar


Overview

FarroService Backend is the API powering a plumbing and home-services booking platform. It handles service catalog management, master (technician) scheduling, client bookings, and role-based administration — built with Clean Architecture principles on top of ASP.NET Core.

Clients book services through a simple public form (no account required), while admins and masters manage services, schedules, and bookings through authenticated endpoints.

Tech Stack

Layer Technology
Framework ASP.NET Core 10
Language C#
ORM Entity Framework Core
Application logic MediatR (CQRS pattern)
Authentication ASP.NET Identity + JWT Bearer
Database PostgreSQL hosted on Neon
Geocoding Nominatim API
API docs Scalar (OpenAPI UI)

Architecture

The solution follows a layered Clean Architecture approach:

backend/
├── FarroService.DAL/      # Entities, repositories, EF Core, migrations
├── FarroService.BLL/      # DTOs, MediatR commands/queries/handlers
└── FarroService.WebAPI/   # Controllers, DI configuration, Program.cs
  • DAL — persistence layer: entity models, DbContext, repositories, and database migrations.
  • BLL — business logic layer: request/response DTOs and CQRS handlers via MediatR.
  • WebAPI — presentation layer: REST controllers, middleware, and application startup.

Domain Model

Entity Description
ApplicationUser Identity-based user (Admin / Master), extended with full name and specializations
Service A bookable service with price, duration, and an associated specialization
Specialization A category of expertise linking masters to the services they can perform
Booking A client reservation for a service with a specific master, date, and time slot
Schedule A master's weekly working hours per day of the week

Roles

Role Description
MainAdmin Full system access
Admin Manages services, masters, and bookings
Master Manages own schedule and assigned bookings

Clients do not have accounts — bookings are created via a public form using just a name and phone number.

Business Rules

  • Bookings are only allowed within working hours: 10:00–19:00.
  • A master can only be booked for a service that matches one of their specializations.
  • Available time slots are calculated per master, per service, per day.

Getting Started

Prerequisites

Setup

# Restore dependencies
dotnet restore

# Configure your database connection string via User Secrets
dotnet user-secrets set "ConnectionStrings:DefaultConnection" "<your-connection-string>"

# Apply EF Core migrations
dotnet ef database update --project FarroService.DAL

# Run the API
dotnet run --project FarroService.WebAPI

Note: Use the direct Neon connection endpoint (without -pooler) for migrations — the pooled endpoint can cache stale "database not found" errors after dotnet ef database drop.

Seed Data

On first run, the database is seeded with:

  • 4 specializations: Plumbing, Heating, Sewerage, Water Supply
  • 7 services linked to those specializations
  • A MainAdmin and an Admin account
  • 3 masters, each with 2 specializations and a Mon–Fri, 10:00–19:00 schedule
Role Email Password
MainAdmin admin@farro.ua Admin123!
Admin manager@farro.ua Admin123!

API Documentation

Full interactive API documentation is available via Scalar once the project is running:

https://localhost:<port>/scalar

It covers authentication, services, masters, specializations, schedules, bookings, and user administration endpoints, including required roles and request/response schemas, generated from the app's OpenAPI specification.

Key Implementation Notes

  • options.MapInboundClaims = true is required for JWT — in .NET 10 this defaults to false, which silently breaks role-based authorization.
  • AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true) is enabled to support DateTime.Kind = Unspecified values in queries against PostgreSQL.

Part of the FarroService diploma project — see the frontend repository for the client application.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages