How islamhesham-dev/library-management-system works
Project Type and Purpose
• This is a full-stack MERN application—React/TypeScript frontend (“library-app”) and Node.js/Express/TypeScript backend (“library-server”)—with MongoDB as the data store. Its purpose is to provide patrons and employees a unified interface for library operations: registration, catalog browsing, check-out/check-in, and loan history tracking.
High-Level Architecture Overview
• Frontend (Client side): React app built with Vite, Redux for state management, CSS Modules for styling, and Cypress/Jest for testing.
• Backend (Server side): Express server organized in a layered MVC-style pattern—Routes → Controllers → Services → DAOs → MongoDB models—written in TypeScript. Uses middleware for validation and error handling.
• Database: MongoDB holds collections for Users, Books, LibraryCards, LoanRecords, with pagination support.
• Testing & Build tools: Cypress for end-to-end, Jest for unit tests, Vite for frontend bundling, ESLint for linting, Babel configured for transpilation.
a. User Interface Layer
• Browser/UI: React components (Pages, Features, Components)
• Redux Store: central state management, slices for auth, book, modal
• Vite Dev/Build server
b. API Layer (Backend)
• HTTP Router: Express routes (AuthRoutes, BookRoutes, etc.)
• Controllers: Handle incoming requests, call Services
• Services: Business logic and orchestration
• DAOs (Data Access Objects): Direct database operations via Mongoose or Mongo driver
• Middlewares: Validation, error handling
c. Database Layer
• MongoDB instance: collections and indexes for Users, Books, LoanRecords, LibraryCards
d. External/DevOps Tools
• Cypress runner (E2E tests)
• Jest test suites
• Optional: CI/CD pipeline (not in file tree but typical)
Relationships and Data Flows
• User clicks → React UI component dispatches Redux action → thunk/middleware triggers HTTP request → Express route receives request → Validation middleware → Controller → Service layer → DAO performs CRUD on MongoDB → Response bubbles up (DAO → Service → Controller → Express → frontend) → Redux updates store → UI re-renders.
• E2E tests simulate browser interactions; Jest tests cover unit logic on either side.
Architectural Patterns and Principles
• Frontend: Feature-based folder structure, component composition, unidirectional data flow (Redux).
• Backend: Layered architecture (Routes → Controllers → Services → DAOs → Database), separation of concerns, middleware chaining, TypeScript interfaces/models.
• RESTful API design, clear segregation of read/write operations, pagination support via a Pagination model.
Technologies & Frameworks
• Frontend: React, Redux Toolkit, Vite, TypeScript, CSS Modules, Cypress, Jest.
• Backend: Node.js, Express, TypeScript, Mongoose or MongoDB driver, Jest.
• Database: MongoDB.