Skip to content

Architecture

Valerio edited this page Aug 12, 2026 · 2 revisions

Architecture

UncannyPrompt is a layered .NET 10 monolith. The MVP runs as one web container plus SQL Server, but the project boundaries keep the domain, use cases, infrastructure, and HTTP edge separated.

Layered design

Presentation
  UncannyPrompt.WebApp
    Razor Pages, REST controllers, Developer API docs/key pages, auth, security middleware, Swagger, static assets

Application
  UncannyPrompt.Application
    DTOs, request models, service interfaces, service implementations, access-control query helpers

Domain
  UncannyPrompt.Domain
    entities, enums, domain concepts, no framework dependencies

Infrastructure
  UncannyPrompt.Infrastructure
    EF Core, SQL Server, repositories, unit of work, migrations, crypto primitives, configuration composition

Shared
  UncannyPrompt.Shared
    small cross-project constants such as authentication scheme names

Dependency rules

  • UncannyPrompt.Domain depends on nothing.
  • UncannyPrompt.Application depends on Domain and Shared.
  • UncannyPrompt.Infrastructure depends on Application, Domain, and Shared; it implements the interfaces consumed by application services.
  • UncannyPrompt.WebApp composes the application and infrastructure layers through dependency injection.
  • UncannyPrompt.UnitTests references the layers it verifies.

The repository-level layout follows that split:

src/       runtime projects
tests/     test projects
wiki/      source-controlled developer/operator documentation

Runtime topology

The reference deployment has two runtime services:

Service Responsibility
webapp ASP.NET Core Razor Pages UI and JSON API
sqlserver Transactional persistence through EF Core

There is no separate worker in the MVP. Prompt creation, versioning, sharing, resolution, copy logging, and audit all run in request/response flows through application services.

Domain model at a glance

  • Tenant - the top-level isolation boundary.
  • Workspace - a grouping unit inside a tenant.
  • Project - contains folders, prompts, variables, tags, and sharing boundaries.
  • Folder - hierarchical prompt organization inside a project.
  • Prompt - the main authored object with content, optional negative prompt, metadata, tags, favorites, and versions.
  • PromptVersion - immutable snapshot of content and negative prompt, used for version history and restore.
  • VariableDefinition / VariableValue - named placeholders and scoped values for prompt resolution.
  • ShareGrant - ACL grant for project, folder, or prompt targets.
  • PublicShareLink - anonymous prompt link with deterministic lookup hash plus verification hash.
  • AuditEvent - append-only record of security and operational events.

Main request flow

Browser/API caller
  -> WebApp controller or Razor Page
  -> Application service
  -> AccessControlQueries / TenantScopeService
  -> IRepository / IUnitOfWork
  -> EF Core DbContext
  -> SQL Server

Controllers and Razor Pages do not query EF directly. They call application services, which enforce tenant scope, resource permissions, validation, auditing, and persistence boundaries.

The left-menu Developers area is part of the WebApp presentation layer. It exposes authenticated API documentation and API key management while reusing the same UserApiKey, authentication handler, and application services used by API callers.

Prompt flow

Author creates prompt
  -> PromptService.CreateAsync
  -> PromptVersion #1
  -> tags/favorites/pins/listing projections

Author edits prompt content
  -> PromptService.UpdateAsync
  -> new PromptVersion only when content changes or explicit version metadata is provided

User resolves/copies prompt
  -> PromptResolutionService.ResolveAsync
  -> variable precedence applied
  -> PromptService.LogCopyAsync records usage/audit metadata

See Prompt Lifecycle and Variables and Resolution for the detailed behavior.

Entry points

Clone this wiki locally