A professional-grade Command Line Interface (CLI) application demonstrating Clean Architecture, SOLID principles, and Relational Data Persistence. This project evolved through four intensive modules, moving from a simple script to a robust, test-verified enterprise foundation.
The goal was to build a system that is both modular and "crash-proof."
- Repository Pattern: Implemented
IRepository<T>to decouple the User Interface from data access logic. - Generics: Leveraged C# Generics with type constraints (
where T : class, IEntity) for a reusable data engine. - Defensive Layer: Developed custom Exception Middleware (e.g.,
EntityNotFoundException) and Guard Clauses to ensure application stability against invalid user inputs.
Architecture is nothing without verification. This module focused on automated testing.
- Unit Testing: Built a comprehensive suite using xUnit to verify the core CRUD lifecycle.
- Mocking: Utilized Moq to simulate the data layer, allowing for lightning-fast tests that execute in memory without touching the physical disk.
- Negative Testing: Specifically tested failure states to ensure the "Defensive Layer" correctly intercepts and reports system errors.
Refactored the application into a Service-Oriented Architecture (SOA) to achieve true loose coupling.
- Inversion of Control (IoC): Integrated
Microsoft.Extensions.DependencyInjectionto manage object lifetimes (Singleton, Scoped, and Transient). - Service Layer: Introduced a
TaskServiceto encapsulate business logic, ensuring theProgram.cs(UI) remains "thin" and focused only on user interaction. - Dependency Inversion: Removed all hard-coded dependencies, allowing the system to be highly extensible and testable.
Successfully transitioned from local JSON file storage to a professional relational database architecture using Entity Framework Core.
- Object-Relational Mapping (ORM): Implemented
AppDbContextto map C# POCO classes to a SQLite database schema, eliminating manual serialization logic. - Code-First Migrations: Managed database schema evolution using EF Core Migrations, ensuring version-controlled data structures.
- Runtime Schema Verification: Integrated
Database.EnsureCreated()to guarantee database and table existence at application startup. - Architectural Flexibility: Demonstrated the power of Dependency Injection by swapping the storage provider from JSON to SQL with zero changes required in the
TaskServiceor UI layers.
Transitioning the application from a local CLI tool to a modern, scalable RESTful Web Service.
- REST API Design: Implementing standard HTTP verbs (GET, POST, PUT, DELETE).
- Cross-Project Integration: Sharing the Domain and Logic layers between the CLI and Web API projects.
- Swagger/OpenAPI: Documenting the API endpoints for third-party consumption.
- Language: C# 13 (.NET 9)
- Data Layer: Entity Framework Core, SQLite, JSON Serialization
- Testing: xUnit, Moq, Fluent Assertions
- Patterns: SOLID Principles, Repository Pattern, Dependency Injection, Clean Architecture
- Module 1: OOP & Defensive Programming
- Module 2: Automated Unit Testing
- Module 3: Dependency Injection & Service Layers
- Module 4: SQL Database Integration (EF Core)
- Next: Module 5: ASP.NET Core Web API (RESTful Services)