Skip to content

Add api#501

Draft
jamesmoore wants to merge 18 commits intomainfrom
add-api
Draft

Add api#501
jamesmoore wants to merge 18 commits intomainfrom
add-api

Conversation

@jamesmoore
Copy link
Owner

@jamesmoore jamesmoore commented Mar 11, 2026

This pull request introduces the initial implementation of the SDMeta.Api project, setting up the API backend for the SDMeta application. The changes establish the project structure, core services, and essential API contracts, including file watching, image identification, scanning management, and configuration. The most important changes are grouped below:

Project Setup and Configuration:

  • Added the SDMeta.Api project file (SDMeta.Api.csproj) with dependencies for image processing, IO abstraction, and resilience (Polly). References the core SDMeta project.
  • Added launch settings for development and HTTPS support in launchSettings.json.
  • Implemented the main entry point in Program.cs, configuring dependency injection, CORS, static file serving, JSON serialization, and API endpoint mapping. Also sets up image codecs and initializes the database.

API Contracts and Data Structures:

  • Defined a comprehensive set of API contract records in ApiContracts.cs, including error, image, prompt, scan, and storage response types. These provide the data models for API endpoints.

Core Services and Utilities:

  • Implemented ImageIdCodec and ImagePathAuthorizer for encoding/decoding image identifiers and authorizing file paths, as well as a CursorCodec for paginated API responses.
  • Added ImageDirSettings for resolving image directory paths from configuration, supporting multiple directories.

File and Scan Management:

  • Introduced PendingFileChangeQueue to watch image directories for file changes (additions/removals) using FileSystemWatcher, supporting thread-safe queueing of changes for later processing.
  • Added ScanJobManager to manage full and partial scan jobs, including progress tracking, concurrent job state management, and error handling.
  • Provided RetryingFileLoader, a decorator for image file loading that adds retry and timeout logic using Polly for improved resilience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant