# rukayaafrin/inventory_management_system_using_spring_boot architecture

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

- Interactive diagram: https://gitdiagram.com/rukayaafrin/inventory_management_system_using_spring_boot
- Repository: https://github.com/rukayaafrin/inventory_management_system_using_spring_boot

## Overview

##### Project Type and Purpose
- This is a full-stack Java web application built with Spring Boot.
- Purpose: an Inventory Management System with user roles (Admin, Mechanic, Supplier), product/catalogue management, stock usage reporting, and email notifications.

##### File Structure Analysis
- src/main/java/com/team9/motors:
- controller – HTTP entry points (AdminController, ProductController, etc.)
- service – business logic implementations (CatalogueImplementation, ProductImplementation, etc.)
- repository – Spring Data JPA interfaces for CRUD (ProductRepository, InventoryRepository, etc.)
- model – JPA entity classes (Product, Inventory, User, StockUsage, Supplier, etc.) and supporting classes (DateSelector, Role)
- springSecurity – authentication & authorization (SecurityConfiguration, MainUser)
- mail – email utility (JavaMailUtil)
- interfacemethods – defines service contracts (CatalogueInterface, UserInterface, etc.)
- src/main/resources:
- application.properties – DB connection/config
- CreateUser.sql – initial data load script
- static – CSS/JS/fonts/images served to the client
- templates – Thymeleaf HTML views organized into layouts & pages
- Tests: JUnit tests under src/test for application and data bootstrap.
- Build and packaging via Maven (pom.xml) with embedded Tomcat.

##### README Insights
- Uses MySQL (“team9” schema).
- Generates reports to disk paths configured in service classes.
- Spring Boot run with embedded server.
- JUnit test bootstraps sample data.

a. Main Components
- Client Browser with HTML/CSS/JS (Thymeleaf-rendered views)
- Spring Boot Application
– Presentation Layer (Controllers + Thymeleaf)
– Service Layer (Catalogue, Product, Inventory, Supplier, User, StockUsage logic)
– Data Access Layer (Spring Data JPA Repositories)
– Security Module (Spring Security)
– Mail Module (JavaMailUtil)
- MySQL Database (“team9” schema)
- File System (for report files)
- External SMTP Server (for email notifications)
b. Relationships & Interactions
1. User browser sends HTTP request → Controller
2. Controller invokes Service via interface → applies business rules
3. Service calls Repository → executes SQL on MySQL
4. Service may write report file to disk or send email via JavaMailUtil → SMTP
5. Controller returns model + Thymeleaf template → rendered HTML to client
6. Spring Security intercepts requests → enforces authentication/authorization
c. Architectural Patterns & Principles
- Layered (MVC + Service + Repository)
- Dependency Injection (Spring Beans)
- Convention-over-Configuration (Spring Boot auto-config)
- Interface-driven design (services defined by interfaces)
- Template layout (Thymeleaf reusable layout files)
d. Key Technologies/Frameworks
- Spring Boot (web starter, security, data-jpa)
- Thymeleaf templates
- Spring Data JPA (Hibernate)
- MySQL
- JavaMail (for notifications)
- Maven

##### Detail Level
- Drill down controllers by logical modules (UserMgmt, ProductMgmt, Inventory, Reporting).
- Interfaces between layers.
- Security filter chain intercepting HTTP requests before controllers.
- Where static resources are served (directly by Spring’s resource handler).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    Client["Browser\n(HTML/CSS/JS)"]:::external

    %% Spring Boot Application Boundary
    subgraph "Spring Boot Application"
        direction TB

        %% Security Module
        Security["Spring Security\n(SecurityConfiguration, MainUser)"]:::security

        %% Web Layer
        subgraph "Web Layer"
            direction TB
            Controllers["Controllers\n(AdminController, ProductController, etc.)"]:::frontend
            Templates["Thymeleaf Templates\n(layouts & pages)"]:::frontend
            StaticAssets["Static Assets\n(CSS/JS/Images)"]:::frontend
        end

        %% Service Layer
        subgraph "Service Layer"
            direction TB
            Interfaces["Service Interfaces\n(CatalogueInterface, UserInterface, etc.)"]:::service
            Services["Service Implementations\n(CatalogueImpl, ProductImpl, etc.)"]:::service
        end

        %% Data Access Layer
        subgraph "Data Access Layer"
            direction TB
            Repositories["Repositories\n(ProductRepo, InventoryRepo, etc.)"]:::repository
        end

        %% Domain Model
        Model["Domain Models\n(JPA Entities & Supporting Classes)"]:::model

        %% Mail Module
        Mail["Mail Module\n(JavaMailUtil)"]:::mail

        %% Entry Point & Config
        Entry["Application Entry Point\n(InventorymanagementsystemApplication)"]:::service
        Config["Config & Init\n(application.properties, CreateUser.sql)"]:::service
    end

    %% External Components
    DB["MySQL Database\n(team9 schema)"]:::db
    FileSys["File System\n(Report Output)"]:::storage
    SMTP["External SMTP Server"]:::external

    %% Connections
    Client -->|HTTP Request| Security
    Security -->|Authorized Request| Controllers
    Controllers -->|Invoke Service| Interfaces
    Interfaces -->|Implemented By| Services
    Services -->|Call Repository| Repositories
    Repositories -->|SQL Queries| DB
    Services -->|Write Reports| FileSys
    Services -->|Send Emails| SMTP
    Controllers -->|Return Model & View| Templates
    Controllers -->|Serve Static| StaticAssets
    Entry --> Controllers
    Entry --> Services
    Entry --> Repositories
    Entry --> Security
    Entry --> Mail
    Entry --> Config

    %% Click Events
    click Controllers "https://github.com/rukayaafrin/inventory_management_system_using_spring_boot/tree/main/team9_final_javawebapp/src/main/java/com/team9/motors/controller"
    click Templates "https://github.com/rukayaafrin/inventory_management_system_using_spring_boot/tree/main/team9_final_javawebapp/src/main/resources/templates"
    click StaticAssets "https://github.com/rukayaafrin/inventory_management_system_using_spring_boot/tree/main/team9_final_javawebapp/src/main/resources/static"
    click Services "https://github.com/rukayaafrin/inventory_management_system_using_spring_boot/tree/main/team9_final_javawebapp/src/main/java/com/team9/motors/service"
    click Interfaces "https://github.com/rukayaafrin/inventory_management_system_using_spring_boot/tree/main/team9_final_javawebapp/src/main/java/com/team9/motors/interfacemethods"
    click Repositories "https://github.com/rukayaafrin/inventory_management_system_using_spring_boot/tree/main/team9_final_javawebapp/src/main/java/com/team9/motors/repository"
    click Model "https://github.com/rukayaafrin/inventory_management_system_using_spring_boot/tree/main/team9_final_javawebapp/src/main/java/com/team9/motors/model"
    click Security "https://github.com/rukayaafrin/inventory_management_system_using_spring_boot/tree/main/team9_final_javawebapp/src/main/java/com/team9/motors/springSecurity"
    click Mail "https://github.com/rukayaafrin/inventory_management_system_using_spring_boot/blob/main/team9_final_javawebapp/src/main/java/com/team9/motors/mail/JavaMailUtil.java"
    click Entry "https://github.com/rukayaafrin/inventory_management_system_using_spring_boot/blob/main/team9_final_javawebapp/src/main/java/com/team9/motors/InventorymanagementsystemApplication.java"
    click Config "https://github.com/rukayaafrin/inventory_management_system_using_spring_boot/blob/main/src/main/resources/application.properties"

    %% Styles
    classDef frontend fill:#DDEBF7,stroke:#4F81BD,color:#000;
    classDef service fill:#E2EFDA,stroke:#548235,color:#000;
    classDef repository fill:#FCE4D6,stroke:#C65911,color:#000;
    classDef model fill:#FCE4D6,stroke:#BF9000,color:#000;
    classDef security fill:#F2DCDB,stroke:#C00000,color:#000;
    classDef mail fill:#FFF2CC,stroke:#7F6000,color:#000;
    classDef db fill:#DDEBF7,stroke:#17365D,color:#000;
    classDef storage fill:#E7E6E6,stroke:#7A7A7A,color:#000;
    classDef external fill:#FFF2CC,stroke:#7F6000,color:#000;
```
