# yaranasserr/advanced-library-management-system-with-django- architecture

> Architecture diagram of the GitHub repository yaranasserr/advanced-library-management-system-with-django-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yaranasserr/advanced-library-management-system-with-django-
- Repository: https://github.com/yaranasserr/advanced-library-management-system-with-django-

## Overview

This project is an Advanced Library Management System built with Django that encompasses multiple interrelated apps (users, books, authors, borrow, notifications, and library), each addressing a distinct domain of the overall system. In addition to the Django web application, the project utilizes several auxiliary components (Celery for asynchronous processing, Redis as the broker for Celery tasks, Mailhog for email testing, Swagger for API documentation, geopy for distance calculations, and Docker for containerization).

##### Main Components
- Web Application Layer: The core Django application, which hosts six apps:
- Users (authentication, registration, password recovery)
- Books and Authors (listing and filtering of books and authors, including a special endpoint to load detailed author-book data)
- Borrow (borrowing transactions, rules, and penalty calculations)
- Library (management of library details including location and filtering by category)
- Notifications (email notifications, confirmation emails, daily reminders using Celery)
- Asynchronous Task Layer: Celery, with its beat scheduler and worker processes, handling email reminders and other background tasks.
- Database: The SQLite database (and the logical database design visible via the provided schema) which stores all data including users, books, etc.
- External Services & Deployment Tools:
- Redis: Acting as the message broker for Celery.
- Mailhog: Simulating the email service.
- Swagger: Provided as API documentation for ease of integration and testing.
- Docker & Docker Compose: Used for containerizing the application and its dependent services.

##### Interactions and Relationships
- How the client (user’s browser) interacts with the Django application through HTTP requests/responses.
- Within Django, illustrate how different apps (users, books, authors, etc.) are organized, and how they connect through defined URL configurations and views.
- Data flow between Django and the Database.
- Present the asynchronous communication: the Django app dispatches tasks to Celery workers via Redis, which then processes tasks like sending emails using Mailhog.
- Integration points like the Swagger API documentation endpoint.

##### Architectural Patterns
- Modular Structure: Each Django app encapsulates a specific domain responsibility.
- Separation of Concerns: Clear boundaries between web request handling, business logic (inside models and views), and background task management (using Celery).
- Containerization: Emphasize Docker as the platform for deployment, managing services (Django app, Redis, Celery, Mailhog) in isolated containers.
- Use of asynchronous task processing for email notifications and reminders to ensure scalability and responsiveness.

- Use clear labels for each component node (e.g., “Django Application” with sub-components “Users”, “Books”, “Borrow”, etc.).
- Client → Web Application (HTTP Requests)
- Web Application → Database (CRUD Operations)
- Web Application → Celery (Task Dispatch via Redis)
- Celery Worker → Mailhog (Email Notifications)
- Incorporate Docker Compose and container symbols to denote service boundaries.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Client
    Client("Client Browser"):::frontend

    %% Containerized Environment (Docker Compose)
    subgraph "Containerized Environment (Docker Compose)"
        Django("Django Application"):::backend

        subgraph "Django Apps"
            Users("Users App"):::app
            Books("Books App"):::app
            Authors("Authors App"):::app
            Borrow("Borrow App"):::app
            LibraryApp("Library App"):::app
            Notifications("Notifications App"):::app
        end

        DB("SQLite Database"):::db

        Celery("Celery (Worker)"):::celery
        CeleryBeat("Celery Beat (Schedule)"):::celery

        Redis("Redis (Broker)"):::external
        Mailhog("Mailhog (Email Test)"):::external
        Swagger("Swagger API Doc"):::external
    end

    %% Interactions
    Client -->|"HTTP_Request"| Django
    Django -->|"Loads"| Users
    Django -->|"Loads"| Books
    Django -->|"Loads"| Authors
    Django -->|"Loads"| Borrow
    Django -->|"Loads"| LibraryApp
    Django -->|"Loads"| Notifications
    Django -->|"CRUD"| DB
    Django -->|"Dispatch_Task"| Celery
    Celery -->|"Schedules"| CeleryBeat
    Celery -->|"Uses"| Redis
    Celery -->|"Sends_Email"| Mailhog
    Client -->|"View_API"| Swagger

    %% Click Events for Component Mappings
    click Users "https://github.com/yaranasserr/advanced-library-management-system-with-django-/tree/main/LibrarySystem/librarysystem/users"
    click Books "https://github.com/yaranasserr/advanced-library-management-system-with-django-/tree/main/LibrarySystem/librarysystem/books"
    click Authors "https://github.com/yaranasserr/advanced-library-management-system-with-django-/tree/main/LibrarySystem/librarysystem/authors"
    click Borrow "https://github.com/yaranasserr/advanced-library-management-system-with-django-/tree/main/LibrarySystem/librarysystem/borrow"
    click LibraryApp "https://github.com/yaranasserr/advanced-library-management-system-with-django-/tree/main/LibrarySystem/librarysystem/library"
    click Notifications "https://github.com/yaranasserr/advanced-library-management-system-with-django-/tree/main/LibrarySystem/librarysystem/notifications"
    click Celery "https://github.com/yaranasserr/advanced-library-management-system-with-django-/blob/main/LibrarySystem/librarysystem/librarysystem/celery.py"
    click CeleryBeat "https://github.com/yaranasserr/advanced-library-management-system-with-django-/tree/main/LibrarySystem/librarysystem/celerybeat-schedule"
    click DB "https://github.com/yaranasserr/advanced-library-management-system-with-django-/blob/main/LibrarySystem/librarysystem/db.sqlite3"

    %% Styles
    classDef app fill:#D5E8D4,stroke:#82B366,stroke-width:2px;
    classDef db fill:#F8CECC,stroke:#B85450,stroke-width:2px;
    classDef celery fill:#FFF2CC,stroke:#D6B656,stroke-width:2px;
    classDef external fill:#DDEBF7,stroke:#6D9EEB,stroke-width:2px;
    classDef frontend fill:#FCE5CD,stroke:#E69138,stroke-width:2px;
    classDef backend fill:#E2EFDA,stroke:#3C763D,stroke-width:2px;
```
