$ show hs-web/hsweb-framework
hsweb-framework is a modular Java backend development framework, not a single deployable application. It is built as a multi-module Maven monorepo providing reactive-first CRUD scaffolding, RBAC/authorization, an OAuth2 authorization server, dynamic datasource switching, reactive caching, access logging, i18n, dictionary/enum support, and file upload services. The code is dominated by Spring Boot auto-configurations, SPI extension points, and reusable controller/service interfaces that applications consume as dependencies. It supports both WebFlux (R2DBC) and WebMVC (JDBC) stacks, with reactive APIs as the primary design direction. Architecturally, the framework centers on hsweb-core (bean utilities, i18n, exceptions, ID generation), hsweb-commons (generic CRUD services/controllers, query helpers, SQL analysis), hsweb-authorization (authentication model, token management, AOP method authorization, OAuth2 granters/authenticators), hsweb-datasource (dynamic schema/table/datasource switching), hsweb-concurrent-cache (ReactiveCache with Guava/Caffeine/Redis backends), hsweb-logging (AOP access logs), and hsweb-system (default user, permission, dictionary, and file modules). Key entry points are Java annotations such as @Authorize, @Resource, @EnableEasyormRepository, @EnableEntityEvent, and interface contracts like ReactiveServiceCrudController and CrudService, which auto-generate REST endpoints for entities. Primary data flows move from HTTP requests through WebFlux/WebMVC controllers into reactive or synchronous CrudService implementations, then through EasyORM repositories to R2DBC/JDBC databases. Authorization flows are layered: token parsing/generation, AuthenticationManager initialization, AOP authorization definition parsing, data-permission handlers, and OAuth2 grant/redirect handling. Entity lifecycle events, cache invalidation, and query rewriting are cross-cutting mechanisms implemented via Spring application events, Reactor context, and JSqlParser-based SQL analysis. Redis is used for token storage and cache synchronization; Caffeine/Guava support local reactive caches. External dependencies include Spring Boot 3.x, Reactor, R2DBC, JDBC, Redis, JSqlParser, and Javassist. The codebase demonstrates strong engineering in isolated utilities like FastBeanCopier, reactive cache invalidation, streaming JSON response writing, and SQL query analysis. However, it carries notable drift: mixed javax/jakarta annotations, deprecated legacy APIs, a coexistence of servlet and reactive paths, some ignored/incomplete tests, and complex compatibility layers around OAuth2 and cache semantics. Overall it is a mature, actively maintained framework with substantial reusable components, though consumers should expect to navigate Chinese-language comments and some legacy baggage.
The LLM identified 6 files worth highlighting for reuse:
High-performance bean copier that uses Javassist to generate dedicated Copier implementations at runtime. It handles Maps, Java records, ExtendableEntity, nested collections, and type conversion with caching of generated copiers. It is self-contained and demonstrates non-obvious bytecode-level optimization, making it safely reusable in any Java project needing fast object transformation.
A JSqlParser-based SQL analyzer that rewrites complex SQL statements to inject security/authorization conditions and to rebuild pagination. It supports JOIN, UNION, CTEs, subqueries, and window functions. This is a reusable query-governance component that could be extracted to enforce row-level or tenant-level restrictions on arbitrary SQL.
Fluent query-builder API over reactive repositories supporting select/from/join/where/orderBy/fetch and paged queries with one-to-many combining. It abstracts paging policy, total-count handling, and result transformation into a clean DSL. The pattern is reusable for any reactive data-access layer that needs consistent query composition.
Streaming JSON response writer that wraps reactive publisher results into a uniform response envelope without buffering the entire stream in memory. It generates incremental JSON arrays, preserves error semantics, and supports NDJSON/SSE passthrough. This is a well-crafted, reusable Spring WebFlux component for building memory-efficient streaming APIs.
Abstract reactive cache implementation providing getMono/getFlux with lazy loading and in-flight deduplication so concurrent subscribers share a single upstream request. It carefully handles eviction and clear operations so stale in-flight loads cannot repopulate the cache. This is a subtle, reusable concurrency pattern for reactive caching across Redis/Caffeine/Guava backends.
Composable OAuth2 client authenticator that routes authentication attempts through registered ReactiveOAuth2ClientAuthenticator implementations. It demonstrates a clean SPI/chain-of-responsibility design, allowing external modules to add new client authentication methods without modifying the authorization server core. The pattern is reusable for any extensible authentication pipeline.