Skip to content

Commit e849169

Browse files
committed
docs: update codeboarding architecture documentation
## πŸ“š Architecture Documentation Update This commit contains updated documentation files fetched from the CodeBoarding service and copied to the architecture documentation section. ### πŸ“Š Summary - Documentation files created/updated: 7 - JSON files created/updated: 8 - Documentation directory: .codeboarding/ - JSON directory: .codeboarding/ - Output format: .md - Repository analyzed: https://github.com/CodeBoarding/friendli-python - Destination: docs/architecture/ The generated .md files have been automatically copied to the architecture documentation section and referenced in on_boarding.md. πŸ€– This commit was automatically generated by the CodeBoarding documentation update workflow.
1 parent 2fdc727 commit e849169

File tree

8 files changed

+135
-81
lines changed

8 files changed

+135
-81
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"description": "The `friendli_core` SDK is designed with extensibility in mind, primarily through its `Hooks & Extensibility Manager`. This central component, embodied by classes like `HookRegistrar` and `SDKHooks`, facilitates the dynamic registration and execution of custom logic. The `HookRegistrar` acts as the entry point for defining new hooks, while `SDKHooks` provides the mechanism for the SDK's core functionalities to discover and invoke these registered hooks at predetermined points. This architecture ensures that the SDK remains flexible and adaptable, allowing for easy integration of custom behaviors and extensions without altering the core codebase.",
3+
"components": [
4+
{
5+
"name": "Hooks & Extensibility Manager",
6+
"description": "This component is responsible for managing the registration, discovery, and execution of various custom logic hooks throughout the SDK's lifecycle. It provides the core mechanism for extensibility.",
7+
"referenced_source_code": [
8+
{
9+
"qualified_name": "friendli_core._hooks.registration.HookRegistrar",
10+
"reference_file": "<file_path>",
11+
"reference_start_line": null,
12+
"reference_end_line": null
13+
},
14+
{
15+
"qualified_name": "friendli_core._hooks.sdkhooks.SDKHooks",
16+
"reference_file": "src/friendli_core/_hooks/sdkhooks.py",
17+
"reference_start_line": 22,
18+
"reference_end_line": 79
19+
}
20+
],
21+
"assigned_files": [
22+
"src/friendli_core/_hooks/__init__.py",
23+
"src/friendli_core/_hooks/sdkhooks.py",
24+
"src/friendli_core/_hooks/registration.py",
25+
"src/friendli_core/_hooks/types.py"
26+
],
27+
"can_expand": true
28+
},
29+
{
30+
"name": "Unclassified",
31+
"description": "Component for all unclassified files and utility functions (Utility functions/External Libraries/Dependencies)",
32+
"referenced_source_code": [],
33+
"assigned_files": [],
34+
"can_expand": false
35+
}
36+
],
37+
"components_relations": [
38+
{
39+
"relation": "Registers Hooks",
40+
"src_name": "Hooks & Extensibility Manager",
41+
"dst_name": "SDK Core"
42+
},
43+
{
44+
"relation": "Triggers Hooks",
45+
"src_name": "SDK Core",
46+
"dst_name": "Hooks & Extensibility Manager"
47+
}
48+
]
49+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
```mermaid
2+
graph LR
3+
Hooks_Extensibility_Manager["Hooks & Extensibility Manager"]
4+
Unclassified["Unclassified"]
5+
Hooks_Extensibility_Manager -- "Registers Hooks" --> SDK_Core
6+
SDK_Core -- "Triggers Hooks" --> Hooks_Extensibility_Manager
7+
```
8+
9+
[![CodeBoarding](https://img.shields.io/badge/Generated%20by-CodeBoarding-9cf?style=flat-square)](https://github.com/CodeBoarding/CodeBoarding)[![Demo](https://img.shields.io/badge/Try%20our-Demo-blue?style=flat-square)](https://www.codeboarding.org/diagrams)[![Contact](https://img.shields.io/badge/Contact%20us%20-%20contact@codeboarding.org-lightgrey?style=flat-square)](mailto:contact@codeboarding.org)
10+
11+
## Details
12+
13+
The `friendli_core` SDK is designed with extensibility in mind, primarily through its `Hooks & Extensibility Manager`. This central component, embodied by classes like `HookRegistrar` and `SDKHooks`, facilitates the dynamic registration and execution of custom logic. The `HookRegistrar` acts as the entry point for defining new hooks, while `SDKHooks` provides the mechanism for the SDK's core functionalities to discover and invoke these registered hooks at predetermined points. This architecture ensures that the SDK remains flexible and adaptable, allowing for easy integration of custom behaviors and extensions without altering the core codebase.
14+
15+
### Hooks & Extensibility Manager
16+
This component is responsible for managing the registration, discovery, and execution of various custom logic hooks throughout the SDK's lifecycle. It provides the core mechanism for extensibility.
17+
18+
19+
**Related Classes/Methods**:
20+
21+
- `friendli_core._hooks.registration.HookRegistrar`
22+
- <a href="https://github.com/CodeBoarding/friendli-python/blob/main/.codeboardingsrc/friendli_core/_hooks/sdkhooks.py#L22-L79" target="_blank" rel="noopener noreferrer">`friendli_core._hooks.sdkhooks.SDKHooks`:22-79</a>
23+
24+
25+
### Unclassified
26+
Component for all unclassified files and utility functions (Utility functions/External Libraries/Dependencies)
27+
28+
29+
**Related Classes/Methods**: _None_
30+
31+
32+
33+
### [FAQ](https://github.com/CodeBoarding/GeneratedOnBoardings/tree/main?tab=readme-ov-file#faq)

β€Ž.codeboarding/analysis.jsonβ€Ž

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"src/friendli/httpclient.py",
3535
"src/friendli/config.py",
3636
"src/friendli_core/__init__.py",
37-
"src/friendli_core/_version.py",
37+
"src/friendli_core/endpoint.py",
3838
"src/friendli_core/basesdk.py",
3939
"src/friendli_core/httpclient.py",
4040
"src/friendli_core/sdkconfiguration.py"
@@ -88,19 +88,16 @@
8888
"src/friendli/dataset/dataset.py",
8989
"src/friendli/file/__init__.py",
9090
"src/friendli/file/file.py",
91-
"src/friendli_core/friendlicore_serverless_chat.py",
9291
"src/friendli_core/completions.py",
9392
"src/friendli_core/file.py",
9493
"src/friendli_core/chat.py",
9594
"src/friendli_core/friendlicore_image.py",
9695
"src/friendli_core/friendlicore_completions.py",
97-
"src/friendli_core/friendlicore_serverless_token.py",
9896
"src/friendli_core/image.py",
9997
"src/friendli_core/toolassistedchat.py",
10098
"src/friendli_core/dataset.py",
10199
"src/friendli_core/token.py",
102100
"src/friendli_core/friendlicore_token.py",
103-
"src/friendli_core/friendlicore_serverless_completions.py",
104101
"src/friendli_core/friendlicore_chat.py",
105102
"src/friendli_core/knowledge.py",
106103
"src/friendli_core/audio.py"
@@ -121,6 +118,7 @@
121118
"assigned_files": [
122119
"src/friendli/models.py",
123120
"src/friendli/types.py",
121+
"src/friendli/serverless/model.py",
124122
"src/friendli_core/model.py",
125123
"src/friendli_core/models/containerdetokenizationop.py",
126124
"src/friendli_core/models/splitinfo.py",
@@ -331,9 +329,7 @@
331329
"src/friendli_core/models/init_uploadop.py",
332330
"src/friendli_core/models/streamedchatdata.py",
333331
"src/friendli_core/models/fileinfo.py",
334-
"src/friendli_core/models/streamedcompletiondata.py",
335-
"src/friendli_core/types/__init__.py",
336-
"src/friendli_core/types/basemodel.py"
332+
"src/friendli_core/models/streamedcompletiondata.py"
337333
],
338334
"can_expand": true
339335
},
@@ -357,13 +353,14 @@
357353
"assigned_files": [
358354
"src/friendli/container/__init__.py",
359355
"src/friendli/serverless/__init__.py",
360-
"src/friendli/serverless/model.py",
361356
"src/friendli/dedicated/__init__.py",
362357
"src/friendli/dedicated/endpoint.py",
358+
"src/friendli_core/friendlicore_serverless_chat.py",
363359
"src/friendli_core/dedicated.py",
364360
"src/friendli_core/container.py",
365-
"src/friendli_core/endpoint.py",
366-
"src/friendli_core/serverless.py"
361+
"src/friendli_core/friendlicore_serverless_token.py",
362+
"src/friendli_core/serverless.py",
363+
"src/friendli_core/friendlicore_serverless_completions.py"
367364
],
368365
"can_expand": true
369366
},
@@ -384,14 +381,15 @@
384381
"src/friendli_core/_hooks/registration.py",
385382
"src/friendli_core/_hooks/types.py"
386383
],
387-
"can_expand": false
384+
"can_expand": true
388385
},
389386
{
390387
"name": "Unclassified",
391388
"description": "Component for all unclassified files and utility functions (Utility functions/External Libraries/Dependencies)",
392389
"referenced_source_code": [],
393390
"assigned_files": [
394391
"src/friendli/utils.py",
392+
"src/friendli_core/_version.py",
395393
"src/friendli_core/utils/metadata.py",
396394
"src/friendli_core/utils/__init__.py",
397395
"src/friendli_core/utils/forms.py",
@@ -409,6 +407,8 @@
409407
"src/friendli_core/utils/unmarshal_json_response.py",
410408
"src/friendli_core/utils/eventstreaming.py",
411409
"src/friendli_core/utils/annotations.py",
410+
"src/friendli_core/types/__init__.py",
411+
"src/friendli_core/types/basemodel.py",
412412
"scripts/prepare_readme.py",
413413
"scripts/auto-fix.py"
414414
],
@@ -470,6 +470,13 @@
470470
"assigned_files": [],
471471
"can_expand": false
472472
},
473+
{
474+
"name": "Unclassified",
475+
"description": "Component for all unclassified files and utility functions (Utility functions/External Libraries/Dependencies)",
476+
"referenced_source_code": [],
477+
"assigned_files": [],
478+
"can_expand": false
479+
},
473480
{
474481
"name": "Unclassified",
475482
"description": "Component for all unclassified files and utility functions (Utility functions/External Libraries/Dependencies)",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"commit_hash": "60cff9cc1e4b5f31db88108b2281c75b49aa1555",
2+
"commit_hash": "2fdc7274073734394c843c58e6c409cd8b275630",
33
"code_boarding_version": "0.2.0"
44
}

β€Ž.codeboarding/overview.mdβ€Ž

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ graph LR
1616
Unclassified["Unclassified"]
1717
Unclassified["Unclassified"]
1818
Unclassified["Unclassified"]
19+
Unclassified["Unclassified"]
1920
Friendli_Client_Public_API_ -- "delegates requests to" --> SDK_Core
2021
SDK_Core -- "utilizes" --> Data_Models_Error_Handling
2122
SDK_Core -- "adapts behavior based on" --> Platform_Abstractions
@@ -27,6 +28,7 @@ graph LR
2728
click Service_Modules href "https://github.com/CodeBoarding/friendli-python/blob/main/.codeboarding/Service_Modules.md" "Details"
2829
click Data_Models_Error_Handling href "https://github.com/CodeBoarding/friendli-python/blob/main/.codeboarding/Data_Models_Error_Handling.md" "Details"
2930
click Platform_Abstractions href "https://github.com/CodeBoarding/friendli-python/blob/main/.codeboarding/Platform_Abstractions.md" "Details"
31+
click Hooks_Extensibility href "https://github.com/CodeBoarding/friendli-python/blob/main/.codeboarding/Hooks_Extensibility.md" "Details"
3032
```
3133

3234
[![CodeBoarding](https://img.shields.io/badge/Generated%20by-CodeBoarding-9cf?style=flat-square)](https://github.com/CodeBoarding/CodeBoarding)[![Demo](https://img.shields.io/badge/Try%20our-Demo-blue?style=flat-square)](https://www.codeboarding.org/diagrams)[![Contact](https://img.shields.io/badge/Contact%20us%20-%20contact@codeboarding.org-lightgrey?style=flat-square)](mailto:contact@codeboarding.org)
@@ -84,7 +86,7 @@ Provides base structures and interfaces tailored for different operational modes
8486
- `friendli_core.serverless`
8587

8688

87-
### Hooks & Extensibility
89+
### Hooks & Extensibility [[Expand]](./Hooks_Extensibility.md)
8890
Offers an extensible mechanism for injecting custom logic at various stages of the request/response lifecycle, allowing for pre-processing, post-processing, and error handling customization.
8991

9092

@@ -151,6 +153,12 @@ Component for all unclassified files and utility functions (Utility functions/Ex
151153
Component for all unclassified files and utility functions (Utility functions/External Libraries/Dependencies)
152154

153155

156+
**Related Classes/Methods**: _None_
157+
158+
### Unclassified
159+
Component for all unclassified files and utility functions (Utility functions/External Libraries/Dependencies)
160+
161+
154162
**Related Classes/Methods**: _None_
155163

156164

β€Ždocs/architecture/Hooks_Extensibility.mdβ€Ž

Lines changed: 7 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,27 @@
11
```mermaid
22
graph LR
3-
FriendliClient["FriendliClient"]
4-
HookRegistrar["HookRegistrar"]
5-
SDKHookOrchestrator["SDKHookOrchestrator"]
6-
HookDefinitions["HookDefinitions"]
7-
HttpClient["HttpClient"]
8-
SDKErrorProcessor["SDKErrorProcessor"]
3+
Hooks_Extensibility_Manager["Hooks & Extensibility Manager"]
94
Unclassified["Unclassified"]
10-
SDKHookOrchestrator -- "implements" --> HookDefinitions
11-
HookRegistrar -- "configures" --> SDKHookOrchestrator
12-
SDKHookOrchestrator -- "uses" --> HookDefinitions
13-
FriendliClient -- "registers hooks with" --> HookRegistrar
14-
HookRegistrar -- "registers hooks with" --> SDKHookOrchestrator
15-
HttpClient -- "invokes before_request hooks on" --> SDKHookOrchestrator
16-
HttpClient -- "invokes after_success hooks on" --> SDKHookOrchestrator
17-
SDKErrorProcessor -- "invokes after_error hooks on" --> SDKHookOrchestrator
5+
Hooks_Extensibility_Manager -- "Registers Hooks" --> SDK_Core
6+
SDK_Core -- "Triggers Hooks" --> Hooks_Extensibility_Manager
187
```
198

209
[![CodeBoarding](https://img.shields.io/badge/Generated%20by-CodeBoarding-9cf?style=flat-square)](https://github.com/CodeBoarding/CodeBoarding)[![Demo](https://img.shields.io/badge/Try%20our-Demo-blue?style=flat-square)](https://www.codeboarding.org/diagrams)[![Contact](https://img.shields.io/badge/Contact%20us%20-%20contact@codeboarding.org-lightgrey?style=flat-square)](mailto:contact@codeboarding.org)
2110

2211
## Details
2312

24-
The `friendli_core._hooks` subsystem provides a robust extension mechanism for the Friendli SDK. The `FriendliClient` initiates this by providing custom logic to the `HookRegistrar`, which then configures the `SDKHookOrchestrator`. This orchestrator is central to the subsystem, managing and invoking various hook typesβ€”defined by `HookDefinitions`β€”at critical junctures. For instance, the `HttpClient` triggers hooks before sending requests and after receiving responses, while the `SDKErrorProcessor` activates specific hooks when exceptions occur. This design allows for flexible customization of SDK behavior without altering its core implementation, enhancing adaptability and maintainability.
13+
The `friendli_core` SDK is designed with extensibility in mind, primarily through its `Hooks & Extensibility Manager`. This central component, embodied by classes like `HookRegistrar` and `SDKHooks`, facilitates the dynamic registration and execution of custom logic. The `HookRegistrar` acts as the entry point for defining new hooks, while `SDKHooks` provides the mechanism for the SDK's core functionalities to discover and invoke these registered hooks at predetermined points. This architecture ensures that the SDK remains flexible and adaptable, allowing for easy integration of custom behaviors and extensions without altering the core codebase.
2514

26-
### FriendliClient
27-
The primary interface for users to interact with the SDK and register custom extensions. Initializes the SDK and provides custom hook implementations to the `HookRegistrar`.
28-
29-
30-
**Related Classes/Methods**:
31-
32-
- <a href="https://github.com/CodeBoarding/friendli-python/blob/main/.codeboardingsrc/friendli_core/sdk.py" target="_blank" rel="noopener noreferrer">`friendli_core.FriendliClient`</a>
33-
34-
35-
### HookRegistrar
36-
The component responsible for receiving and organizing custom hook implementations. Receives custom hook instances from `FriendliClient` and adds them to the `SDKHookOrchestrator` for later invocation.
37-
38-
39-
**Related Classes/Methods**:
40-
41-
- <a href="https://github.com/CodeBoarding/friendli-python/blob/main/.codeboardingsrc/friendli_core/_hooks/registration.py#L8-L12" target="_blank" rel="noopener noreferrer">`friendli_core._hooks.registration.init_hooks`:8-12</a>
42-
43-
44-
### SDKHookOrchestrator
45-
The central component that manages the lifecycle of hooks, invoking them at appropriate stages of SDK operations. Stores and manages different types of hooks. It is responsible for invoking the correct hooks (e.g., `before_request`, `after_success`, `after_error`) when triggered by `HttpClient` or `SDKErrorProcessor`, ensuring they adhere to `HookDefinitions`.
15+
### Hooks & Extensibility Manager
16+
This component is responsible for managing the registration, discovery, and execution of various custom logic hooks throughout the SDK's lifecycle. It provides the core mechanism for extensibility.
4617

4718

4819
**Related Classes/Methods**:
4920

21+
- `friendli_core._hooks.registration.HookRegistrar`
5022
- <a href="https://github.com/CodeBoarding/friendli-python/blob/main/.codeboardingsrc/friendli_core/_hooks/sdkhooks.py#L22-L79" target="_blank" rel="noopener noreferrer">`friendli_core._hooks.sdkhooks.SDKHooks`:22-79</a>
5123

5224

53-
### HookDefinitions
54-
The collection of abstract interfaces and data structures that define the contract and context for all types of hooks. Defines the abstract base classes for various hook types (e.g., `SDKInitHook`, `BeforeRequestHook`) and their associated context objects, establishing the API for custom extensions.
55-
56-
57-
**Related Classes/Methods**:
58-
59-
- <a href="https://github.com/CodeBoarding/friendli-python/blob/main/.codeboardingsrc/friendli_core/_hooks/types.py#L100-L115" target="_blank" rel="noopener noreferrer">`friendli_core._hooks.types.Hooks`:100-115</a>
60-
- <a href="https://github.com/CodeBoarding/friendli-python/blob/main/.codeboardingsrc/friendli_core/_hooks/types.py#L67-L70" target="_blank" rel="noopener noreferrer">`friendli_core._hooks.types.SDKInitHook`:67-70</a>
61-
- <a href="https://github.com/CodeBoarding/friendli-python/blob/main/.codeboardingsrc/friendli_core/_hooks/types.py#L73-L78" target="_blank" rel="noopener noreferrer">`friendli_core._hooks.types.BeforeRequestHook`:73-78</a>
62-
- <a href="https://github.com/CodeBoarding/friendli-python/blob/main/.codeboardingsrc/friendli_core/_hooks/types.py#L81-L86" target="_blank" rel="noopener noreferrer">`friendli_core._hooks.types.AfterSuccessHook`:81-86</a>
63-
- <a href="https://github.com/CodeBoarding/friendli-python/blob/main/.codeboardingsrc/friendli_core/_hooks/types.py#L89-L97" target="_blank" rel="noopener noreferrer">`friendli_core._hooks.types.AfterErrorHook`:89-97</a>
64-
- <a href="https://github.com/CodeBoarding/friendli-python/blob/main/.codeboardingsrc/friendli_core/_hooks/types.py#L12-L31" target="_blank" rel="noopener noreferrer">`friendli_core._hooks.types.HookContext`:12-31</a>
65-
66-
67-
### HttpClient
68-
The underlying mechanism for making external network requests, which integrates with the hook system. Executes network requests. Before sending a request, it notifies the `SDKHookOrchestrator` to run `before_request` hooks. After receiving a response, it notifies the `SDKHookOrchestrator` to run `after_success` hooks.
69-
70-
71-
**Related Classes/Methods**:
72-
73-
- <a href="https://github.com/CodeBoarding/friendli-python/blob/main/.codeboardingsrc/friendli_core/httpclient.py#L11-L47" target="_blank" rel="noopener noreferrer">`friendli_core.httpclient.HttpClient`:11-47</a>
74-
75-
76-
### SDKErrorProcessor
77-
The part of the SDK responsible for handling exceptions and triggering error-specific hooks. Catches and processes exceptions during SDK operations. Upon an error, it notifies the `SDKHookOrchestrator` to run `after_error` hooks.
78-
79-
80-
**Related Classes/Methods**:
81-
82-
- <a href="https://github.com/CodeBoarding/friendli-python/blob/main/.codeboardingsrc/friendli_core/models/sdkerror.py#L12-L39" target="_blank" rel="noopener noreferrer">`friendli_core.SDKErrorProcessor`:12-39</a>
83-
84-
8525
### Unclassified
8626
Component for all unclassified files and utility functions (Utility functions/External Libraries/Dependencies)
8727

β€Ždocs/architecture/on_boarding.mdβ€Ž

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,12 @@ _Last updated: 2025-11-15 20:35:14 UTC_
187187
- [overview.md](./overview.md)
188188

189189
_Last updated: 2025-11-22 20:33:01 UTC_
190+
- [Data_Models_Error_Handling.md](./Data_Models_Error_Handling.md)
191+
- [Friendli_Client_Public_API_.md](./Friendli_Client_Public_API_.md)
192+
- [Hooks_Extensibility.md](./Hooks_Extensibility.md)
193+
- [Platform_Abstractions.md](./Platform_Abstractions.md)
194+
- [SDK_Core.md](./SDK_Core.md)
195+
- [Service_Modules.md](./Service_Modules.md)
196+
- [overview.md](./overview.md)
197+
198+
_Last updated: 2025-11-29 20:36:48 UTC_

0 commit comments

Comments
Β (0)