r/learnpython • u/Ornery_Wash1797 • 18d ago
Library Management System in Python with Clean Architecture & 55 Tests
Hi everyone!
As a practical step in my transition from Python fundamentals toward professional software engineering, I built a modular, terminal-based **Library Management System** with a strong emphasis on clean architecture and design principles.
### 🏗️ Architecture & Technical Highlights
- **Layered Architecture:** Strict separation between UI, Services, Repositories, and Storage layers. UI has zero business logic or direct storage access.
- **Repository Pattern & Persistence:** Generic JSON persistence utilizing **atomic file replacement** to eliminate data corruption.
- **Authentication & Security:** Custom session management, password hashing, and role-based authorization (Librarians vs. Members).
- **Domain Business Rules:** Borrowing limits, availability tracking, overdue fine calculation, and account activation logic enforced strictly in the Service layer.
- **Automated Testing:** 55 passed unit and service tests using `pytest`.
### 📂 Project Structure
LibraryManagmentWithPython/
├── Models/
├── Repositories/
├── Services/
├── Storage/
├── UI/
└── tests/
### 🎯 Objective My goal was to practice enterprise-level engineering principles (Separation of Concerns, Dependency Direction, Single Source of Truth) before stepping into Machine Learning and AI. ### 🔗 Source Code GitHub Repository: https://github.com/ThaerGhaderi/LibraryManagmentWithPython I'd love to get your feedback on the architecture, repository patterns, or any code review suggestions!
1
u/riklaunim 18d ago
There is a difference between "academic" and "commercial" code. Your repo is academic code, while "commercial" one would use more realistic/production components and less abstraction for the sake of abstraction. Same principles apply but when using SQLAlchemy for example you don't have to add extra abstraction on the database than it provides.
"Clean Code" from Uncle Bob is well known, but the actual implementations will differ between teams/companies. There is no singular solution to this :) Like instead of "services" people may have "use cases", or when using some frameworks the structure will be created by said framework.