# ashif-ismail/spring-auto-request-parser architecture

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

- Interactive diagram: https://gitdiagram.com/ashif-ismail/spring-auto-request-parser
- Repository: https://github.com/ashif-ismail/spring-auto-request-parser

## Overview

##### Project type and purpose
- This is a Spring Boot “starter” library (open-source tool) that provides zero-config auto-configuration for custom MVC argument resolution. It hooks into Spring’s startup process (via `spring.factories`) and automatically registers a `HandlerMethodArgumentResolver` that resolves controller method parameters annotated with `@RequestContent`.

##### File structure
- Top-level configuration:
- pom.xml / mvnw – Maven build, publishing via GitHub Actions (`.github/workflows/maven-publish.yml`).
- src/main/resources/META-INF/spring.factories – declares `WebAutoConfig` for Spring Boot auto-configuration.
- Code packages:
- `com.ashifismail.autorequest.config.WebAutoConfig` – the Spring `@Configuration` that registers the resolver.
- `com.ashifismail.autorequest.web.RequestContent` – the marker annotation.
- `com.ashifismail.autorequest.web.RequestContentArgumentResolver` – the core logic that inspects requests and binds JSON/XML/body content to method parameters.

##### README for additional insights
- Confirms “zero configuration” design, plug-and-play setup, and use of a single annotation to trigger the resolver.

##### Main components & relationships
a. External HTTP Client (curl/browser/SDK)
b. Spring MVC DispatcherServlet (framework entry point)
c. HandlerMapping & HandlerAdapter (Spring core)
d. WebAutoConfig (auto-configuration)
e. RequestContentArgumentResolver (custom resolver)
f. HttpMessageConverters (JSON/XML converters)
g. User’s Controller & `@RequestContent` method parameter
h. Domain object (POJO) bound from request body
i. Response generation back to HTTP Client

Interaction flow:
1) Client sends HTTP request → 2) DispatcherServlet routes to controller →
3) HandlerAdapter invokes WebAutoConfig-registered RequestContentArgumentResolver →
4) Resolver reads annotation, picks appropriate HttpMessageConverter →
5) Body → Domain object → Controller method → 6) Return value serialized → HTTP response.

##### Architectural patterns & design principles
- Spring Boot Auto-Configuration (via `spring.factories`) for zero config.
- Strategy pattern: custom `HandlerMethodArgumentResolver` plugged into Spring’s resolver chain.
- Annotation-driven programming model.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Layer
    subgraph "External"
        direction TB
        HTTPClient["HTTP Client (curl/browser/SDK)"]:::external
    end

    %% Framework Layer
    subgraph "Framework (Spring MVC)" 
        direction TB
        DispatcherServlet["DispatcherServlet"]:::framework
        HandlerMapping["HandlerMapping"]:::framework
        HandlerAdapter["HandlerAdapter"]:::framework
        HttpMessageConverters["HttpMessageConverters"]:::framework
    end

    %% Library Layer
    subgraph "Library (Auto Request Parser)" 
        direction TB
        SPRINGFACTORIES["spring.factories"]:::library
        WebAutoConfig["WebAutoConfig"]:::library
        RequestContentArgumentResolver["RequestContentArgumentResolver"]:::library
        RequestContentAnnotation["RequestContent Annotation"]:::library
    end

    %% User Code Layer
    subgraph "User Code"
        direction TB
        Controller["User Controller"]:::user
        DomainObject["Domain Object (POJO)"]:::user
    end

    %% Project Configuration
    subgraph "Project Configuration"
        direction TB
        Pom["pom.xml"]:::config
        MVNW["mvnw / mvnw.cmd"]:::config
        Publish[".github/workflows/maven-publish.yml"]:::config
    end

    %% Startup Registration Flow
    SPRINGFACTORIES -->|"spring.factories loaded"| WebAutoConfig
    WebAutoConfig -->|"registers resolver"| RequestContentArgumentResolver
    WebAutoConfig -->|hooks via annotation| RequestContentAnnotation

    %% Request Flow
    HTTPClient -->|"HTTP Request"| DispatcherServlet
    DispatcherServlet -->|"determine handler"| HandlerMapping
    HandlerMapping -->|"invoke handler"| HandlerAdapter
    HandlerAdapter -->|"resolve @RequestContent"| RequestContentArgumentResolver
    RequestContentArgumentResolver -->|"invoke converter"| HttpMessageConverters
    HttpMessageConverters -->|"Body → POJO"| DomainObject
    HandlerAdapter -->|"invoke method"| Controller
    Controller -->|"return value"| HandlerAdapter
    HandlerAdapter -->|"serialize response"| HttpMessageConverters
    HttpMessageConverters -->|"HTTP Response"| HTTPClient

    %% Click Events
    click WebAutoConfig "https://github.com/ashif-ismail/spring-auto-request-parser/blob/main/src/main/java/com/ashifismail/autorequest/config/WebAutoConfig.java"
    click RequestContentAnnotation "https://github.com/ashif-ismail/spring-auto-request-parser/blob/main/src/main/java/com/ashifismail/autorequest/web/RequestContent.java"
    click RequestContentArgumentResolver "https://github.com/ashif-ismail/spring-auto-request-parser/blob/main/src/main/java/com/ashifismail/autorequest/web/RequestContentArgumentResolver.java"
    click SPRINGFACTORIES "https://github.com/ashif-ismail/spring-auto-request-parser/blob/main/src/main/resources/META-INF/spring.factories"
    click Pom "https://github.com/ashif-ismail/spring-auto-request-parser/blob/main/pom.xml"
    click MVNW "https://github.com/ashif-ismail/spring-auto-request-parser/tree/main/mvnw"
    click MVNW "https://github.com/ashif-ismail/spring-auto-request-parser/blob/main/mvnw.cmd"
    click Publish "https://github.com/ashif-ismail/spring-auto-request-parser/blob/main/.github/workflows/maven-publish.yml"

    %% Styles
    classDef external fill:#dddddd,stroke:#333,stroke-width:1px
    classDef framework fill:#bbdefb,stroke:#333,stroke-width:1px
    classDef library fill:#c8e6c9,stroke:#333,stroke-width:1px
    classDef user fill:#ffe0b2,stroke:#333,stroke-width:1px
    classDef config fill:#f0f4c3,stroke:#333,stroke-width:1px
```
