Repository navigation
Expand file tree
/
Copy pathopenapi.yaml
More file actions
1012 lines (943 loc) · 34.2 KB
/
Copy pathopenapi.yaml
File metadata and controls
1012 lines (943 loc) · 34.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
openapi: 3.1.0
info:
title: NotebookLM OSS Clone API
version: 0.1.0
description: |
Backend API for the NotebookLM OSS Clone. All routes are served by Next.js
Route Handlers. The server proxies document ingestion, chat, and search to
an OpenRAG instance; notebook/source/note metadata is managed locally.
REQ-ID references map each endpoint to the requirements in requirements.md.
## Frontend-only requirements (no API endpoint)
The following REQ-IDs are satisfied entirely in the browser and have no
corresponding API endpoint:
- REQ-005 Three-panel layout (CSS/component structure)
- REQ-010 Source selection checkboxes (React state; effect carried via
`selectedSourceIds` in POST /chat and POST /generate/* bodies)
- REQ-011 Source list search filter (client-side string filter, no server call)
- REQ-014 Chat history display (React state; conversation continuity via
`chatId` round-trip in the chat endpoint)
- REQ-015 Loading indicator while streaming (React state; signals are the
first SSE token arriving and the `done` event closing the stream)
- REQ-022 Empty state guidance (conditional rendering based on source count)
- REQ-023 Error communication (frontend displays errors from API responses;
the API contract is defined by the reusable error response schemas)
servers:
- url: http://localhost:3001
description: Local development server (Next.js app)
tags:
- name: notebooks
description: "Notebook CRUD — REQ-001, REQ-002, REQ-003, REQ-004"
- name: sources
description: |
Source management — REQ-006, REQ-007, REQ-008, REQ-009, REQ-012.
REQ-010 (source selection) has no dedicated endpoint: selection state lives in
the browser and is passed as `selectedSourceIds` to the chat and generate endpoints.
REQ-011 (source search) is a client-side display filter with no server involvement.
- name: chat
description: |
Streaming RAG chat — REQ-013, REQ-016.
REQ-014 (history display) is React state; conversation continuity is achieved via
the `chatId` field in the request/response contract of this endpoint.
REQ-015 (loading indicator) is frontend UX triggered by SSE stream open/close.
- name: notes
description: "Note CRUD — REQ-017, REQ-019, REQ-020, REQ-021"
- name: generate
description: "AI-generated studio artifacts — REQ-018, REQ-024, REQ-025"
# ─────────────────────────────────────────────────────────────────────────────
# PATHS
# ─────────────────────────────────────────────────────────────────────────────
paths:
# ── Notebooks ──────────────────────────────────────────────────────────────
/api/notebooks:
get:
operationId: listNotebooks
summary: List all notebooks
description: "REQ-002 — Returns all notebooks sorted by createdAt descending."
tags: [notebooks]
responses:
"200":
description: Notebook list
content:
application/json:
schema:
type: object
required: [notebooks]
properties:
notebooks:
type: array
items:
$ref: "#/components/schemas/NotebookSummary"
"500":
$ref: "#/components/responses/InternalServerError"
post:
operationId: createNotebook
summary: Create a notebook
description: "REQ-001 — Creates a new notebook and a corresponding OpenRAG knowledge filter."
tags: [notebooks]
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [name]
properties:
name:
type: string
minLength: 1
example: "Physics Notes"
responses:
"201":
description: Notebook created
content:
application/json:
schema:
$ref: "#/components/schemas/Notebook"
"400":
$ref: "#/components/responses/BadRequest"
"500":
$ref: "#/components/responses/InternalServerError"
/api/notebooks/{notebookId}:
parameters:
- $ref: "#/components/parameters/notebookId"
get:
operationId: getNotebook
summary: Get a notebook
description: "REQ-002 — Fetches a single notebook with its source count and note count."
tags: [notebooks]
responses:
"200":
description: Notebook detail
content:
application/json:
schema:
$ref: "#/components/schemas/Notebook"
"404":
$ref: "#/components/responses/NotFound"
"500":
$ref: "#/components/responses/InternalServerError"
patch:
operationId: updateNotebook
summary: Rename a notebook
description: "REQ-003 — Updates the notebook name. Empty name is rejected."
tags: [notebooks]
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [name]
properties:
name:
type: string
minLength: 1
example: "Advanced Physics"
responses:
"200":
description: Updated notebook
content:
application/json:
schema:
$ref: "#/components/schemas/Notebook"
"400":
$ref: "#/components/responses/BadRequest"
"404":
$ref: "#/components/responses/NotFound"
"500":
$ref: "#/components/responses/InternalServerError"
delete:
operationId: deleteNotebook
summary: Delete a notebook
description: |
REQ-004 — Deletes the notebook, all its sources (including removing them
from OpenRAG), all its notes, and its OpenRAG knowledge filter.
tags: [notebooks]
responses:
"204":
description: Notebook deleted
"404":
$ref: "#/components/responses/NotFound"
"500":
$ref: "#/components/responses/InternalServerError"
# ── Sources ────────────────────────────────────────────────────────────────
/api/notebooks/{notebookId}/sources:
parameters:
- $ref: "#/components/parameters/notebookId"
get:
operationId: listSources
summary: List sources in a notebook
description: "REQ-009 — Returns all sources for the notebook, ordered by createdAt ascending."
tags: [sources]
responses:
"200":
description: Source list
content:
application/json:
schema:
type: object
required: [sources]
properties:
sources:
type: array
items:
$ref: "#/components/schemas/Source"
"404":
$ref: "#/components/responses/NotFound"
"500":
$ref: "#/components/responses/InternalServerError"
/api/notebooks/{notebookId}/sources/text:
parameters:
- $ref: "#/components/parameters/notebookId"
post:
operationId: addTextSource
summary: Add a plain-text source
description: |
REQ-006 — Accepts pasted text, ingests it to OpenRAG as a .txt file,
and updates the notebook knowledge filter.
Returns 409 if identical text content already exists as a source.
tags: [sources]
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [body]
properties:
title:
type: string
description: "Optional. Defaults to first line of body, truncated to 60 chars."
body:
type: string
minLength: 1
description: Plain text content.
responses:
"201":
description: Source created
content:
application/json:
schema:
$ref: "#/components/schemas/Source"
"400":
$ref: "#/components/responses/BadRequest"
"404":
$ref: "#/components/responses/NotFound"
"409":
$ref: "#/components/responses/Conflict"
"500":
$ref: "#/components/responses/InternalServerError"
/api/notebooks/{notebookId}/sources/file:
parameters:
- $ref: "#/components/parameters/notebookId"
post:
operationId: addFileSource
summary: Upload a PDF source
description: |
REQ-007 — Accepts a multipart PDF upload, ingests to OpenRAG, and
updates the notebook knowledge filter.
Returns 400 for non-PDF files.
Returns 409 if a source with the same filename already exists.
Returns 422 if the PDF cannot be parsed (corrupted / password-protected).
tags: [sources]
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
required: [file]
properties:
file:
type: string
format: binary
description: PDF file. Must have content-type application/pdf.
title:
type: string
description: "Optional. Defaults to filename without extension."
responses:
"201":
description: Source created
content:
application/json:
schema:
$ref: "#/components/schemas/Source"
"400":
$ref: "#/components/responses/BadRequest"
"404":
$ref: "#/components/responses/NotFound"
"409":
$ref: "#/components/responses/Conflict"
"422":
$ref: "#/components/responses/UnprocessableEntity"
"500":
$ref: "#/components/responses/InternalServerError"
/api/notebooks/{notebookId}/sources/url:
parameters:
- $ref: "#/components/parameters/notebookId"
post:
operationId: addUrlSource
summary: Add a URL source
description: |
REQ-008 — Fetches the page server-side, extracts readable text, ingests
to OpenRAG as .txt, and updates the notebook knowledge filter.
Returns 409 if the same URL already exists as a source.
Returns 422 if the URL is unreachable or yields no readable text.
tags: [sources]
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [url]
properties:
url:
type: string
format: uri
example: "https://en.wikipedia.org/wiki/Retrieval-augmented_generation"
title:
type: string
description: "Optional. Defaults to the page <title> element."
responses:
"201":
description: Source created
content:
application/json:
schema:
$ref: "#/components/schemas/Source"
"400":
$ref: "#/components/responses/BadRequest"
"404":
$ref: "#/components/responses/NotFound"
"409":
$ref: "#/components/responses/Conflict"
"422":
$ref: "#/components/responses/UnprocessableEntity"
"500":
$ref: "#/components/responses/InternalServerError"
/api/notebooks/{notebookId}/sources/{sourceId}:
parameters:
- $ref: "#/components/parameters/notebookId"
- $ref: "#/components/parameters/sourceId"
delete:
operationId: deleteSource
summary: Remove a source from a notebook
description: |
REQ-012 — Deletes the source record, removes the document from OpenRAG,
and updates the notebook knowledge filter. Existing notes are not altered.
tags: [sources]
responses:
"204":
description: Source removed
"404":
$ref: "#/components/responses/NotFound"
"500":
$ref: "#/components/responses/InternalServerError"
# ── Chat ───────────────────────────────────────────────────────────────────
/api/notebooks/{notebookId}/chat:
parameters:
- $ref: "#/components/parameters/notebookId"
post:
operationId: chatWithSources
summary: Send a chat message (streaming SSE)
description: |
REQ-013, REQ-016 (partial) — Sends a message to OpenRAG scoped to the
selected sources via a knowledge filter. Streams the response as
Server-Sent Events.
REQ-010 (source selection) is implemented here: `selectedSourceIds`
determines which knowledge filter is applied. If it equals all source IDs
the notebook's persistent filter is used; otherwise an ephemeral filter
is created, used, then deleted in a finally block.
REQ-014 (conversation continuity) is implemented here: the `chatId`
returned in the `done` event must be passed back in subsequent requests
to maintain conversation context within a session.
If selectedSourceIds is empty the server returns 400.
SSE event types:
- `content` — incremental token delta
- `sources` — source citations for the response
- `done` — stream complete, carries chatId
- `error` — unrecoverable error during generation
tags: [chat]
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [message, selectedSourceIds]
properties:
message:
type: string
minLength: 1
example: "What is the maximum HP of the Azur character?"
selectedSourceIds:
type: array
items:
type: string
minItems: 1
description: IDs of sources to include in context. Must not be empty.
chatId:
type: ["string", "null"]
description: "OpenRAG chat ID from a previous response. Null or omitted starts a new conversation."
responses:
"200":
description: SSE stream
content:
text/event-stream:
schema:
type: string
description: |
Newline-delimited SSE events. Each event has the form:
event: {type}\ndata: {json}\n\n
Event payloads:
content: { "delta": "string" }
sources: { "sources": [ { "title": "string", "filename": "string" } ] }
done: { "chatId": "string" }
error: { "error": "string" }
"400":
$ref: "#/components/responses/BadRequest"
"404":
$ref: "#/components/responses/NotFound"
"429":
$ref: "#/components/responses/RateLimited"
"502":
$ref: "#/components/responses/BadGateway"
"500":
$ref: "#/components/responses/InternalServerError"
# ── Notes ──────────────────────────────────────────────────────────────────
/api/notebooks/{notebookId}/notes:
parameters:
- $ref: "#/components/parameters/notebookId"
get:
operationId: listNotes
summary: List notes in a notebook
description: "REQ-017 — Returns all notes ordered by createdAt descending."
tags: [notes]
responses:
"200":
description: Note list
content:
application/json:
schema:
type: object
required: [notes]
properties:
notes:
type: array
items:
$ref: "#/components/schemas/Note"
"404":
$ref: "#/components/responses/NotFound"
"500":
$ref: "#/components/responses/InternalServerError"
post:
operationId: createNote
summary: Create a note
description: |
REQ-016 (type=chat), REQ-019 (type=manual) — Creates a manual or
chat-saved note. AI-generated notes (overview, table, mindmap) are
created via /generate/* endpoints instead.
tags: [notes]
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/CreateNoteRequest"
responses:
"201":
description: Note created
content:
application/json:
schema:
$ref: "#/components/schemas/Note"
"400":
$ref: "#/components/responses/BadRequest"
"404":
$ref: "#/components/responses/NotFound"
"500":
$ref: "#/components/responses/InternalServerError"
/api/notebooks/{notebookId}/notes/{noteId}:
parameters:
- $ref: "#/components/parameters/notebookId"
- $ref: "#/components/parameters/noteId"
patch:
operationId: updateNote
summary: Edit a note
description: |
REQ-020 — Updates the title and/or body of any note type.
For table and mindmap notes only the title can be edited via this
endpoint; structured data is not hand-editable in the MVP.
Empty body is rejected.
tags: [notes]
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
title:
type: string
minLength: 1
body:
type: string
minLength: 1
description: "Only applicable for manual, chat, and overview note types."
minProperties: 1
responses:
"200":
description: Updated note
content:
application/json:
schema:
$ref: "#/components/schemas/Note"
"400":
$ref: "#/components/responses/BadRequest"
"404":
$ref: "#/components/responses/NotFound"
"500":
$ref: "#/components/responses/InternalServerError"
delete:
operationId: deleteNote
summary: Delete a note
description: "REQ-021 — Deletes a note. Irreversible."
tags: [notes]
responses:
"204":
description: Note deleted
"404":
$ref: "#/components/responses/NotFound"
"500":
$ref: "#/components/responses/InternalServerError"
# ── Generation ─────────────────────────────────────────────────────────────
/api/notebooks/{notebookId}/generate/overview:
parameters:
- $ref: "#/components/parameters/notebookId"
post:
operationId: generateOverview
summary: Generate an overview note
description: |
REQ-018 — Calls OpenRAG chat with a summarisation prompt scoped to the
selected sources. Saves the result as a new note of type "overview".
Each call creates a new note; existing overview notes are not replaced.
REQ-010 (source selection) is applied via `selectedSourceIds`.
tags: [generate]
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [selectedSourceIds]
properties:
selectedSourceIds:
type: array
items:
type: string
minItems: 1
responses:
"201":
description: Overview note created
content:
application/json:
schema:
$ref: "#/components/schemas/Note"
"400":
$ref: "#/components/responses/BadRequest"
"404":
$ref: "#/components/responses/NotFound"
"422":
$ref: "#/components/responses/UnprocessableEntity"
"429":
$ref: "#/components/responses/RateLimited"
"502":
$ref: "#/components/responses/BadGateway"
"500":
$ref: "#/components/responses/InternalServerError"
/api/notebooks/{notebookId}/generate/table:
parameters:
- $ref: "#/components/parameters/notebookId"
post:
operationId: generateTable
summary: Generate a data table note
description: |
REQ-024 — Calls OpenRAG chat with a structured extraction prompt scoped
to the selected sources. The model returns JSON with headers and rows.
Returns 422 if no clear tabular data can be extracted.
Saves the result as a new note of type "table".
REQ-010 (source selection) is applied via `selectedSourceIds`.
tags: [generate]
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [selectedSourceIds]
properties:
selectedSourceIds:
type: array
items:
type: string
minItems: 1
prompt:
type: ["string", "null"]
description: |
Optional focus prompt, e.g. "Compare each character's HP,
class, and abilities". Omit to let the AI decide.
example: "Compare each character's HP, class, and special abilities"
responses:
"201":
description: Data table note created
content:
application/json:
schema:
$ref: "#/components/schemas/Note"
"400":
$ref: "#/components/responses/BadRequest"
"404":
$ref: "#/components/responses/NotFound"
"422":
$ref: "#/components/responses/UnprocessableEntity"
"429":
$ref: "#/components/responses/RateLimited"
"502":
$ref: "#/components/responses/BadGateway"
"500":
$ref: "#/components/responses/InternalServerError"
/api/notebooks/{notebookId}/generate/mindmap:
parameters:
- $ref: "#/components/parameters/notebookId"
post:
operationId: generateMindMap
summary: Generate a mind map note
description: |
REQ-025 — Calls OpenRAG chat with a concept-extraction prompt scoped to
the selected sources. The model returns JSON with nodes and edges.
Returns 422 if fewer than two distinct concepts are identified.
Saves the result as a new note of type "mindmap".
REQ-010 (source selection) is applied via `selectedSourceIds`.
tags: [generate]
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [selectedSourceIds]
properties:
selectedSourceIds:
type: array
items:
type: string
minItems: 1
topic:
type: ["string", "null"]
description: |
Optional focus topic, e.g. "Combat mechanics". Omit to let
the AI select the central concept.
example: "Combat mechanics"
responses:
"201":
description: Mind map note created
content:
application/json:
schema:
$ref: "#/components/schemas/Note"
"400":
$ref: "#/components/responses/BadRequest"
"404":
$ref: "#/components/responses/NotFound"
"422":
$ref: "#/components/responses/UnprocessableEntity"
"429":
$ref: "#/components/responses/RateLimited"
"502":
$ref: "#/components/responses/BadGateway"
"500":
$ref: "#/components/responses/InternalServerError"
# ─────────────────────────────────────────────────────────────────────────────
# COMPONENTS
# ─────────────────────────────────────────────────────────────────────────────
components:
# ── Parameters ─────────────────────────────────────────────────────────────
parameters:
notebookId:
name: notebookId
in: path
required: true
schema:
type: string
description: UUID of the notebook.
sourceId:
name: sourceId
in: path
required: true
schema:
type: string
description: UUID of the source.
noteId:
name: noteId
in: path
required: true
schema:
type: string
description: UUID of the note.
# ── Schemas ────────────────────────────────────────────────────────────────
schemas:
NotebookSummary:
type: object
required: [id, name, sourceCount, noteCount, createdAt]
properties:
id:
type: string
example: "nb_abc123"
name:
type: string
example: "Physics Notes"
sourceCount:
type: integer
minimum: 0
noteCount:
type: integer
minimum: 0
createdAt:
type: string
format: date-time
Notebook:
allOf:
- $ref: "#/components/schemas/NotebookSummary"
- type: object
required: [openragFilterId]
properties:
openragFilterId:
type: string
description: ID of the associated OpenRAG knowledge filter.
example: "filter_xyz789"
Source:
type: object
required: [id, notebookId, title, type, openragFilename, createdAt]
properties:
id:
type: string
example: "src_def456"
notebookId:
type: string
example: "nb_abc123"
title:
type: string
example: "Lecture 3 — Thermodynamics"
type:
type: string
enum: [text, pdf, url]
url:
type: ["string", "null"]
format: uri
description: "Populated for type=url only."
openragFilename:
type: string
description: Filename key used in OpenRAG for this document.
example: "nb_abc123-src_def456.pdf"
createdAt:
type: string
format: date-time
Note:
type: object
required: [id, notebookId, title, type, createdAt, updatedAt]
properties:
id:
type: string
example: "note_ghi789"
notebookId:
type: string
example: "nb_abc123"
title:
type: string
example: "What is the max HP of Azur?"
type:
type: string
enum: [manual, chat, overview, table, mindmap]
body:
type: ["string", "null"]
description: "Plain text content. Present for manual, chat, and overview types."
tableData:
type: ["object", "null"]
description: "Present for type=table only."
required: [headers, rows]
properties:
headers:
type: array
items:
type: string
example: ["Character", "Class", "HP", "Special Ability"]
rows:
type: array
items:
type: array
items:
type: string
example: [["Azur", "Mage", "28", "Chain Lightning"]]
mindMapData:
type: ["object", "null"]
description: "Present for type=mindmap only."
required: [nodes, edges]
properties:
nodes:
type: array
items:
type: object
required: [id, label]
properties:
id:
type: string
label:
type: string
example: [{"id": "n1", "label": "Combat"}, {"id": "n2", "label": "Damage Types"}]
edges:
type: array
items:
type: object
required: [from, to, label]
properties:
from:
type: string
to:
type: string
label:
type: string
example: [{"from": "n1", "to": "n2", "label": "includes"}]
createdAt:
type: string
format: date-time
updatedAt:
type: string
format: date-time
CreateNoteRequest:
oneOf:
- title: ManualNoteRequest
description: "REQ-019 — User-written note. Title is optional."
type: object
required: [type, body]
additionalProperties: false
properties:
type:
type: string
enum: [manual]
title:
type: string
minLength: 1
description: "Optional. Defaults to first line of body truncated to 60 chars, or 'Untitled Note'."
body:
type: string
minLength: 1
- title: ChatNoteRequest
description: "REQ-016 — Note saved from an AI chat response. Title is required (the user's question)."
type: object
required: [type, title, body]
additionalProperties: false
properties:
type:
type: string
enum: [chat]
title:
type: string
minLength: 1
maxLength: 60
description: "The user's question that prompted the response, truncated to 60 chars."
body:
type: string
minLength: 1
description: "The full AI response text."
discriminator:
propertyName: type
ChatSourceRef:
type: object
required: [title, filename]
properties:
title:
type: string
filename:
type: string
description: OpenRAG filename of the source.
Error:
type: object
required: [error]
properties:
error:
type: string
description: Human-readable error message.
example: "Notebook not found."
code:
type: ["string", "null"]
description: Optional machine-readable error code.
example: "NOTEBOOK_NOT_FOUND"
# ── Reusable Responses ─────────────────────────────────────────────────────
responses:
BadRequest:
description: "400 — Invalid input (missing required field, empty string, wrong type)."
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
example:
error: "name must not be empty."
code: "VALIDATION_ERROR"
NotFound:
description: "404 — The requested resource does not exist."
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
example:
error: "Notebook not found."
code: "NOT_FOUND"
Conflict:
description: "409 — A duplicate resource already exists."
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
example:
error: "A source with this filename already exists in the notebook."
code: "DUPLICATE_SOURCE"
UnprocessableEntity:
description: |
422 — The request was well-formed but could not be processed.
Examples: PDF is password-protected, URL returned no readable text,
AI could not extract tabular data, fewer than two concepts identified.
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
example:
error: "Could not extract readable text from the provided URL."
code: "UNPROCESSABLE"
RateLimited:
description: "429 — OpenRAG rate limit reached. Retry after a short delay."
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
example:
error: "OpenRAG rate limit exceeded. Please try again shortly."
code: "RATE_LIMITED"
BadGateway:
description: "502 — OpenRAG returned an error or is unreachable."
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
example: