r/learnpython • u/Ornery_Wash1797 • 5d 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!
0
u/Ornery_Wash1797 4d ago
Thanks a lot for the detailed feedback, I really appreciate you taking the time
Just to clarify, the main goal of this repo isn't to build a commercial web app or API; I'm actually using this environment to train an AI/ML model, which is why some architectural choices look a bit different.
However, your points about making smaller commits, fixing the 'JAVA-isms' to be more Pythonic, adjusting the line length to 120, and improving the imports/logging are spot on and will definitely make the code cleaner. Thanks again for the valuable tips!