Skip to main content

HeroFinder Demo & Walkthrough

A lot of us have experience building web apps. When we create web apps, we get so many things by default: DI, logging, configuration. But when building console apps using templates, you get basically nothing.

Today we will look at how we take all the concepts that we get from web apps and apply them to a console app, so we end up with an enterprise style console application that allows us to find heroes who are available to help us.

Presenter

This demo showcases how to build enterprise-grade console applications with all the cross-cutting concerns we expect from modern applications. Emphasize the contrast between simple console app templates and what we can achieve with proper architecture.

Key Features We'll Explore

This console application demonstrates:

  • Command branching to group functionality (top level commands, then sub-commands like heroes list)
  • Dependency Injection using the host builder pattern
  • Structured logging with Serilog
  • Configuration management
  • Beautiful console output using Colorful.Console with ASCII art

Show Application Functionality

First, cd into the HeroFinder.Console directory:

 cd 01-Getting-Started/HeroFinder/HeroFinder.Console

Run the application and show the help menu

dotnet run

Get help for the heroes command

dotnet run heroes

Get the list of heroes

dotnet run heroes list

Call for help!

dotnet run sos

Walkthrough Code

Now let's explore the key components that make this enterprise console application work:

Program.cs - Application Bootstrap

The heart of our application setup. This is where we:

  • Display ASCII art
  • Set up the host builder (just like web applications)
  • Configure all our cross-cutting concerns: DI, logging, configuration
  • Register our command structure
var builder = CoconaApp.CreateBuilder();
Presenter

Cocona makes DI easy - feels like a web app

ASCII Art

  • Creates visual appeal and professional appearance
  • Sets the tone for a polished application experience

Configuration

  • Uses the same configuration system as web applications
  • Supports appsettings.json, environment variables, etc.
  • Fully integrated with the host builder pattern

Commands

  • Command branching organizes functionality logically
  • Top level commands for main application features
  • Sub-commands (like heroes list, heroes create) for grouped operations
  • Clean separation of concerns with individual command classes

Services

  • Full dependency injection support
  • Services registered in the container just like web apps
  • Proper separation of business logic from command handling

Models

  • Strong typing throughout the application
  • Clean data structures that support the business logic
  • Integrated with dependency injection and service layer

Key Takeaways

This demo shows how modern .NET console applications can be just as sophisticated as web applications:

  1. No more basic console templates - We can build enterprise-grade console apps
  2. Reuse web app patterns - DI, logging, configuration, structured architecture
  3. Professional UX - Beautiful output with Colorful.Console, not just plain text
  4. Maintainable code - Proper separation of concerns, testable architecture
  5. Command organization - Logical grouping of functionality with sub-commands
Presenter

Console apps don't have to be second-class citizens - With the right architecture, they can be just as maintainable and feature-rich as any web application.