This commit is contained in:
maxime committed 2026-11-18 15:37:10 +01:00
1 parent 01317cb2f8
commit 8aa61da11a
1 file changed
+19 -18
+19 -18
View File
@@ -1,6 +1,6 @@
<mxfile host="Electron">
<diagram name="1. Architecture" id="arch">
<mxGraphModel dx="2678" dy="701" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1500" pageHeight="900" math="0" shadow="0">
<mxGraphModel dx="3204" dy="1013" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1500" pageHeight="900" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
@@ -129,44 +129,45 @@
<mxCell id="acc-allowed" edge="1" parent="1" source="acc-check" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;labelBackgroundColor=#ffffff;endArrow=classic;strokeColor=#d79b00;strokeWidth=2;dashed=1;fontColor=#b36b00;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" target="fix-7" value="allowed">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="acc-tool" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;dashed=1;strokeWidth=2;" value="&lt;b&gt;get_customer_access()&lt;/b&gt;&lt;br&gt;no parameter: called first, on Generate reply" vertex="1">
<mxCell id="acc-tool" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;strokeWidth=2;" value="&lt;b&gt;get_customer_access()&lt;/b&gt;&lt;br&gt;no parameter, on Generate reply&lt;br&gt;secret header Authorization: Bearer …" vertex="1">
<mxGeometry height="62" width="320" x="155" y="432" as="geometry" />
</mxCell>
<mxCell id="acc-e-conv" edge="1" parent="1" source="HigBPHvGvvlsroYYhkdi-3" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;labelBackgroundColor=#ffffff;endArrow=classic;strokeColor=#b85450;dashed=1;fontColor=#b85450;" target="acc-tool" value="contact identity&lt;br&gt;(X-Libredesk-Contact-*&lt;br&gt;headers, added by&lt;br&gt;LibreDesk, not the LLM)">
<mxCell id="acc-e-conv" edge="1" parent="1" source="HigBPHvGvvlsroYYhkdi-3" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;labelBackgroundColor=#ffffff;endArrow=classic;strokeColor=#b85450;fontColor=#b85450;" target="acc-tool" value="contact e-mail&lt;br&gt;(X-Libredesk-Contact-Email,&lt;br&gt;added by LibreDesk,&lt;br&gt;not the LLM)">
<mxGeometry relative="1" x="-0.1837" as="geometry">
<mxPoint as="offset" />
<Array as="points">
<mxPoint x="40" y="260" />
<mxPoint x="40" y="448" />
<mxPoint x="60" y="260" />
<mxPoint x="60" y="448" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="acc-svc" parent="1" style="rounded=1;arcSize=3;whiteSpace=wrap;html=1;verticalAlign=top;align=left;spacingLeft=8;fontStyle=1;fillColor=#fdf3f2;strokeColor=#b85450;dashed=1;strokeWidth=2;" value="Access service (independent container)" vertex="1">
<mxGeometry height="330" width="465" x="-390" y="740" as="geometry" />
<mxCell id="acc-svc" parent="1" style="rounded=1;arcSize=3;whiteSpace=wrap;html=1;verticalAlign=top;align=left;spacingLeft=8;fontStyle=1;fillColor=#fdf3f2;strokeColor=#b85450;strokeWidth=2;" value="Access service (independent container: acces/, Python stdlib) &lt;span style=&quot;font-weight:normal&quot;&gt;in service, provisional: Maxime&#39;s PC&lt;/span&gt;" vertex="1">
<mxGeometry height="350" width="465" x="-390" y="720" as="geometry" />
</mxCell>
<mxCell id="acc-api" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;dashed=1;strokeWidth=2;" value="&lt;b&gt;REST API&lt;/b&gt;&lt;br&gt;GET /customer/access (identity from the headers)&lt;br&gt;→ projects the customer may see: project, serial, role" vertex="1">
<mxCell id="acc-api" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;strokeWidth=2;" value="&lt;b&gt;REST API&lt;/b&gt;&lt;br&gt;GET /customer/access · Bearer token, else 401&lt;br&gt;→ {&quot;projects&quot;: [{project, serial, role}]}" vertex="1">
<mxGeometry height="80" width="425" x="-370" y="780" as="geometry" />
</mxCell>
<mxCell id="acc-lookup" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;dashed=1;strokeWidth=2;" value="&lt;b&gt;Rights lookup&lt;/b&gt;&lt;br&gt;contact e-mail → dashboard account (auth0|…)&lt;br&gt;→ its UserGroups (user / dev_admin) → Device.serial_number&lt;br&gt;unknown contact → empty list" vertex="1">
<mxCell id="acc-lookup" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;strokeWidth=2;" value="&lt;b&gt;Rights lookup&lt;/b&gt;&lt;br&gt;contact e-mail → dashboard accounts (auth0|…)&lt;br&gt;→ their UserGroups → Device (project, serial)&lt;br&gt;role: dev_admin wins over user&lt;br&gt;no e-mail, unknown or no rights → empty list&lt;br&gt;file or DB unreadable → 502, never an empty list" vertex="1">
<mxGeometry height="150" width="425" x="-370" y="890" as="geometry" />
</mxCell>
<mxCell id="acc-e-api" edge="1" parent="1" source="acc-api" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;labelBackgroundColor=#ffffff;endArrow=classic;strokeColor=#b85450;dashed=1;fontColor=#b85450;strokeWidth=2;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" target="acc-lookup" value="">
<mxCell id="acc-e-api" edge="1" parent="1" source="acc-api" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;labelBackgroundColor=#ffffff;endArrow=classic;strokeColor=#b85450;fontColor=#b85450;strokeWidth=2;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" target="acc-lookup" value="">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="acc-auth0" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" value="&lt;b&gt;utilisateurs.json&lt;/b&gt;&lt;br&gt;e-mail → auth0|…&lt;br&gt;exported once from Auth0" vertex="1">
<mxGeometry height="70" width="200" x="-390" y="1190" as="geometry" />
<mxCell id="acc-auth0" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" value="&lt;b&gt;utilisateurs.json&lt;/b&gt;&lt;br&gt;e-mail → auth0|…&lt;br&gt;Auth0 export (exporter_utilisateurs.py),&lt;br&gt;re-read on every call" vertex="1">
<mxGeometry height="80" width="200" x="-390" y="1185" as="geometry" />
</mxCell>
<mxCell id="acc-db" parent="1" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=10;fillColor=#f8cecc;strokeColor=#b85450;" value="&lt;b&gt;Access rights&lt;/b&gt; (dashboard DB)&lt;br&gt;&lt;b&gt;UserGroupEntry&lt;/b&gt;: user → UserGroup&lt;br&gt;&lt;b&gt;UserGroup&lt;/b&gt;: device × role (user · dev_admin)&lt;br&gt;&lt;b&gt;Device&lt;/b&gt;.serial_number (1..n per serial)" vertex="1">
<mxCell id="acc-db" parent="1" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=10;fillColor=#f8cecc;strokeColor=#b85450;" value="&lt;b&gt;Access rights&lt;/b&gt; (dashboard database.db, copy)&lt;br&gt;&lt;b&gt;UserGroupEntry&lt;/b&gt;: user → UserGroup&lt;br&gt;&lt;b&gt;UserGroup&lt;/b&gt;: device × role (user · dev_admin)&lt;br&gt;&lt;b&gt;Device&lt;/b&gt;: name, serial_number" vertex="1">
<mxGeometry height="120" width="245" x="-170" y="1165" as="geometry" />
</mxCell>
<mxCell id="acc-e-auth0" edge="1" parent="1" source="acc-lookup" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;labelBackgroundColor=#ffffff;endArrow=classic;strokeColor=#b85450;dashed=1;fontColor=#b85450;exitX=0.2;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" target="acc-auth0" value="e-mail → auth0|…">
<mxCell id="acc-e-auth0" edge="1" parent="1" source="acc-lookup" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;labelBackgroundColor=#ffffff;endArrow=classic;strokeColor=#b85450;fontColor=#b85450;exitX=0.2;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" target="acc-auth0" value="e-mail → auth0|…">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="acc-e-db" edge="1" parent="1" source="acc-lookup" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;labelBackgroundColor=#ffffff;endArrow=classic;strokeColor=#b85450;dashed=1;fontColor=#b85450;exitX=0.75;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" target="acc-db" value="read-only">
<mxCell id="acc-e-db" edge="1" parent="1" source="acc-lookup" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;labelBackgroundColor=#ffffff;endArrow=classic;strokeColor=#b85450;fontColor=#b85450;exitX=0.75;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" target="acc-db" value="read-only">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="acc-e-tool" edge="1" parent="1" source="acc-tool" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;labelBackgroundColor=#ffffff;endArrow=classic;strokeColor=#b85450;dashed=1;fontColor=#b85450;strokeWidth=2;exitX=0;exitY=0.75;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" target="acc-api" value="HTTP GET&lt;br&gt;+ identity headers">
<mxGeometry relative="1" as="geometry">
<mxCell id="acc-e-tool" edge="1" parent="1" source="acc-tool" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;labelBackgroundColor=#ffffff;endArrow=classic;strokeColor=#b85450;fontColor=#b85450;strokeWidth=2;exitX=0;exitY=0.75;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" target="acc-api" value="HTTP GET&lt;br&gt;+ Bearer token&lt;br&gt;+ contact e-mail">
<mxGeometry relative="1" x="0.1612" as="geometry">
<mxPoint as="offset" />
<Array as="points">
<mxPoint x="100" y="478" />
<mxPoint x="100" y="660" />
@@ -231,7 +232,7 @@
<mxCell id="gen-host-edge" edge="1" parent="1" source="gen-host" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;labelBackgroundColor=#ffffff;endArrow=classic;strokeColor=#999999;dashed=1;fontColor=#666666;exitX=0;exitY=0.5;exitDx=0;exitDy=0;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" target="gen-6" value="HTTP">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="gen-legend" parent="1" style="shape=note;whiteSpace=wrap;html=1;size=14;align=left;verticalAlign=top;spacingLeft=10;spacingTop=6;spacingRight=8;fillColor=#fff2cc;strokeColor=#d6b656;" value="&lt;b style=&quot;font-size:13px&quot;&gt;Reusable mechanism&lt;/b&gt;&lt;br&gt;&lt;br&gt;&lt;b&gt;1. Host app&lt;/b&gt; (here LibreDesk) triggers an action and sends context + tool list to the LLM.&lt;br&gt;&lt;b&gt;2. Tool&lt;/b&gt; = name + JSON schema + thin HTTP adapter. No business logic in the host.&lt;br&gt;&lt;b&gt;3. Independent service&lt;/b&gt; = container exposing a REST API; owns its domain logic and its data access, returns structured JSON.&lt;br&gt;&lt;b&gt;4.&lt;/b&gt; The LLM turns the tool result into the output (here a draft reviewed by a human).&lt;br&gt;&lt;b&gt;5. Access&lt;/b&gt;: on Generate reply the LLM first calls get_customer_access; LibreDesk adds the contact identity (headers), the access service returns the stations the customer may read (Auth0 export + UserGroup, the dashboard's rule). Each data service checks again with the same headers.&lt;br&gt;&lt;br&gt;New capability = one service + one tool declaration.&lt;br&gt;Same pattern for another host app (sales agent: CRM, quotes, stock…).&lt;br&gt;&lt;br&gt;&lt;b&gt;Legend&lt;/b&gt;&lt;br&gt;&lt;span style=&quot;color:#6c8ebf&quot;&gt;■&lt;/span&gt; existing LibreDesk&lt;br&gt;&lt;span style=&quot;color:#d79b00&quot;&gt;■&lt;/span&gt; dashed orange: this use case (planned)&lt;br&gt;&lt;span style=&quot;color:#b85450&quot;&gt;■&lt;/span&gt; red: access rights (planned)&lt;br&gt;&lt;span style=&quot;color:#9673a6&quot;&gt;■&lt;/span&gt; dashed purple: any other service, plugged the same way&lt;br&gt;&lt;span style=&quot;color:#999999&quot;&gt;■&lt;/span&gt; dashed grey: other consumers of the services" vertex="1">
<mxCell id="gen-legend" parent="1" style="shape=note;whiteSpace=wrap;html=1;size=14;align=left;verticalAlign=top;spacingLeft=10;spacingTop=6;spacingRight=8;fillColor=#fff2cc;strokeColor=#d6b656;" value="&lt;b style=&quot;font-size:13px&quot;&gt;Reusable mechanism&lt;/b&gt;&lt;br&gt;&lt;br&gt;&lt;b&gt;1. Host app&lt;/b&gt; (here LibreDesk) triggers an action and sends context + tool list to the LLM.&lt;br&gt;&lt;b&gt;2. Tool&lt;/b&gt; = name + JSON schema + thin HTTP adapter. No business logic in the host.&lt;br&gt;&lt;b&gt;3. Independent service&lt;/b&gt; = container exposing a REST API; owns its domain logic and its data access, returns structured JSON.&lt;br&gt;&lt;b&gt;4.&lt;/b&gt; The LLM turns the tool result into the output (here a draft reviewed by a human).&lt;br&gt;&lt;b&gt;5. Access&lt;/b&gt;: on Generate reply the LLM first calls get_customer_access; LibreDesk adds the contact identity (headers), the access service (Bearer token) returns the projects the customer may read (Auth0 export + UserGroup, the dashboard&#39;s rule). Each data service checks again with the same headers.&lt;br&gt;&lt;br&gt;New capability = one service + one tool declaration.&lt;br&gt;Same pattern for another host app (sales agent: CRM, quotes, stock…).&lt;br&gt;&lt;br&gt;&lt;b&gt;Legend&lt;/b&gt;&lt;br&gt;&lt;span style=&quot;color:#6c8ebf&quot;&gt;■&lt;/span&gt; existing LibreDesk&lt;br&gt;&lt;span style=&quot;color:#d79b00&quot;&gt;■&lt;/span&gt; dashed orange: this use case (planned)&lt;br&gt;&lt;span style=&quot;color:#b85450&quot;&gt;■&lt;/span&gt; red: access rights (solid: in service; dashed: planned)&lt;br&gt;&lt;span style=&quot;color:#9673a6&quot;&gt;■&lt;/span&gt; dashed purple: any other service, plugged the same way&lt;br&gt;&lt;span style=&quot;color:#999999&quot;&gt;■&lt;/span&gt; dashed grey: other consumers of the services" vertex="1">
<mxGeometry height="450" width="380" x="1000" y="160" as="geometry" />
</mxCell>
</root>