- Überblick
- Technologien
- Architektur
- Spielmechanik
- Features
- Screenshots
- Installation & Ausführung
- Projektstruktur
- Testing
- Entwickler-Highlights
The Middleman Simulator ist eine umfassende Business-Simulationsanwendung, die in C# mit .NET 8.0 entwickelt wurde. Das Projekt demonstriert fortgeschrittene Softwareentwicklungspraktiken und objektorientiertes Design im Kontext einer Echtzeit-Marktsimulation.
Eine vollständige Wirtschaftssimulation, in der mehrere Spieler (Zwischenhändler) auf einem virtuellen Agrarmarkt konkurrieren. Spieler müssen Ressourcen verwalten, strategische Entscheidungen treffen und ihre finanzielle Position über eine festgelegte Zeitperiode optimieren.
Spieler übernehmen die Rolle von Zwischenhändlern, die:
- 📦 Agrarprodukte kaufen, verkaufen und lagern
- 💰 Finanzkonten und Budgets verwalten
- 🏭 Lagerkapazitäten und Lagerkosten optimieren
- 💳 Kredite mit Zinssätzen managen
- 📈 Marktdynamik und Produktverfügbarkeit analysieren
- 🤖 Gegen KI-gesteuerte Konkurrenten antreten
- .NET 8.0 - Neueste .NET Runtime-Version
- C# 11+ - Moderne Sprachfeatures (implicit usings, nullable reference types)
- Spectre.Console v0.48.0 - Rich Console UI mit formatierten Tabellen, Panels und farbiger Ausgabe
├── Spectre.Console v0.48.0 → Rich Terminal UI
├── NUnit v4.0.1 → Unit Testing Framework
├── Moq v4.20.70 → Mocking Library
├── Microsoft.NET.Test.SDK v17.8.0 → Test Infrastructure
- Strict Null Checking aktiviert
- YAML-Konfiguration für Produktdaten
- Dependency Injection Pattern
- Repository Pattern für Datenzugriff
- Custom Exception Handling
Das Projekt folgt einer sauberen, mehrschichtigen Architektur mit klarer Trennung der Verantwortlichkeiten:
Abstraktion der Datenzugriffsschicht für lose Kopplung
IProductRepository → ProductRepository
IMiddlemanRepository → MiddlemanRepositoryGeschäftslogik in dedizierten Services
MarketService → Tägliche Simulation & Marktmechanik
MiddlemanService → Händler-Operationen (Kauf/Verkauf/Kredite)
ProductService → Produktverwaltung & UpdatesServices werden über Konstruktor-Injektion bereitgestellt
Spezifische Ausnahmen für Fehlerbehandlung:
InsufficientFundsExceptionWarehouseCapacityExceededExceptionProductNotAvailableExceptionProductNotFoundExceptionLoanAlreadyExistsExceptionUserInputException
Aktions-Delegates für UI-Updates und Event-Handling
- Konfiguration der Simulationsdauer (Anzahl der Tage)
- Erstellung mehrerer Zwischenhändler mit:
- Name und Firmenname
- Startkapital (initiales Kontostand)
- Standard-Lagerkapazität: 100 Einheiten
Jeder Spieltag umfasst:
- Produkt-Updates - Verfügbarkeit und Preise schwanken basierend auf Produktionsraten
- Lagerkostenabzug - Spieler zahlen für Lagerraum (belegt + leer)
- Kreditzins-Verarbeitung - Fällige Kredite werden zwangsweise zurückgezahlt
- Spieler-Aktionen - Jeder Spieler kann:
- 🛒 Einkaufen - Produkte vom Markt kaufen
- 💵 Verkaufen - Produkte an Kunden verkaufen
- 📦 Lager vergrößern - Lagerkapazität erweitern
- 💳 Kredit aufnehmen - Finanzielle Mittel leihen
- ⏭️ Runde beenden - Zum nächsten Tag übergehen
10 Agrarprodukte mit unterschiedlichen Eigenschaften (aus produkte.yml):
| Produkt | Haltbarkeit | Basispreis |
|---|---|---|
| 🥒 Gurke | 21 Tage | €5.00 |
| 🍑 Aprikose | 4 Tage | €6.00 |
| 🍅 Tomate | 10 Tage | €7.00 |
| 🥔 Kartoffel | 30 Tage | €3.00 |
| 🧅 Zwiebel | 40 Tage | €2.00 |
| 🥕 Karotte | 20 Tage | €4.00 |
| 🍎 Apfel | 14 Tage | €6.00 |
| 🍌 Banane | 7 Tage | €8.00 |
| 🧃 Orangensaft | 5 Tage | €12.00 |
| 🥛 Milch | 3 Tage | €8.00 |
- Basispreis - Festgelegt für jedes Produkt
- Einkaufspreis - Berechnet mit Marktschwankungen
- Verkaufspreis - 80% des Basispreises (Gewinnmarge)
- Rabattstufen - Mengenbasierte Rabatte beim Einkauf:
- 25+ Einheiten: 2% Rabatt
- 50+ Einheiten: 5% Rabatt
- 75+ Einheiten: 10% Rabatt
- Lagerkosten - 5€ pro belegter Einheit + 1€ pro leerer Einheit täglich
- Lagererweiterung - 50€ pro Einheit Kapazitätserweiterung
- Kredite - 7-tägige Rückzahlungsfrist mit konfigurierbaren Zinssätzen
- Konkurs - Spiel endet für Spieler bei Kontostand ≤ 0
- ⏰ Simulationsdauer abgelaufen
- 💸 Alle Spieler bankrott
- 🏆 Gewinner nach finalem Kontostand gerankt
- 📊 Formatierte Tabellen für Produktlisten
- 📈 Visuelle Balkendiagramme für Lagerverteilung
- 🎨 Farbcodierte Ausgaben für bessere Lesbarkeit
- 📋 Strukturierte Panels für Tagesberichte
- ✅ Interaktive Menüs und Eingabeaufforderungen
- Produkte mit variabler Verfügbarkeit
- Preisschwankungen basierend auf Angebot
- Verderbliche Waren mit Haltbarkeitsdatum
- Mengenrabatte für Großeinkäufe
- Detaillierte Ausgabenverfolgung
- Kreditsystem mit Zinsen
- Automatische Lagerkostenberechnung
- Konkursmechanik
- Multiple KI-gesteuerte Händler
- Automatisierte Handelsentscheidungen
- Wettbewerbsbasiertes Ranking-System
- Externe Produktdefinitionen
- Einfache Erweiterbarkeit
- Datentrennung vom Code
Konfiguration der Simulation mit mehreren Spielern und Firmen
Detaillierte Übersicht über Finanzen und Ausgaben
Produktverkauf mit visueller Lagerverteilung
Endgültige Platzierung nach Kontostand
- .NET 8.0 SDK oder höher
- Windows, macOS oder Linux
- Terminal/Konsole mit Unicode-Unterstützung
# Repository klonen
git clone https://gitlab.myfesko.com/docker/middlemen-simulator.git
cd middlemen-simulator
# Dependencies wiederherstellen
dotnet restore
# Projekt bauen
dotnet build
# Anwendung ausführen
dotnet run --project TheMiddleman/TheMiddleman.csprojcd TheMiddleman/bin/Debug/net8.0
./TheMiddlemanmiddlemen-simulator/
├── TheMiddleman/ # Hauptanwendung
│ ├── Entities/ # Datenmodelle
│ │ ├── Middleman.cs # Händler-Entity
│ │ ├── Product.cs # Produkt-Entity
│ │ └── Loan.cs # Kredit-Entity
│ │
│ ├── business_logic/ # Geschäftslogik
│ │ ├── MarketService.cs # Marktsimulation
│ │ ├── MiddlemanService.cs # Händler-Operationen
│ │ └── ProductService.cs # Produktverwaltung
│ │
│ ├── data_access/ # Repository Pattern
│ │ ├── IProductRepository.cs # Produkt-Interface
│ │ ├── ProductRepository.cs # Produkt-Implementierung
│ │ ├── IMiddlemanRepository.cs # Händler-Interface
│ │ └── MiddlemanRepository.cs # Händler-Implementierung
│ │
│ ├── exceptions/ # Custom Exceptions
│ │ ├── InsufficientFundsException.cs
│ │ ├── WarehouseCapacityExceededException.cs
│ │ ├── ProductNotAvailableException.cs
│ │ ├── ProductNotFoundException.cs
│ │ ├── LoanAlreadyExistsException.cs
│ │ └── UserInputException.cs
│ │
│ ├── user_interface/ # UI-Layer
│ │ └── ConsoleUI.cs # Spectre.Console UI
│ │
│ ├── Utils/ # Hilfsfunktionen
│ │ └── CurrencyFormatter.cs # Währungsformatierung
│ │
│ ├── tests/ # Unit Tests
│ │ ├── ProductServiceTests.cs
│ │ └── MiddlemanServiceTests.cs
│ │
│ ├── Game.cs # Spiel-Orchestrator
│ ├── MainRunner.cs # Entry Point
│ ├── produkte.yml # Produktkonfiguration
│ └── TheMiddleman.csproj # Projektdatei
│
├── img/ # Dokumentation & Screenshots
│ ├── screenshot1.png - screenshot11.png
│
├── TheMiddleman.sln # Visual Studio Solution
├── README.md # Diese Datei
└── .gitignore # Git-Konfiguration
Das Projekt verwendet NUnit 4.0.1 und Moq 4.20.70 für umfassendes Testing:
# Alle Tests ausführen
dotnet test
# Tests mit detaillierter Ausgabe
dotnet test --verbosity detailed- ✅ ProductService Unit Tests
- ✅ MiddlemanService Unit Tests
- ✅ Mock-basierte Repository Tests
- ✅ Exception Handling Tests
- Strikte Trennung von Concerns (UI, Business Logic, Data Access)
- SOLID-Prinzipien konsequent angewandt
- Dependency Injection für testbare und wartbare Codebase
- Nullable Reference Types für erhöhte Typsicherheit
- Implicit Usings für reduzierten Boilerplate
- Pattern Matching und moderne Sprachkonstrukte
- Rich Terminal UI mit Spectre.Console
- Informative Visualisierungen (Tabellen, Charts)
- Benutzerfreundliche Menüführung
- Custom Exception-Framework
- Spezifische Fehlerbehandlung für jeden Geschäftsfall
- Benutzerfreundliche Fehlermeldungen
- YAML-basierte Produktkonfiguration
- Externe Datenverwaltung
- Leicht erweiterbar ohne Code-Änderungen
- Unit Tests mit NUnit
- Mocking mit Moq
- Testbare Architektur durch DI
- Multi-Spieler Simulation
- Finanzielle Berechnungen
- Marktdynamik und Preisfindung
- Zeitbasierte Mechaniken (Haltbarkeit, Kreditzinsen)
- ✅ .NET 8.0 / C# 11+ Entwicklung
- ✅ Objektorientierte Programmierung (OOP)
- ✅ Design Patterns (Repository, Service Layer, DI)
- ✅ SOLID-Prinzipien
- ✅ Exception Handling
- ✅ Unit Testing (NUnit, Moq)
- ✅ YAML-Konfiguration
- ✅ Console Application Development
- ✅ Algorithmisches Denken
- ✅ Software-Architektur
- ✅ Code-Organisation und -Struktur
- ✅ Third-Party Library Integration (Spectre.Console)
Dieses Projekt wurde als Demonstrationsprojekt für Portfolio-Zwecke entwickelt und zeigt fortgeschrittene C#/.NET-Entwicklungsfähigkeiten.
Repository: https://gitlab.myfesko.com/docker/middlemen-simulator
- Overview
- Technologies
- Architecture
- Game Mechanics
- Features
- Screenshots
- Installation & Running
- Project Structure
- Testing
- Developer Highlights
The Middleman Simulator is a comprehensive business simulation application developed in C# with .NET 8.0. The project demonstrates advanced software development practices and object-oriented design in the context of a real-time market simulation.
A complete economic simulation where multiple players (middlemen/traders) compete in a virtual agricultural market. Players must manage resources, make strategic decisions, and optimize their financial position over a defined time period.
Players take on the role of middlemen who:
- 📦 Buy, sell, and store agricultural products
- 💰 Manage financial accounts and budgets
- 🏭 Optimize warehouse capacity and storage costs
- 💳 Handle loans with interest rates
- 📈 Analyze market dynamics and product availability
- 🤖 Compete against AI-driven opponents
- .NET 8.0 - Latest .NET Runtime version
- C# 11+ - Modern language features (implicit usings, nullable reference types)
- Spectre.Console v0.48.0 - Rich Console UI with formatted tables, panels, and colored output
├── Spectre.Console v0.48.0 → Rich Terminal UI
├── NUnit v4.0.1 → Unit Testing Framework
├── Moq v4.20.70 → Mocking Library
├── Microsoft.NET.Test.SDK v17.8.0 → Test Infrastructure
- Strict Null Checking enabled
- YAML Configuration for product data
- Dependency Injection pattern
- Repository Pattern for data access
- Custom Exception Handling
The project follows a clean, multi-layered architecture with clear separation of concerns:
Data access layer abstraction for loose coupling
IProductRepository → ProductRepository
IMiddlemanRepository → MiddlemanRepositoryBusiness logic in dedicated services
MarketService → Daily simulation & market mechanics
MiddlemanService → Trader operations (buy/sell/loans)
ProductService → Product management & updatesServices provided via constructor injection
Specific exceptions for error handling:
InsufficientFundsExceptionWarehouseCapacityExceededExceptionProductNotAvailableExceptionProductNotFoundExceptionLoanAlreadyExistsExceptionUserInputException
Action delegates for UI updates and event handling
- Configure simulation duration (number of days)
- Create multiple middlemen with:
- Name and company name
- Starting capital (initial account balance)
- Default warehouse capacity: 100 units
Each game day includes:
- Product Updates - Availability and pricing fluctuate based on production rates
- Storage Cost Deduction - Players pay for warehouse space (occupied + empty)
- Loan Interest Processing - Due loans are enforced for repayment
- Player Actions - Each player can:
- 🛒 Buy - Purchase products from the market
- 💵 Sell - Sell products to customers
- 📦 Expand Warehouse - Increase storage capacity
- 💳 Take Loan - Borrow financial resources
- ⏭️ End Round - Proceed to the next day
10 agricultural products with varying characteristics (from produkte.yml):
| Product | Durability | Base Price |
|---|---|---|
| 🥒 Cucumber | 21 days | €5.00 |
| 🍑 Apricot | 4 days | €6.00 |
| 🍅 Tomato | 10 days | €7.00 |
| 🥔 Potato | 30 days | €3.00 |
| 🧅 Onion | 40 days | €2.00 |
| 🥕 Carrot | 20 days | €4.00 |
| 🍎 Apple | 14 days | €6.00 |
| 🍌 Banana | 7 days | €8.00 |
| 🧃 Orange Juice | 5 days | €12.00 |
| 🥛 Milk | 3 days | €8.00 |
- Base Price - Set for each product
- Purchase Price - Calculated with market fluctuations
- Selling Price - 80% of base price (profit margin)
- Discount Tiers - Volume-based discounts on purchases:
- 25+ units: 2% discount
- 50+ units: 5% discount
- 75+ units: 10% discount
- Storage Costs - €5 per occupied unit + €1 per empty unit daily
- Warehouse Expansion - €50 per unit capacity increase
- Loans - 7-day repayment period with configurable interest rates
- Bankruptcy - Game ends for player when balance ≤ 0
- ⏰ Simulation duration expires
- 💸 All players bankrupt
- 🏆 Winners ranked by final account balance
- 📊 Formatted tables for product listings
- 📈 Visual bar charts for warehouse distribution
- 🎨 Color-coded outputs for better readability
- 📋 Structured panels for daily reports
- ✅ Interactive menus and prompts
- Products with variable availability
- Price fluctuations based on supply
- Perishable goods with expiration dates
- Volume discounts for bulk purchases
- Detailed expense tracking
- Loan system with interest
- Automatic storage cost calculation
- Bankruptcy mechanics
- Multiple AI-driven traders
- Automated trading decisions
- Competition-based ranking system
- External product definitions
- Easy extensibility
- Data separation from code
Simulation configuration with multiple players and companies
Detailed overview of finances and expenses
Product sales with visual warehouse distribution
Final rankings by account balance
- .NET 8.0 SDK or higher
- Windows, macOS, or Linux
- Terminal/Console with Unicode support
# Clone repository
git clone https://gitlab.myfesko.com/docker/middlemen-simulator.git
cd middlemen-simulator
# Restore dependencies
dotnet restore
# Build project
dotnet build
# Run application
dotnet run --project TheMiddleman/TheMiddleman.csprojcd TheMiddleman/bin/Debug/net8.0
./TheMiddlemanmiddlemen-simulator/
├── TheMiddleman/ # Main application
│ ├── Entities/ # Data models
│ │ ├── Middleman.cs # Trader entity
│ │ ├── Product.cs # Product entity
│ │ └── Loan.cs # Loan entity
│ │
│ ├── business_logic/ # Business logic
│ │ ├── MarketService.cs # Market simulation
│ │ ├── MiddlemanService.cs # Trader operations
│ │ └── ProductService.cs # Product management
│ │
│ ├── data_access/ # Repository pattern
│ │ ├── IProductRepository.cs # Product interface
│ │ ├── ProductRepository.cs # Product implementation
│ │ ├── IMiddlemanRepository.cs # Trader interface
│ │ └── MiddlemanRepository.cs # Trader implementation
│ │
│ ├── exceptions/ # Custom exceptions
│ │ ├── InsufficientFundsException.cs
│ │ ├── WarehouseCapacityExceededException.cs
│ │ ├── ProductNotAvailableException.cs
│ │ ├── ProductNotFoundException.cs
│ │ ├── LoanAlreadyExistsException.cs
│ │ └── UserInputException.cs
│ │
│ ├── user_interface/ # UI layer
│ │ └── ConsoleUI.cs # Spectre.Console UI
│ │
│ ├── Utils/ # Utility functions
│ │ └── CurrencyFormatter.cs # Currency formatting
│ │
│ ├── tests/ # Unit tests
│ │ ├── ProductServiceTests.cs
│ │ └── MiddlemanServiceTests.cs
│ │
│ ├── Game.cs # Game orchestrator
│ ├── MainRunner.cs # Entry point
│ ├── produkte.yml # Product configuration
│ └── TheMiddleman.csproj # Project file
│
├── img/ # Documentation & screenshots
│ ├── screenshot1.png - screenshot11.png
│
├── TheMiddleman.sln # Visual Studio solution
├── README.md # This file
└── .gitignore # Git configuration
The project uses NUnit 4.0.1 and Moq 4.20.70 for comprehensive testing:
# Run all tests
dotnet test
# Run tests with detailed output
dotnet test --verbosity detailed- ✅ ProductService Unit Tests
- ✅ MiddlemanService Unit Tests
- ✅ Mock-based Repository Tests
- ✅ Exception Handling Tests
- Strict separation of concerns (UI, Business Logic, Data Access)
- SOLID principles consistently applied
- Dependency Injection for testable and maintainable codebase
- Nullable Reference Types for increased type safety
- Implicit Usings for reduced boilerplate
- Pattern Matching and modern language constructs
- Rich Terminal UI with Spectre.Console
- Informative visualizations (tables, charts)
- User-friendly menu navigation
- Custom exception framework
- Specific error handling for each business case
- User-friendly error messages
- YAML-based product configuration
- External data management
- Easily extensible without code changes
- Unit tests with NUnit
- Mocking with Moq
- Testable architecture through DI
- Multi-player simulation
- Financial calculations
- Market dynamics and price discovery
- Time-based mechanics (expiration, loan interest)
- ✅ .NET 8.0 / C# 11+ Development
- ✅ Object-Oriented Programming (OOP)
- ✅ Design Patterns (Repository, Service Layer, DI)
- ✅ SOLID Principles
- ✅ Exception Handling
- ✅ Unit Testing (NUnit, Moq)
- ✅ YAML Configuration
- ✅ Console Application Development
- ✅ Algorithmic Thinking
- ✅ Software Architecture
- ✅ Code Organization and Structure
- ✅ Third-Party Library Integration (Spectre.Console)
This project was developed as a demonstration project for portfolio purposes and showcases advanced C#/.NET development skills.
Repository: https://gitlab.myfesko.com/docker/middlemen-simulator



