# gaitan19/borrowingsystemapi architecture

> Architecture diagram of the GitHub repository gaitan19/borrowingsystemapi, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gaitan19/borrowingsystemapi
- Repository: https://github.com/gaitan19/borrowingsystemapi

## Overview

##### Project Overview
- This is a RESTful API (“BorrowingSystemAPI”) built on .NET 7 / C# for managing item‐borrowing workflows.
- Core capabilities include user authentication (JWT), item management, loan/renewal/return flows, role‐based access control (Admin vs. regular User), and reporting.

- Communicate, at a high level, the interactions between external actors (end users, admins, external systems) and the API’s primary functions.
- System scope: what the Borrowing System offers and who uses each feature.

##### Actors
- “Guest” (unauthenticated user – can register, log in)
- “User” (authenticated borrower – can view items, create borrowing requests, view their history)
- “Admin” (role with extra privileges – can manage items, manage users, approve/reject requests, view reports)

##### Use Cases (ellipses inside the system boundary)
a. Authentication & User Management
- Register
- Log In (obtain JWT)
- Log Out (invalidate token or client‐side discard)
- Manage Profile (update user info)
b. Item & Catalog Management
- View Available Items
- (Admin) Create / Update / Delete Item
c. Borrowing Workflow
- Create Borrowing Request
- View Own Requests (status: pending, approved, rejected)
- (Admin) Approve / Reject Request
- View Loaned Items
- Renew Loan
- Return Item
d. Reporting & Auditing
- View Overdue Items Report
- View User Borrowing History
- (Admin) Generate System Reports
e. Movement & MovementType (audit trails)
- Log Movement (automatic on any state change)

##### System Boundary
- Use-case ellipses inside this rectangle; actors outside.

##### Relationships & Notes
- Associate lines between each actor and the use cases they invoke.
- Guest → Register, Log In
- User → View Available Items, Create Borrowing Request, View Own Requests, Renew Loan, Return Item
- Admin → All user use cases + Create/Update/Delete Item, Approve/Reject Request, Generate Reports, Manage Users
- Use «include» or «extend» relationships for cross‐cutting concerns:
- Every secured use case «include» Authenticate User (JWT)
- Approve/Reject Request «extend» Create Borrowing Request (optional notation)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Actors
    Guest([Guest]):::actor
    User([User]):::actor
    Admin([Admin]):::actor
    NotificationService([Notification Service]):::actor

    %% System Boundary
    subgraph "Borrowing System API"
        direction TB
        %% Authentication & User Management
        Register(("Register")):::auth
        LogIn(("Log In")):::auth
        LogOut(("Log Out")):::auth
        ManageProfile(("Manage Profile")):::auth
        AuthenticateUser(("Authenticate User (JWT)")):::auth

        %% Item & Catalog Management
        ViewAvailableItems(("View Available Items")):::item
        CreateItem(("Create Item")):::item
        UpdateItem(("Update Item")):::item
        DeleteItem(("Delete Item")):::item

        %% Borrowing Workflow
        CreateBorrowRequest(("Create Borrowing Request")):::workflow
        ViewOwnRequests(("View Own Requests")):::workflow
        ApproveRejectRequest(("Approve/Reject Request")):::workflow
        ViewLoanedItems(("View Loaned Items")):::workflow
        RenewLoan(("Renew Loan")):::workflow
        ReturnItem(("Return Item")):::workflow

        %% Reporting & Auditing
        ViewOverdueReport(("View Overdue Items Report")):::report
        ViewUserHistory(("View User Borrowing History")):::report
        GenerateReports(("Generate System Reports")):::report

        %% Movement & MovementType
        LogMovement(("Log Movement")):::movement

        %% Utilities
        WeatherForecast(("WeatherForecast Utility")):::util
    end

    %% Associations
    Guest --> Register
    Guest --> LogIn

    User --> ViewAvailableItems
    User --> CreateBorrowRequest
    User --> ViewOwnRequests
    User --> RenewLoan
    User --> ReturnItem

    Admin --> ViewAvailableItems
    Admin --> CreateItem
    Admin --> UpdateItem
    Admin --> DeleteItem
    Admin --> ApproveRejectRequest
    Admin --> GenerateReports
    Admin --> ViewUserHistory
    Admin --> ManageProfile

    NotificationService --> LogMovement

    %% Include/Extend Relationships
    CreateBorrowRequest -.->|«extend» ApproveRejectRequest| ApproveRejectRequest
    ViewAvailableItems -->|"«include»"| AuthenticateUser
    CreateBorrowRequest -->|"«include»"| AuthenticateUser
    ViewOwnRequests -->|"«include»"| AuthenticateUser
    RenewLoan -->|"«include»"| AuthenticateUser
    ReturnItem -->|"«include»"| AuthenticateUser
    CreateItem -->|"«include»"| AuthenticateUser
    UpdateItem -->|"«include»"| AuthenticateUser
    DeleteItem -->|"«include»"| AuthenticateUser
    ApproveRejectRequest -->|"«include»"| AuthenticateUser
    ViewOverdueReport -->|"«include»"| AuthenticateUser
    ViewUserHistory -->|"«include»"| AuthenticateUser
    GenerateReports -->|"«include»"| AuthenticateUser

    %% Click Events
    click Register "https://github.com/gaitan19/borrowingsystemapi/blob/main/Controllers/AuthController.cs"
    click LogIn "https://github.com/gaitan19/borrowingsystemapi/blob/main/Controllers/AuthController.cs"
    click LogOut "https://github.com/gaitan19/borrowingsystemapi/blob/main/Controllers/AuthController.cs"
    click ManageProfile "https://github.com/gaitan19/borrowingsystemapi/blob/main/Controllers/UsersController.cs"

    click ViewAvailableItems "https://github.com/gaitan19/borrowingsystemapi/blob/main/Controllers/ItemsController.cs"
    click CreateItem "https://github.com/gaitan19/borrowingsystemapi/blob/main/Controllers/ItemsController.cs"
    click UpdateItem "https://github.com/gaitan19/borrowingsystemapi/blob/main/Controllers/ItemsController.cs"
    click DeleteItem "https://github.com/gaitan19/borrowingsystemapi/blob/main/Controllers/ItemsController.cs"

    click CreateBorrowRequest "https://github.com/gaitan19/borrowingsystemapi/blob/main/Controllers/RequestsController.cs"
    click ViewOwnRequests "https://github.com/gaitan19/borrowingsystemapi/blob/main/Controllers/RequestsController.cs"
    click ApproveRejectRequest "https://github.com/gaitan19/borrowingsystemapi/blob/main/Controllers/RequestsController.cs"
    click ViewLoanedItems "https://github.com/gaitan19/borrowingsystemapi/blob/main/Controllers/RequestsController.cs"
    click RenewLoan "https://github.com/gaitan19/borrowingsystemapi/blob/main/Controllers/RequestsController.cs"
    click ReturnItem "https://github.com/gaitan19/borrowingsystemapi/blob/main/Controllers/RequestsController.cs"

    click LogMovement "https://github.com/gaitan19/borrowingsystemapi/blob/main/Controllers/MovementTypesController.cs"
    click WeatherForecast "https://github.com/gaitan19/borrowingsystemapi/blob/main/Controllers/WeatherForecastController.cs"

    %% Styles
    classDef auth fill:#AED6F1,stroke:#21618C,color:#1B2631
    classDef item fill:#A9DFBF,stroke:#196F3D,color:#1B2631
    classDef workflow fill:#F9E79F,stroke:#B9770E,color:#1B2631
    classDef report fill:#D7BDE2,stroke:#6C3483,color:#1B2631
    classDef movement fill:#F5CBA7,stroke:#B9770E,color:#1B2631
    classDef util fill:#D6DBDF,stroke:#566573,color:#1B2631
    classDef actor fill:#B2BABB,stroke:#2C3E50,color:#1B2631,stroke-width:2px
```
