Skip to content

Latest commit

 

History

20 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

.NET Minimal API — Distributed System (Master / Followers)

This project demonstrates a simple distributed system built with .NET 8 Minimal API. It uses a master–followers architecture, where:

  • The master node accepts write requests
  • Updates are represented as JSON Patch operations
  • The master applies the patch locally and propagates it to all followers
  • Followers apply the same patch to keep state consistent
  • A simple vector clock is used to prevent stale updates

Architecture Overview

  • Master node — receives PATCH requests and broadcasts them
  • Follower nodes — receive updates only from the master
  • All nodes run the same application image
  • Roles and topology are configured via appsettings.json and environment variables

Available Endpoints

  • /
    Returns a simple status message: "Server started!"
  • /get
    Returns the current JSON state stored on the node.
  • /replace
    Applies a single JSON Patch operation to the current state.
    On the master node, the patch is also forwarded to all followers.
  • /vclock
    Returns the current vector clock (logical timestamps per source).
  • /test
    Simple HTML UI for manual testing of /replace and /get.

Example /replace request body

The request contains:

  • Source — identifier of the request sender
  • ID — monotonically increasing logical timestamp
  • Payload — a single JSON Patch operation (RFC 6902)
{
    "Source": "Dyagilev",
    "ID": 1,
    "Payload": "{'op': 'add', 'path': '/hello', 'value': { 'name': 'Ginger' }}"
}

JSON Patch Examples

{
    "op": "add",
    "path": "/user",
    "value": { "name": "Alice" }
}
{
    "op": "replace",
    "path": "/user/name",
    "value": "Bob"
}
{
    "op": "remove",
    "path": "/user"
}

Setup and Run (Docker Compose)

The system is designed to run using Docker Compose. One container acts as the master, and multiple containers act as followers.

  1. Clone the repository:
    git clone https://github.com/GeorgeD615/DistributedSystemAPI.git
  2. Navigate to the project directory:
    cd DistributedSystemAPI
  3. Build and start all services:
    docker compose up --build
  4. Open the master node in a browser:
    http://localhost:3000

Ports Mapping

  • Master: http://localhost:3000
  • Follower 1: http://localhost:3001
  • Follower 2: http://localhost:3002
  • Follower 3: http://localhost:3003

Notes

  • The system demonstrates eventual consistency
  • JSON Patch operations are applied in order using logical clocks
  • This project is intended for educational purposes

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages