How dromara/sa-token works
Main project purpose and modules
• At the core is the “sa-token-core” module. This contains the fundamental APIs and components (authentication, session management, annotations, error-handling, security utilities, logging, etc.) that form the basis of the framework.
• Surrounding the core are various supporting modules:
– “sa-token-bom”: A Maven BOM to manage dependency versions.
– “sa-token-demo”: Contains many demo applications showing integrations with Redis, Dubbo, OAuth2, WebFlux, Solon, and more. These samples showcase how Sa-Token is applied in different architectures.
– “sa-token-doc”: Keeps the documentation, API descriptions, and usage guides.
– “sa-token-plugin”: Contains numerous plugins (for Dubbo, jwt, oauth2, SSO, redisson integration, etc.) that extend or integrate the core framework with various external technologies.
– “sa-token-test”: Contains unit and integration tests verifying framework functionality.
• Additionally, there are separate starter modules and third-party integration modules which act as adapters for various frameworks (Spring Boot, JFinal, Solon, etc.) and for different runtime environments.
File structure to capture architectural patterns
• The multi-module Maven layout (each module having its own pom.xml) indicates a layered, pluggable architecture.
• The core module’s packages show a clean separation by concerns – annotations (for declarative security), context management (thread local/session management), DAO interfaces (for persistence and state), and error/exception handling.
• The presence of many sub-folders (such as “annotation/handler”, “context/model”, “dao”, etc.) within “sa-token-core” implies an internal architectural pattern built around the separation of authentication logic, context propagation, and extension points.
• Plugin modules further highlight an extensible design pattern, where integrations with external frameworks (dubbo, grpc, oauth2, JWT, etc.) are provided as separate pluggable components.