# navneetprabhakar/executor architecture

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

- Interactive diagram: https://gitdiagram.com/navneetprabhakar/executor
- Repository: https://github.com/navneetprabhakar/executor

## Overview

##### Project type and purpose
- This is a Spring Boot microservice (backend application) exposing REST APIs for uploading files and processing them asynchronously via a thread pool (ExecutorService/ThreadPoolTaskExecutor).
- The primary use case: clients upload files, the service enqueues processing tasks, persists metadata in a database, and provides status updates.

##### File structure
- Top-level build files: build.gradle, settings.gradle, .gitignore.
- src/main/java/com/navneet/executor:
- configs – ThreadPoolTaskExecutor bean configuration
- constants – StatusEnum (task states)
- controller – TaskController (REST endpoints)
- data/models – JPA entities (Customer, Tasks)
- data/repo – Spring Data JPA repositories
- models – API DTOs (ServiceRequest/Response, UploadRequest/Response, TaskStatus)
- service – UploadService interface, helper and implementation
- threads – ProcessFileUploadTask (Runnable job)
- utils – FileUtils (file operations)
- src/main/resources/application.properties – thread-pool and datasource settings.

##### README for additional insights
- Confirms focus on JDK ExecutorService and Spring ThreadPoolTaskExecutor.
- REST APIs to upload and process.

a. Main components
1. Client (e.g., Web UI or CURL)
2. TaskController (Spring MVC layer)
3. UploadService (business logic)
4. ThreadPoolTaskExecutor (configured thread pool)
5. ProcessFileUploadTask (worker threads)
6. File Storage (local FS or external blob store)
7. Database (Tasks, Customer tables via Spring Data JPA)
8. Utilities (FileUtils)
9. Configuration (ThreadPoolExecutorConfig)
b. Relationships & interactions
- Client → TaskController: sends UploadRequest
- TaskController → UploadService: invokes uploadFile()
- UploadService:
- persists initial task record via TasksRepo
- submits ProcessFileUploadTask to ThreadPoolTaskExecutor
- ThreadPoolTaskExecutor → ProcessFileUploadTask: picks up tasks asynchronously
- ProcessFileUploadTask:
- uses FileUtils to store/process files
- updates task status in DB via TasksRepo
- Client can poll TaskController for TaskStatus (reads from DB).
c. Architectural patterns & design principles
- Layered MVC: Controller → Service → Repository
- Asynchronous processing: Producer (controller/service) & Consumer (thread pool workers)
- Dependency injection for configs, services, repos
- Separation of concerns: DTOs vs. Entities vs. Helpers
d. Key technologies & frameworks
- Spring Boot (auto-configuration, embedded server)
- Spring MVC (REST controllers)
- Spring Data JPA (repository layer)
- ThreadPoolTaskExecutor (configurable thread pool)
- JDK ExecutorService under the hood
- Java 8+ features (Runnable, enums)

## Diagram (Mermaid)

```mermaid
flowchart TD
    Client["Client (Web UI / CURL)"]:::external
    ExecutorApp["ExecutorApplication"]:::service

    subgraph "API Layer"
        TC["TaskController"]:::api
        UReq["UploadRequest DTO"]:::api
        URes["UploadResponse DTO"]:::api
        TSDTO["TaskStatus DTO"]:::api
    end

    subgraph "Service Layer"
        USI["UploadService"]:::service
        USIH["UploadServiceHelper"]:::service
        USIml["UploadServiceImpl"]:::service
    end

    subgraph "Configuration"
        TConfig["ThreadPoolExecutorConfig"]:::service
        AppProps["application.properties"]:::service
    end

    subgraph "Async Processing"
        TPE["ThreadPoolTaskExecutor"]:::async
        PFUT["ProcessFileUploadTask"]:::async
    end

    subgraph "Persistence Layer"
        TR["TasksRepo"]:::db
        CR["CustomerRepo"]:::db
        DB["Database"]:::db
        TasksEntity["Tasks Entity"]:::db
        CustomerEntity["Customer Entity"]:::db
    end

    subgraph "Utilities"
        FU["FileUtils"]:::util
        FS["File Storage"]:::util
    end

    Client -->|"POST /upload"| TC
    TC -->|"uploadFile(UploadRequest)"| USIml
    TC -->|"GET /status/{id}"| TC
    TC -->|"returns UploadResponse"| Client
    TC -->|"returns TaskStatus"| Client

    USIml -->|"save Tasks entity"| TR
    USIml -->|"save Customer entity"| CR
    USIml -->|"submit task"| TPE

    TPE -->|"execute Runnable"| PFUT
    PFUT -->|"use FileUtils"| FU
    FU -->|"store file"| FS
    PFUT -->|"update status"| TR

    TR -->|"JPA operations"| DB
    CR -->|"JPA operations"| DB

    classDef external fill:#E7E7E7,stroke:#333,stroke-width:1px
    classDef api fill:#DCEFFD,stroke:#333,stroke-width:1px
    classDef service fill:#D5E8D4,stroke:#333,stroke-width:1px
    classDef async fill:#F8CECC,stroke:#333,stroke-width:1px
    classDef db fill:#E1E1E1,stroke:#333,stroke-width:1px
    classDef util fill:#FFF2CC,stroke:#333,stroke-width:1px

    click ExecutorApp "https://github.com/navneetprabhakar/executor/blob/main/src/main/java/com/navneet/executor/ExecutorApplication.java"
    click TConfig "https://github.com/navneetprabhakar/executor/blob/main/src/main/java/com/navneet/executor/configs/ThreadPoolExecutorConfig.java"
    click TC "https://github.com/navneetprabhakar/executor/blob/main/src/main/java/com/navneet/executor/controller/TaskController.java"
    click USI "https://github.com/navneetprabhakar/executor/blob/main/src/main/java/com/navneet/executor/service/UploadService.java"
    click USIH "https://github.com/navneetprabhakar/executor/blob/main/src/main/java/com/navneet/executor/service/helper/UploadServiceHelper.java"
    click USIml "https://github.com/navneetprabhakar/executor/blob/main/src/main/java/com/navneet/executor/service/impl/UploadServiceImpl.java"
    click PFUT "https://github.com/navneetprabhakar/executor/blob/main/src/main/java/com/navneet/executor/threads/ProcessFileUploadTask.java"
    click FU "https://github.com/navneetprabhakar/executor/blob/main/src/main/java/com/navneet/executor/utils/FileUtils.java"
    click TR "https://github.com/navneetprabhakar/executor/blob/main/src/main/java/com/navneet/executor/data/repo/TasksRepo.java"
    click CR "https://github.com/navneetprabhakar/executor/blob/main/src/main/java/com/navneet/executor/data/repo/CustomerRepo.java"
    click TasksEntity "https://github.com/navneetprabhakar/executor/blob/main/src/main/java/com/navneet/executor/data/models/Tasks.java"
    click CustomerEntity "https://github.com/navneetprabhakar/executor/blob/main/src/main/java/com/navneet/executor/data/models/Customer.java"
    click StatusEnum "https://github.com/navneetprabhakar/executor/blob/main/src/main/java/com/navneet/executor/constants/StatusEnum.java"
    click UReq "https://github.com/navneetprabhakar/executor/blob/main/src/main/java/com/navneet/executor/models/UploadRequest.java"
    click URes "https://github.com/navneetprabhakar/executor/blob/main/src/main/java/com/navneet/executor/models/UploadResponse.java"
    click TSDTO "https://github.com/navneetprabhakar/executor/blob/main/src/main/java/com/navneet/executor/models/TaskStatus.java"
    click ServiceReq "https://github.com/navneetprabhakar/executor/blob/main/src/main/java/com/navneet/executor/models/ServiceRequest.java"
    click ServiceRes "https://github.com/navneetprabhakar/executor/blob/main/src/main/java/com/navneet/executor/models/ServiceResponse.java"
    click CustomerInfo "https://github.com/navneetprabhakar/executor/blob/main/src/main/java/com/navneet/executor/models/CustomerInfo.java"
    click AppProps "https://github.com/navneetprabhakar/executor/blob/main/src/main/resources/application.properties"
```
