How diegotrejo/libreria.modelos works
Project type and purpose
• This is a full-stack .NET solution implementing a simple library management system (“Libreria”) with:
• A RESTful backend service (Libreria.API)
• A server-rendered web UI (Libreria.MVC)
• A shared domain‐models library (Libreria.Modelos)
• An API consumer helper library (Librerria.API.Consumer)
• A test harness (Libreria.Test)
File structure
• Top-level solution (.sln) ties together five projects.
• Libreria.API
• “Controllers” expose CRUD endpoints for entities (Autores, Libros, Editoriales, Paises).
• “Data/AppDbContext” + EF Core migrations → Microsoft SQL Server.
• appsettings.json defines connection strings & environment settings.
• Libreria.MVC
• MVC Controllers & Razor Views under “Views/…” for each entity.
• References the domain models and likely calls the API via the consumer library.
• Static assets (CSS/JS) under wwwroot (Bootstrap, jQuery, validation).
• Libreria.Modelos
• Defines POCO classes for Autor, Libro, Editorial, Pais. Shared by API, MVC, Consumer, and Tests.
• Librerria.API.Consumer
• Contains CRUD.cs: a typed HttpClient wrapper to consume the REST API.
• Libreria.Test
• A console-style Program.cs; likely automates tests against the API or consumer.
README
• Minimal (“# Libreria.Modelos”).
a. Main components
• Clients (Browser / User)
• MVC Web App (Libreria.MVC)
• API Consumer Library (Librerria.API.Consumer)
• REST API Service (Libreria.API)
• Database Access (EF Core / AppDbContext / Migrations)
• SQL Server (or another RDBMS)
• Shared Domain Models (Libreria.Modelos)
• Test Harness (Libreria.Test)
b. Relationships & data flow
1. User → HTTP(S) → MVC Controllers
2. MVC Controllers → (in-process) call to API Consumer → HTTP(S) → REST API Controllers
3. REST API Controllers → AppDbContext → SQL Server
4. EF Core Migrations define DB schema; AppDbContextModelSnapshot keeps track.
5. Domain models flow bidirectionally between MVC, Consumer, API, and Tests via the shared library.
6. Test Harness uses the same Consumer/API to verify endpoints and model behavior.
c. Architectural patterns & design principles
• Layered architecture: Presentation (MVC), Application (API + Consumer), Data (EF Core).
• Separation of concerns: UI vs. business logic vs. persistence.
• Shared kernel: domain models in Libreria.Modelos to avoid duplication.
• Single Responsibility: each project handles one responsibility.
• Dependency Injection: built-in .NET Core DI in Program.cs (API & MVC).
d. Key technologies & frameworks
• .NET 8 (or .NET 7+) ASP.NET Core MVC & Web API
• Entity Framework Core + Migrations
• Razor Views, Bootstrap, jQuery (client-side)
• HttpClient wrapper in Consumer library
• Visual Studio solution (.sln), .csproj per project
Details
• Migrations folder and ModelSnapshot as part of the persistence sub-component.
• LaunchSettings.json to indicate local vs. production URLs if desired.