openapi: 3.1.0 info: # Do not change the title, if the title changes, the import paths will be broken title: Api version: 0.1.0 description: API specification servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: songs description: Song metadata operations - name: admin description: Admin configuration - name: auth description: Authentication - name: projects description: User projects paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check description: Returns server health status responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" /songs: get: operationId: listSongs tags: [songs] summary: List all songs description: Returns every song with full metadata, newest first responses: "200": description: A list of songs content: application/json: schema: type: array items: $ref: "#/components/schemas/Song" post: operationId: generateSong tags: [songs] summary: Generate metadata for a song description: Accepts a YouTube link or song name and generates full structured metadata using AI requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/SongInput" responses: "201": description: Song created with generated metadata content: application/json: schema: $ref: "#/components/schemas/Song" "400": description: Invalid input content: application/json: schema: $ref: "#/components/schemas/Error" "502": description: Generation failed content: application/json: schema: $ref: "#/components/schemas/Error" /songs/stats: get: operationId: getSongStats tags: [songs] summary: Library statistics description: Aggregate counts across the song library for the dashboard responses: "200": description: Library statistics content: application/json: schema: $ref: "#/components/schemas/SongStats" /admin/settings: get: operationId: getAdminSettings tags: [admin] summary: Get current AI provider settings responses: "200": description: Current settings content: application/json: schema: $ref: "#/components/schemas/AdminSettings" put: operationId: updateAdminSettings tags: [admin] summary: Update AI provider settings requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AdminSettings" responses: "200": description: Updated settings content: application/json: schema: $ref: "#/components/schemas/AdminSettings" /songs/export: get: operationId: exportAllSongs tags: [songs] summary: Export the entire library as one RAG file description: Returns a single combined JSON document containing every song's metadata responses: "200": description: Combined RAG export content: application/json: schema: $ref: "#/components/schemas/RagExport" /auth/register: post: operationId: register tags: [auth] summary: Register a new account requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AuthBody" responses: "201": description: Account created content: application/json: schema: $ref: "#/components/schemas/AuthUser" "409": description: Email already in use content: application/json: schema: $ref: "#/components/schemas/Error" /auth/login: post: operationId: login tags: [auth] summary: Log in requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AuthBody" responses: "200": description: Logged in content: application/json: schema: $ref: "#/components/schemas/AuthUser" "401": description: Invalid credentials content: application/json: schema: $ref: "#/components/schemas/Error" /auth/logout: post: operationId: logout tags: [auth] summary: Log out responses: "200": description: Logged out content: application/json: schema: type: object properties: ok: type: boolean required: [ok] /auth/me: get: operationId: getMe tags: [auth] summary: Get current user responses: "200": description: Current user content: application/json: schema: $ref: "#/components/schemas/AuthUser" "401": description: Not authenticated content: application/json: schema: $ref: "#/components/schemas/Error" /projects/public: get: operationId: getPublicProjects tags: [projects] summary: Public project gallery (6 newest public projects) responses: "200": description: Public projects content: application/json: schema: type: array items: $ref: "#/components/schemas/PublicProject" /projects: get: operationId: listProjects tags: [projects] summary: List my projects responses: "200": description: My projects content: application/json: schema: type: array items: $ref: "#/components/schemas/ProjectSummary" post: operationId: createProject tags: [projects] summary: Create a new project requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/NewProjectInput" responses: "201": description: Created project content: application/json: schema: $ref: "#/components/schemas/ProjectSummary" /projects/{projectId}: get: operationId: getProject tags: [projects] summary: Get project with entries parameters: - $ref: "#/components/parameters/ProjectId" responses: "200": description: Project with entries content: application/json: schema: $ref: "#/components/schemas/ProjectDetail" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/Error" patch: operationId: patchProject tags: [projects] summary: Update project title or visibility parameters: - $ref: "#/components/parameters/ProjectId" requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ProjectPatch" responses: "200": description: Updated project content: application/json: schema: $ref: "#/components/schemas/ProjectSummary" delete: operationId: deleteProject tags: [projects] summary: Delete a project parameters: - $ref: "#/components/parameters/ProjectId" responses: "204": description: Deleted /projects/{projectId}/entries: post: operationId: createEntry tags: [projects] summary: Add an entry to a project parameters: - $ref: "#/components/parameters/ProjectId" requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/NewEntryInput" responses: "201": description: Created entry content: application/json: schema: $ref: "#/components/schemas/Entry" /projects/{projectId}/entries/{entryId}: delete: operationId: deleteEntry tags: [projects] summary: Delete an entry parameters: - $ref: "#/components/parameters/ProjectId" - name: entryId in: path required: true schema: type: integer responses: "204": description: Deleted /projects/{projectId}/export: get: operationId: exportProject tags: [projects] summary: Export project as JSON parameters: - $ref: "#/components/parameters/ProjectId" responses: "200": description: Project export content: application/json: schema: type: object /projects/{projectId}/members: get: operationId: listProjectMembers tags: [projects] summary: List project members parameters: - $ref: "#/components/parameters/ProjectId" responses: "200": description: Project members content: application/json: schema: type: array items: $ref: "#/components/schemas/ProjectMember" post: operationId: addProjectMember tags: [projects] summary: Invite a user to the project by email (owner only) parameters: - $ref: "#/components/parameters/ProjectId" requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/InviteInput" responses: "200": description: Invite result content: application/json: schema: $ref: "#/components/schemas/InviteResult" /projects/{projectId}/members/{userId}: delete: operationId: removeProjectMember tags: [projects] summary: Remove a member, or leave the project parameters: - $ref: "#/components/parameters/ProjectId" - name: userId in: path required: true schema: type: integer responses: "204": description: Removed /projects/{projectId}/tasks: get: operationId: listTasks tags: [projects] summary: List tasks for a project parameters: - $ref: "#/components/parameters/ProjectId" responses: "200": description: Tasks content: application/json: schema: type: array items: $ref: "#/components/schemas/Task" post: operationId: createTask tags: [projects] summary: Create a task parameters: - $ref: "#/components/parameters/ProjectId" requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/NewTaskInput" responses: "201": description: Created task content: application/json: schema: $ref: "#/components/schemas/Task" /projects/{projectId}/tasks/{taskId}: patch: operationId: patchTask tags: [projects] summary: Update a task parameters: - $ref: "#/components/parameters/ProjectId" - name: taskId in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/TaskPatch" responses: "200": description: Updated task content: application/json: schema: $ref: "#/components/schemas/Task" delete: operationId: deleteTask tags: [projects] summary: Delete a task parameters: - $ref: "#/components/parameters/ProjectId" - name: taskId in: path required: true schema: type: integer responses: "204": description: Deleted /projects/{projectId}/tasks/suggest: post: operationId: suggestTasks tags: [projects] summary: AI-generated task suggestions for a project parameters: - $ref: "#/components/parameters/ProjectId" responses: "200": description: Suggested tasks content: application/json: schema: $ref: "#/components/schemas/TaskSuggestions" /projects/{projectId}/messages: get: operationId: listProjectMessages tags: [projects] summary: Poll project chat messages (supports ?after=&limit= query params) parameters: - $ref: "#/components/parameters/ProjectId" responses: "200": description: Chat messages content: application/json: schema: type: array items: $ref: "#/components/schemas/ProjectChatMessage" post: operationId: sendProjectMessage tags: [projects] summary: Send a chat message (mention @ai for an AI reply) parameters: - $ref: "#/components/parameters/ProjectId" requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/NewChatMessageInput" responses: "201": description: Sent message (and optional AI reply) content: application/json: schema: $ref: "#/components/schemas/ChatPostResponse" /admin/users: get: operationId: listUsers tags: [admin] summary: List all users responses: "200": description: All users content: application/json: schema: type: array items: $ref: "#/components/schemas/AdminUser" /admin/users/invite: post: operationId: inviteUser tags: [admin] summary: Invite a user by email requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/InviteInput" responses: "201": description: Invited user with temporary password content: application/json: schema: $ref: "#/components/schemas/InvitedUser" /admin/users/{userId}: patch: operationId: patchUser tags: [admin] summary: Approve or change user role parameters: - $ref: "#/components/parameters/UserId" requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UserRoleInput" responses: "200": description: Updated user content: application/json: schema: $ref: "#/components/schemas/AdminUser" delete: operationId: deleteUser tags: [admin] summary: Delete a user parameters: - $ref: "#/components/parameters/UserId" responses: "204": description: Deleted /songs/{id}/reanalyze: post: operationId: reanalyzeSong tags: [songs] summary: Re-analyze a full dossier for an existing song (returns draft for review) description: Reruns the complete AI pipeline and returns both the current song and the new draft metadata without writing to the database. The caller must POST to /songs/{id}/commit-draft to persist the draft. parameters: - $ref: "#/components/parameters/SongId" responses: "200": description: Current song alongside the newly generated draft metadata content: application/json: schema: $ref: "#/components/schemas/ReanalyzeDraftResponse" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/Error" "502": description: Generation failed content: application/json: schema: $ref: "#/components/schemas/Error" /songs/{id}/commit-draft: post: operationId: commitDraft tags: [songs] summary: Commit a previously generated draft to the database description: Accepts a draft SongMetadata produced by /songs/{id}/reanalyze and writes it to the song row, replacing the current metadata. parameters: - $ref: "#/components/parameters/SongId" requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CommitDraftInput" responses: "200": description: Song with the committed metadata content: application/json: schema: $ref: "#/components/schemas/Song" "400": description: Invalid draft payload content: application/json: schema: $ref: "#/components/schemas/Error" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/Error" /songs/{id}/reanalyze-dna: post: operationId: reanalyzeDna tags: [songs] summary: Re-analyze Musical DNA for an existing song description: Runs a knowledge-only DNA-focused prompt and merges maqamat, iqaat, and ornamentation into the song's metadata parameters: - $ref: "#/components/parameters/SongId" responses: "200": description: Song with updated Musical DNA fields content: application/json: schema: $ref: "#/components/schemas/Song" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/Error" "502": description: Generation failed content: application/json: schema: $ref: "#/components/schemas/Error" /songs/{id}: get: operationId: getSong tags: [songs] summary: Get a single song parameters: - $ref: "#/components/parameters/SongId" responses: "200": description: The song content: application/json: schema: $ref: "#/components/schemas/Song" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/Error" patch: operationId: updateSong tags: [songs] summary: Update a song's fields or metadata parameters: - $ref: "#/components/parameters/SongId" requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/SongUpdate" responses: "200": description: Updated song content: application/json: schema: $ref: "#/components/schemas/Song" "400": description: Invalid input content: application/json: schema: $ref: "#/components/schemas/Error" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/Error" delete: operationId: deleteSong tags: [songs] summary: Delete a song parameters: - $ref: "#/components/parameters/SongId" responses: "204": description: Deleted "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/Error" components: parameters: SongId: name: id in: path required: true schema: type: integer ProjectId: name: projectId in: path required: true schema: type: integer UserId: name: userId in: path required: true schema: type: integer schemas: HealthStatus: type: object properties: status: type: string required: - status Error: type: object properties: error: type: string required: - error TrackSegment: type: object description: A single interval in the detailed track breakdown properties: timestamp: type: string description: Start time of this interval, e.g. "0:00" or "1:24" label: type: string description: Section name, e.g. "Intro", "Verse 1", "Chorus", "Instrumental break" instruments: type: array items: type: string description: Instruments active during this interval vocals: type: string description: Vocal description for this interval (which voices, harmony, solo, etc.) notes: type: string description: Musical notes — key, tempo, mode, melodic motion, dynamics required: - timestamp - label - instruments - vocals - notes SongMetadata: type: object description: Full structured musicological metadata for a song properties: title: type: string singer: type: string description: Performing singer(s) composer: type: string era: type: string description: Time period / musical era geography: type: string description: Region or country of origin history: type: string description: Historical and cultural background subject: type: string description: Main theme or subject of the song relatedSubjects: type: array items: type: string dialect: type: string description: Language and dialect of the lyrics instruments: type: array items: type: string description: All instruments used voices: type: array items: type: string description: All distinct voices / vocal parts relatedWorks: type: array items: type: string transcription: type: string description: Full lyric transcription pronunciationNotes: type: string description: Detailed notes on how to pronounce the lyrics track: type: array items: $ref: "#/components/schemas/TrackSegment" description: Interval-by-interval breakdown of the music maqamat: type: array items: type: string description: > Melodic modes (Maqamat) present in the recording. Each entry names the maqam and its tonic, e.g. "Bayat — tonic: D, lowered 2nd & 6th" or "Sikah — tonic: E half-flat, characteristic neutral 3rd". iqaat: type: array items: type: string description: > Rhythmic cycles (Iqa'at) used. Each entry includes the name and time signature, e.g. "Maqsum 4/4", "Chobi 6/8", "Sama'i Thaqil 10/8". ornamentation: type: string nullable: true description: > Description of specific vocal and instrumental ornamentation techniques heard: melisma (tahrir), glottal ornaments, messa di voce, portamento, mordent, trill, vibrato, layali/mawwal phrases, etc. required: - title - singer - composer - era - geography - history - subject - relatedSubjects - dialect - instruments - voices - relatedWorks - transcription - pronunciationNotes - track Song: type: object properties: id: type: integer title: type: string singer: type: string era: type: string geography: type: string inputType: type: string enum: [youtube, name, file] inputValue: type: string metadata: $ref: "#/components/schemas/SongMetadata" createdAt: type: string analyzedAt: type: string description: ISO-8601 timestamp of when the dossier was last analyzed or re-analyzed generationNote: type: string description: > Present only when audio extraction was unavailable and the dossier was generated from knowledge only. Shown as an informational notice in the UI. required: - id - title - singer - era - geography - inputType - inputValue - metadata - createdAt - analyzedAt ReanalyzeDraftResponse: type: object description: Response from the reanalyze endpoint — current saved song plus the newly generated draft metadata (not yet written to DB) properties: current: $ref: "#/components/schemas/Song" draft: $ref: "#/components/schemas/SongMetadata" generationNote: type: string description: Present when the draft was generated from knowledge only (audio unavailable). required: - current - draft CommitDraftInput: type: object description: Draft metadata to commit to the song row properties: metadata: $ref: "#/components/schemas/SongMetadata" generationNote: type: string description: Optional generation note to persist alongside the committed metadata required: - metadata SongInput: type: object properties: input: type: string minLength: 1 description: A YouTube link or the name of a song required: - input SongUpdate: type: object description: Partial update for a song — supply any combination of top-level fields and/or full metadata properties: title: type: string singer: type: string era: type: string geography: type: string metadata: $ref: "#/components/schemas/SongMetadata" StatCount: type: object properties: label: type: string count: type: integer required: - label - count SongStats: type: object properties: total: type: integer byEra: type: array items: $ref: "#/components/schemas/StatCount" byGeography: type: array items: $ref: "#/components/schemas/StatCount" byDialect: type: array items: $ref: "#/components/schemas/StatCount" byMaqam: type: array items: $ref: "#/components/schemas/StatCount" byIqa: type: array items: $ref: "#/components/schemas/StatCount" required: - total - byEra - byGeography - byDialect - byMaqam - byIqa RagExport: type: object properties: generatedAt: type: string count: type: integer songs: type: array items: $ref: "#/components/schemas/Song" required: - generatedAt - count - songs AdminSettings: type: object properties: activeProvider: type: string enum: [gemini, claude, deepseek, siliconflow, flamingo] activeModel: type: string required: - activeProvider - activeModel AuthBody: type: object properties: email: type: string password: type: string required: [email, password] AuthUser: type: object properties: id: type: integer email: type: string role: type: string enum: [pending, user, admin] required: [id, email, role] AdminUser: type: object properties: id: type: integer email: type: string role: type: string enum: [pending, user, admin] createdAt: type: string required: [id, email, role, createdAt] InvitedUser: type: object properties: id: type: integer email: type: string role: type: string tempPassword: type: string required: [id, email, role, tempPassword] PublicProject: type: object properties: id: type: integer title: type: string category: type: string summary: type: string nullable: true createdAt: type: string ownerEmail: type: string entryCount: type: integer required: [id, title, category, createdAt, ownerEmail, entryCount] ProjectSummary: type: object properties: id: type: integer title: type: string category: type: string provider: type: string summary: type: string nullable: true isPublic: type: boolean createdAt: type: string entryCount: type: integer required: [id, title, category, provider, isPublic, createdAt, entryCount] NewProjectInput: type: object properties: title: type: string category: type: string enum: [rag-dataset, fine-tune, document, other] provider: type: string required: [title, category, provider] ProjectPatch: type: object properties: title: type: string isPublic: type: boolean NewEntryInput: type: object properties: inputUrl: type: string required: [inputUrl] InviteInput: type: object properties: email: type: string required: [email] UserRoleInput: type: object properties: role: type: string enum: [pending, user, admin] required: [role] EntryDescription: type: object properties: label: type: string text: type: string required: [label, text] Entry: type: object properties: id: type: integer projectId: type: integer inputUrl: type: string aiQuestion: type: string nullable: true descriptions: type: array items: $ref: "#/components/schemas/EntryDescription" createdAt: type: string required: [id, projectId, inputUrl, descriptions, createdAt] ProjectDetail: type: object properties: id: type: integer title: type: string category: type: string provider: type: string summary: type: string nullable: true isPublic: type: boolean createdAt: type: string role: type: string entries: type: array items: $ref: "#/components/schemas/Entry" required: [id, title, category, provider, isPublic, createdAt, role, entries] ProjectMember: type: object properties: id: type: integer email: type: string role: type: string addedAt: type: string required: [id, email, role, addedAt] InviteResult: type: object properties: found: type: boolean pending: type: boolean added: type: boolean id: type: integer email: type: string role: type: string required: [found] Task: type: object properties: id: type: integer projectId: type: integer title: type: string description: type: string nullable: true status: type: string enum: [todo, in_progress, done] assigneeId: type: integer nullable: true assigneeEmail: type: string nullable: true createdBy: type: integer dueDate: type: string nullable: true createdAt: type: string updatedAt: type: string required: [id, projectId, title, status, createdBy, createdAt, updatedAt] NewTaskInput: type: object properties: title: type: string description: type: string assigneeId: type: integer dueDate: type: string required: [title] TaskPatch: type: object properties: title: type: string description: type: string nullable: true status: type: string enum: [todo, in_progress, done] assigneeId: type: integer nullable: true dueDate: type: string nullable: true TaskSuggestion: type: object properties: title: type: string description: type: string required: [title, description] TaskSuggestions: type: object properties: suggestions: type: array items: $ref: "#/components/schemas/TaskSuggestion" required: [suggestions] ProjectChatMessage: type: object properties: id: type: integer content: type: string createdAt: type: string senderId: type: integer nullable: true isAi: type: boolean senderEmail: type: string nullable: true required: [id, content, createdAt, isAi] NewChatMessageInput: type: object properties: content: type: string required: [content] ChatPostResponse: type: object properties: message: $ref: "#/components/schemas/ProjectChatMessage" aiReply: $ref: "#/components/schemas/ProjectChatMessage" nullable: true required: [message]