Package Map
This page covers the package-level mental model of the ai4j/ module.
Its goal is not to list every class, but to answer three questions first:
- How the
Core SDKcode is broadly layered in the source - Which packages you should look at first when reading the source
- Which packages are primary capability surfaces and which are more of a supporting layer
1. Start by remembering the source root path
The module corresponding to Core SDK is:
ai4j/
The main source root path is:
ai4j/src/main/java/io/github/lnyocly/ai4j/
So all packages discussed in this chapter live under this root path by default.
2. The package clusters worth looking at first
Inside the ai4j module, the most important packages are better understood as "clusters" rather than by individual directory name:
service+service.factory: unified entry point, configuration objects, platform enums, service factory and registryplatform: concrete adapter implementations for each providertool+tools: local tool declaration, bridging, built-in tools and execution semanticsskill: Skill description, discovery and loadingmcp: MCP client / gateway / server / transportmemory: foundational session context capabilityrag+vector+rerank+websearch+document: the knowledge-augmentation chain
3. What the supporting-layer packages are roughly responsible for
Beyond the primary capability surfaces, ai4j contains a set of more support-oriented packages:
config: platform configuration objectsnetwork: HTTP, connections and underlying network capabilitiesauth: authentication-related capabilitiesinterceptor: request/response interception extension pointsannotation: annotation-driven capability exposurelistener: streaming or event listening helpersconvert: object conversion and adaptation helpersexception: unified exception definitionsconstant,token: constants and tokenization/token-related helpers
These packages matter, but they are usually not the first landing point on your first read of the source.
4. How to make sense of each primary package cluster
4.1 service + service.factory
This is the unified entry-point layer of the Core SDK.
If you want to look first at:
ConfigurationPlatformTypeAiServiceAiServiceRegistry
start by descending from here.
4.2 platform
This is the provider landing layer.
It answers:
- How each platform such as OpenAI, DashScope, Doubao, or Ollama is adapted
- Which capability interfaces already have concrete implementations
4.3 tool + tools
This is the local invocable capability surface.
It is not just a list of tools; it includes:
- tool declaration
- schema exposure
- execution semantics
- tool security boundaries
4.4 skill
This is the descriptive-asset layer.
Its focus is not execution, but rather:
- which skill to discover
- when to load it
- how to bring resources such as
SKILL.mdinto the model context
4.5 mcp
This is the protocolized external-capability layer.
It sits at the same level as tool, not as a subdirectory of tool, because it also involves:
- transport
- client
- gateway
- server
- tool/resource/prompt exposure
4.6 memory
This is the foundational session context of the base layer, not the full state machine of the upper-layer runtime.
4.7 rag + vector + rerank + websearch + document
This is the knowledge-augmentation main line.
If you trace the whole chain, you will typically see:
- ingestion and chunking
- embedding
- vector store
- rerank
- online search
- citations / trace-related semantics
5. Recommended order for reading the source
If you want to read the source, the suggestion is:
service/service.factoryplatformtool/toolsskillmcpmemoryrag/vector/rerank/websearch
This lets you build the main line of "entry-point layer -> capability surface -> knowledge augmentation" first, so you do not conflate the Core SDK with the upper-layer runtime.
6. Boundary with upper-layer modules
If, as you read, you start to see:
- runtime step loop
- subagent / team orchestration
- workspace-aware tools
- CLI / TUI / ACP
- Flowgram node-graph execution
that is usually no longer the Core SDK layer itself, but rather:
ai4j-agentai4j-codingai4j-cliai4j-flowgram-spring-boot-starter