How sirknightthebrave/projetogestaobiblioteca works
Project type and purpose
• This is a C# console‐based library management application (“ProjetoGestaoBiblioteca”) that persists data in a MySQL database.
• It follows an object‐oriented design with separate concerns for UI, business logic, data access, and domain entities.
File structure
• Top‐level files:
• Program.cs – application entry point
• ConsoleUI.cs – handles command‐line user interactions
• DBContext.cs – data‐access layer using MySQL.Data
• *.cs domain entity files (Book.cs, Copy.cs, CopyCondition.cs, Library.cs, User.cs)
• UserFactory.cs – implements a factory pattern to instantiate different user types
• Utils.cs – utility/helper methods
• SQL folder: contains schema creation (library_management.sql) and seed scripts (populate.sql).
• ProjectoGestaoBiblioteca.csproj/.sln – project and solution definitions.
README for additional insights
• MySQL.Data NuGet package is required for DB connectivity.
• Two user roles (admin & user) planned.
• Passwords are encrypted.
• Persistence layer = MySQL database.
Main components
a. Console UI Layer
• ConsoleUI.cs
• Program.cs (entry point invoking UI methods)
b. Business Logic Layer
• Library.cs orchestrates operations (borrow, return, search)
• UserFactory.cs creates User instances according to role
• Utils.cs for shared helper logic
c. Data Access Layer
• DBContext.cs issues SQL queries to MySQL, maps results to domain objects
d. Domain Model
• Entities: Book, Copy, CopyCondition, User
e. MySQL Database
• “library_management” database with tables (Books, Copies, Users, etc.)
f. External Dependency
• MySQL.Data connector library
Relationships and interactions
• Program.cs → ConsoleUI: starts the application.
• ConsoleUI → Library (BLL): calls high‐level methods (AddBook, RegisterUser, etc.).
• Library → DBContext (DAL): calls CRUD operations.
• DBContext ↔ MySQL Database: executes SQL from .sql scripts.
• Library & DBContext ↔ Domain Entities: pass domain objects back and forth.
• UserFactory → creates User domain instances for Library to use.
Architectural patterns and design principles
• Layered architecture: UI → BLL → DAL → Database
• Factory pattern for User creation
• Single Responsibility: each class has a clear, narrow role
• Persistence abstraction: DBContext separates SQL logic from business rules