@prefix owl:     <http://www.w3.org/2002/07/owl#> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd:     <http://www.w3.org/2001/XMLSchema#> .
@prefix skos:    <http://www.w3.org/2004/02/skos/core#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix arch:    <https://meta.linked.archi/core#> .
@prefix bs:      <https://meta.linked.archi/backstage/onto#> .
@prefix :        <https://meta.linked.archi/examples/payflow/> .

#################################################################
# Model Declaration
#################################################################

:PayFlowModel
    a                          arch:Model ;
    skos:prefLabel             "PayFlow — Backstage Catalog Model"@en ;
    arch:modelConformsToMetamodel <https://meta.linked.archi/backstage/metamodel#Backstage> ;
    dcterms:created            "2025-06-27"^^xsd:date ;
    dcterms:creator            "Kalin Maldzhanski"^^xsd:string ;
    dcterms:description        "Backstage software catalog model for PayFlow — a fintech platform providing payment processing, merchant onboarding, and financial reporting."@en ;
.


#################################################################
# Domains
#################################################################

:PaymentsDomain
    a              bs:Domain ;
    skos:prefLabel "Payments"@en ;
    skos:definition "Domain covering payment processing, fraud detection, and payouts."@en ;
.

:MerchantDomain
    a              bs:Domain ;
    skos:prefLabel "Merchant Services"@en ;
    skos:definition "Domain covering merchant onboarding, reporting, and self-service."@en ;
.

:PlatformDomain
    a              bs:Domain ;
    skos:prefLabel "Platform"@en ;
    skos:definition "Domain covering shared infrastructure, observability, and developer tooling."@en ;
.


#################################################################
# Groups (Teams)
#################################################################

:PaymentsSquad
    a              bs:Group ;
    skos:prefLabel "Payments Squad"@en ;
    skos:definition "Squad responsible for payment processing, fraud, and payout services."@en ;
.

:MerchantSquad
    a              bs:Group ;
    skos:prefLabel "Merchant Squad"@en ;
    skos:definition "Squad responsible for merchant onboarding and reporting."@en ;
.

:PlatformTeam
    a              bs:Group ;
    skos:prefLabel "Platform Team"@en ;
    skos:definition "Team providing shared infrastructure and developer experience tooling."@en ;
.

:SRETeam
    a              bs:Group ;
    skos:prefLabel "SRE Team"@en ;
    skos:definition "Site Reliability Engineering team managing production reliability."@en ;
.


#################################################################
# Users
#################################################################

:AliceEngineer
    a              bs:User ;
    skos:prefLabel "alice.chen"@en ;
    skos:definition "Senior backend engineer in the Payments Squad specialising in transaction processing and fraud detection."@en ;
.

:BobPlatform
    a              bs:User ;
    skos:prefLabel "bob.eriksson"@en ;
    skos:definition "Platform engineer in the Platform Team responsible for shared infrastructure and developer tooling."@en ;
.

:AliceEngineer bs:memberOf :PaymentsSquad .
:BobPlatform bs:memberOf :PlatformTeam .


#################################################################
# Systems
#################################################################

:PaymentGateway
    a              bs:System ;
    skos:prefLabel "Payment Gateway"@en ;
    skos:definition "System handling payment processing, fraud detection, and merchant payouts."@en ;
.

:MerchantPortal
    a              bs:System ;
    skos:prefLabel "Merchant Portal"@en ;
    skos:definition "System providing merchant self-service, onboarding, and financial reporting."@en ;
.

:ObservabilityPlatform
    a              bs:System ;
    skos:prefLabel "Observability Platform"@en ;
    skos:definition "Shared system providing metrics, logging, tracing, and alerting."@en ;
.


#################################################################
# Components
#################################################################

:PaymentProcessor
    a              bs:Component ;
    skos:prefLabel "payment-processor"@en ;
    skos:definition "Core service processing payment transactions — authorisation, capture, refund."@en ;
    bs:lifecycle   "production" ;
.

:FraudService
    a              bs:Component ;
    skos:prefLabel "fraud-service"@en ;
    skos:definition "Real-time fraud scoring service using ML models to evaluate transaction risk before authorisation."@en ;
    bs:lifecycle   "production" ;
.

:PayoutService
    a              bs:Component ;
    skos:prefLabel "payout-service"@en ;
    skos:definition "Service managing scheduled merchant payouts and settlement."@en ;
    bs:lifecycle   "production" ;
.

:MerchantOnboarding
    a              bs:Component ;
    skos:prefLabel "merchant-onboarding"@en ;
    skos:definition "Service handling merchant registration, KYC, and account activation."@en ;
    bs:lifecycle   "production" ;
.

:ReportingService
    a              bs:Component ;
    skos:prefLabel "reporting-service"@en ;
    skos:definition "Service generating financial reports and analytics for merchants."@en ;
    bs:lifecycle   "experimental" ;
.

:WebhookDispatcher
    a              bs:Component ;
    skos:prefLabel "webhook-dispatcher"@en ;
    skos:definition "Platform service delivering event notifications to merchant webhook endpoints."@en ;
    bs:lifecycle   "production" ;
.


#################################################################
# APIs
#################################################################

:PaymentsAPI
    a              bs:API ;
    skos:prefLabel "Payments API (OpenAPI)"@en ;
    skos:definition "REST API for payment initiation, status, and refunds. OpenAPI 3.1 spec."@en ;
.

:MerchantAPI
    a              bs:API ;
    skos:prefLabel "Merchant API (OpenAPI)"@en ;
    skos:definition "REST API for merchant account management and configuration."@en ;
.

:PaymentEventsAPI
    a              bs:API ;
    skos:prefLabel "Payment Events (AsyncAPI)"@en ;
    skos:definition "Kafka-based event stream for payment lifecycle events. AsyncAPI 2.6 spec."@en ;
.

:FraudScoringAPI
    a              bs:API ;
    skos:prefLabel "Fraud Scoring API (gRPC)"@en ;
    skos:definition "Low-latency gRPC API for real-time transaction fraud scoring."@en ;
.


#################################################################
# Resources
#################################################################

:PaymentsDB
    a              bs:Resource ;
    skos:prefLabel "payments-db (PostgreSQL)"@en ;
    skos:definition "Primary PostgreSQL database for payment transactions and state."@en ;
.

:MerchantDB
    a              bs:Resource ;
    skos:prefLabel "merchant-db (PostgreSQL)"@en ;
    skos:definition "PostgreSQL database for merchant accounts and configuration."@en ;
.

:EventBus
    a              bs:Resource ;
    skos:prefLabel "event-bus (Kafka)"@en ;
    skos:definition "Apache Kafka cluster for event streaming between services."@en ;
.

:RedisCache
    a              bs:Resource ;
    skos:prefLabel "redis-cache"@en ;
    skos:definition "Redis cluster for session caching and rate limiting."@en ;
.


#################################################################
# Relationships — Ownership
#################################################################

:PaymentProcessor bs:ownedBy :PaymentsSquad .
:FraudService bs:ownedBy :PaymentsSquad .
:PayoutService bs:ownedBy :PaymentsSquad .
:MerchantOnboarding bs:ownedBy :MerchantSquad .
:ReportingService bs:ownedBy :MerchantSquad .
:WebhookDispatcher bs:ownedBy :PlatformTeam .
:PaymentGateway bs:ownedBy :PaymentsSquad .
:MerchantPortal bs:ownedBy :MerchantSquad .
:ObservabilityPlatform bs:ownedBy :SRETeam .


#################################################################
# Relationships — System Membership
#################################################################

:PaymentProcessor bs:partOfSystem :PaymentGateway .
:FraudService bs:partOfSystem :PaymentGateway .
:PayoutService bs:partOfSystem :PaymentGateway .
:WebhookDispatcher bs:partOfSystem :PaymentGateway .
:MerchantOnboarding bs:partOfSystem :MerchantPortal .
:ReportingService bs:partOfSystem :MerchantPortal .


#################################################################
# Relationships — API Provision
#################################################################

:PaymentProcessor bs:providesAPI :PaymentsAPI .
:PaymentProcessor bs:providesAPI :PaymentEventsAPI .
:FraudService bs:providesAPI :FraudScoringAPI .
:MerchantOnboarding bs:providesAPI :MerchantAPI .


#################################################################
# Relationships — API Consumption
#################################################################

:PayoutService bs:consumesAPI :PaymentsAPI .
:MerchantOnboarding bs:consumesAPI :PaymentsAPI .
:WebhookDispatcher bs:consumesAPI :PaymentEventsAPI .
:PaymentProcessor bs:consumesAPI :FraudScoringAPI .
:ReportingService bs:consumesAPI :PaymentsAPI .


#################################################################
# Relationships — Resource Usage
#################################################################

:PaymentProcessor bs:usesResource :PaymentsDB .
:PaymentProcessor bs:usesResource :EventBus .
:PaymentProcessor bs:usesResource :RedisCache .
:FraudService bs:usesResource :RedisCache .
:PayoutService bs:usesResource :PaymentsDB .
:MerchantOnboarding bs:usesResource :MerchantDB .
:WebhookDispatcher bs:usesResource :EventBus .
:ReportingService bs:usesResource :PaymentsDB .
:ReportingService bs:usesResource :MerchantDB .


#################################################################
# Relationships — Domain Membership
#################################################################

:PaymentGateway bs:belongsToDomain :PaymentsDomain .
:MerchantPortal bs:belongsToDomain :MerchantDomain .
:ObservabilityPlatform bs:belongsToDomain :PlatformDomain .


#################################################################
# Views
#################################################################

:PayFlowServiceCatalogView
    a                            arch:View ;
    skos:prefLabel               "PayFlow Service Catalog"@en ;
    arch:viewConformsToViewpoint <https://meta.linked.archi/backstage/viewpoints#ServiceCatalog> ;
.

:PayFlowAPIDependencyView
    a                            arch:View ;
    skos:prefLabel               "PayFlow API Dependency Map"@en ;
    arch:viewConformsToViewpoint <https://meta.linked.archi/backstage/viewpoints#APIDependency> ;
.

:PayFlowOwnershipView
    a                            arch:View ;
    skos:prefLabel               "PayFlow Ownership Matrix"@en ;
    arch:viewConformsToViewpoint <https://meta.linked.archi/backstage/viewpoints#OwnershipMatrix> ;
.
