Archive-Market은 Archive Platform Ecosystem의 외부 수요, 주문, 결제, 매출, 반품, 클레임 이벤트를 생성하고 주문별 수익성, 운영 자금, 인력 생산성까지 계산하는 Spring Boot 기반 Synthetic Commerce Backend입니다.
이 저장소는 실제 상거래 운영 시스템이 아니라 포트폴리오와 비즈니스 시뮬레이션을 위한 합성 데이터 기반 백엔드입니다. 실제 개인정보, 실제 주소, 실제 카드번호, 실제 결제정보, 실제 금융 데이터, 실제 PG/카드/배송사 API를 사용하지 않습니다.
- 외부 고객 수요와 주문 생성
- 결제, 매출, 환불, 클레임 이벤트 생성
- Archive-Nexus 생산/출하 요청 이벤트 생성
- Archive-Ledger 매출/환불/수수료 정산 이벤트 생성
- ArchiveOS가 읽을 economy, operations, profitability, cashflow summary 제공
- 주문별 예상 수익성, 위험도, 할인 가능 여부 평가
- 저마진/고위험 주문을 ArchiveOS 승인 대상으로 outbox 기록
- Nexus, Logistics, Ledger 실측 비용 이벤트를 주문 수익성 cost component에 반영
- 운영 자금, workforce capacity, backlog, productivity score 계산
- Archive-Market: 외부 수요, 주문, 결제, 매출, 수익성 판단, 운영 현금흐름
- Archive-Nexus: Market 주문 기반 생산, 재고, 출하 이벤트 생성
- Archive-Logistics: Nexus 출하 기반 배송, 운송비, 지연 비용 계산
- Archive-Ledger: Market 매출/환불/클레임, Nexus 비용, Logistics 비용 정산
- ArchiveOS: 손익, cash, risk, approval, settlement 상태 관제
flowchart LR
Customer[Synthetic Customer Demand<br/>B2B / Retail / VIP / Risk]
Market[Archive-Market<br/>Commerce Backend]
Pricing[Profitability & Pricing Engine<br/>Margin / Risk / Discount]
Capital[Working Capital & Workforce<br/>Cashflow / Capacity / Backlog]
Outbox[Market Outbox<br/>Idempotency / Retry / Dry-run]
Nexus[Archive-Nexus<br/>Production / Shipment]
Logistics[Archive-Logistics<br/>Delivery / Logistics Cost]
Ledger[Archive-Ledger<br/>Revenue / Refund / Settlement]
OS[ArchiveOS<br/>Control Tower / Approval]
Customer -->|demand / order| Market
Market -->|order amount / customer risk| Pricing
Market -->|orders / payments / claims| Capital
Pricing -->|ACCEPT| Market
Pricing -->|REVIEW_REQUIRED / risk event| Outbox
Capital -->|capacity / backlog / cash pressure| Market
Market -->|commerce events| Outbox
Outbox -->|MARKET_ORDER_PLACED / PRODUCTION_REQUESTED / SHIPMENT_REQUESTED| Nexus
Nexus -->|confirmed production cost callback| Market
Nexus -->|shipment event| Logistics
Logistics -->|confirmed logistics cost callback| Market
Outbox -->|SALES_REVENUE_CONFIRMED / PAYMENT_CAPTURED / REFUND_REQUESTED| Ledger
Ledger -->|settlement fee / payment fee callback| Market
Outbox -->|ORDER_REQUIRES_REVIEW / LOW_MARGIN_ORDER_DETECTED| OS
Market -->|economy / profitability / cashflow APIs| OS
Nexus -->|summary APIs| OS
Logistics -->|summary APIs| OS
Ledger -->|summary APIs| OS
- Java 21
- Spring Boot 3.x
- Gradle
- Spring Web / Validation / Data JPA
- PostgreSQL
- Flyway
- Spring Batch
- Actuator / Micrometer
- springdoc-openapi
- JUnit 5 / AssertJ / Testcontainers
- Docker / Docker Compose
- GitHub Actions
docker compose up --build -d
curl.exe http://localhost:8094/actuator/health
curl.exe http://localhost:8094/api/operations/summary기본 포트:
- 애플리케이션:
8094 - PostgreSQL:
15435:5432
기본 profile:
local
- 홈페이지:
http://localhost:8094/ - 운영 대시보드:
http://localhost:8094/dashboard/ - Swagger UI:
http://localhost:8094/swagger-ui/index.html - Health:
http://localhost:8094/actuator/health
정적 웹 화면, 브라우저 북마크 아이콘, README 브랜드 이미지는 Archive 로고를 기반으로 구성했습니다.
src/main/resources/static/assets/archive-logo.pngsrc/main/resources/static/assets/archive-market-lockup.svgdocs/brand/archive-market-lockup.svg
대시보드는 최근 추가된 다국어 흐름에 맞춰 한국어 중심 UI를 기본으로 구성하고, 운영 요약과 Market 지표를 바로 확인할 수 있게 만들었습니다.
GET /actuator/healthGET /actuator/infoGET /actuator/metricsGET /api/operations/summaryGET /api/runtime/statusGET /api/runtime-events/recent?limit=100GET /api/runtime-events/recent?after={cursor}&limit=100GET /api/runtime-events/correlation/{correlationId}GET /api/runtime-events/entity/{entityId}
GET /api/customersGET /api/customers/{customerId}/risk-profilePOST /api/customers/{customerId}/risk-profile/recalculateGET /api/productsPOST /api/products/seed
POST /api/ordersPOST /api/orders/simulate?count=100GET /api/ordersGET /api/orders/{orderId}POST /api/orders/{orderId}/confirmPOST /api/orders/{orderId}/cancelPOST /api/payments/capture?orderId={orderId}POST /api/payments/refund?orderId={orderId}GET /api/payments
GET /api/pricing/policiesPOST /api/pricing/policies/seedPOST /api/pricing/recommendPOST /api/orders/{orderId}/profitability/evaluateGET /api/orders/{orderId}/profitabilityGET /api/orders/{orderId}/profitability/cost-adjustmentsGET /api/market-profitability/summaryGET /api/market-profitability/assessmentsGET /api/customers/{customerId}/risk-profilePOST /api/customers/{customerId}/risk-profile/recalculate
POST /api/returns?orderId={orderId}POST /api/claims?orderId={orderId}GET /api/returnsGET /api/claims
GET /api/market-economy/summaryGET /api/market-economy/revenue-eventsGET /api/market-economy/cost-eventsGET /api/market-economy/profit-snapshotsPOST /api/market-economy/daily-close?date=YYYY-MM-DDGET /api/outbox/summaryGET /api/outbox/eventsPOST /api/outbox/publishPOST /api/outbox/retry-failedPOST /api/events/externalPOST /api/events/external/bulkGET /api/events/inbox
GET /api/market-cashflow/summaryGET /api/market-workforce/summaryGET /api/market-productivity/summaryGET /api/workforce/summaryGET /api/productivity/summaryGET /api/capacity/summaryPOST /api/market-workforce/allocate
Runtime Mesh V1 계약은 archive-runtime-mesh-contract.md, ArchiveOS 수집/전송 방식은 archiveos-realtime-integration.md, 운영 점검은 runtime-operations-runbook.md를 참고한다. 이 조회 API들은 모두 read-only이며, workforce 데이터가 아직 없으면 임의의 0값 대신 available=false, status=NO_DATA를 반환한다.
Runtime Balance separates gmv, recognizedRevenue, grossSalesEvents, totalExpense, operatingProfit, operatingMargin, cash, reserve, payable, workforce, and capacity metrics. GMV is order scale, not Market revenue or profit. Auto-run captures and requests production only for ACCEPT orders; review and rejection recommendations remain pending.
POST /api/simulations/demand?count=100POST /api/simulations/orders?count=100POST /api/simulations/profitability?count=100POST /api/simulations/workday/run?date=YYYY-MM-DDPOST /api/simulations/day/run?date=YYYY-MM-DD
local/demo 환경에서는 ArchiveOS Live Flow가 멈춰 보이지 않도록 제한된 속도의 synthetic runtime work loop를 실행할 수 있습니다.
기본 설정:
archive.runtime.autorun.enabled=truearchive.runtime.autorun.scheduler-enabled=truearchive.runtime.tick-interval=30sarchive.runtime.max-events-per-tick=10archive.runtime.max-backlog-per-tick=50
tick은 작은 synthetic 주문 흐름을 진행합니다.
- synthetic demand/order 생성
- 주문 확정
- synthetic payment capture
- profitability assessment
- Nexus/Ledger/ArchiveOS 대상 outbox 생성
- 예산이 남으면 workday snapshot 생성
안전장치:
- 같은 tick bucket 중복 실행 방지
- scheduler lock
- tick당 work budget 제한
- backlog threshold 초과 시 신규 주문 생성 중단
- integration disabled 상태에서는 외부 write 없이 outbox에만 기록
상태 확인:
curl.exe http://localhost:8094/api/runtime/statusArchive-Market은 주문을 무조건 확정하지 않고 예상 매출과 예상 비용을 계산해 주문별 recommendation을 남깁니다.
Expected Revenue:
- 주문 금액
- Express order fee
- Service contract revenue
- Premium handling fee
Expected Cost:
- 예상 생산 비용
- 예상 물류 비용
- Ledger 정산 수수료
- 결제 처리 수수료
- 할인 비용
- 기대 반품 비용
- 기대 클레임 비용
- 고객 획득 비용
- Market 운영 비용
계산식:
Expected Profit = Expected Revenue - Expected Cost
Expected Margin Rate = Expected Profit / Expected Revenue * 100
추천 결과:
ACCEPTREVIEW_REQUIREDREJECT_RECOMMENDED
REJECT_RECOMMENDED는 권고값이며 주문을 자동 취소하지 않습니다. 실제 취소나 승인은 별도 API 또는 ArchiveOS 의사결정 흐름에서 처리하도록 설계했습니다.
기본 정책 예:
- 결제 처리 수수료율:
2.0% - Ledger 정산 수수료율:
0.3% - Ledger 고정 수수료:
100 KRW - 기본 물류비 추정:
50,000 KRW - 긴급 물류 surcharge:
30,000 KRW - DISCOUNT_SEEKER 할인율:
10% - VIP_CUSTOMER 할인율:
5% - B2B_CUSTOMER 할인율:
3%
Nexus, Logistics, Ledger가 보내는 synthetic 실측 비용 이벤트는 기존 external inbox로 수신합니다.
- Archive-Nexus: 생산/제조 비용을
PRODUCTION_COST에 반영 - Archive-Logistics: 배송/운송 비용을
LOGISTICS_COST에 반영 - Archive-Ledger: 정산 수수료와 결제 처리 수수료를
LEDGER_SETTLEMENT_FEE,PAYMENT_PROCESSING_FEE에 반영
적용된 비용 조정은 profitability_cost_component_adjustment에 기록하고, 기존 order_profitability_assessment의 총비용, 예상이익, 마진율, recommendation을 재계산합니다. 실측 비용 어댑터는 외부 이벤트 수신에 따른 재평가만 수행하며 ArchiveOS review 이벤트를 다시 발행하지 않아 순환 이벤트를 방지합니다.
Archive-Market은 Ledger의 최종 정산/원장 기준과 별개로 Market 운영 현금흐름을 표시합니다.
Archive-Market은 총거래액 전체를 Market 이익으로 보지 않습니다. GET /api/market-economy/summary는 GMV와 Market 인식 매출을 분리합니다.
gmv: 주문 총액 기준 synthetic 총거래액grossSalesEvents: 과거/계약 호환용 gross sales event 합계recognizedRevenue: platform fee, payment processing fee revenue, optional service fee, B2B/service fee 등 Market이 실제 인식하는 수수료성 매출totalExpense: Nexus 생산 구매비, Logistics fulfillment fee, Ledger settlement agency fee, ArchiveOS control tower fee, payroll, promotion/coupon, refund/claim/risk reserve 등 비용 합계operatingProfit:recognizedRevenue - totalExpensecashBalance: synthetic opening cash에 인식 매출을 더하고 비용 및 pending settlement를 차감한 운영 현금reserveBalance: refund/claim/risk reserve 합계outstandingPayables: Nexus/Logistics/Ledger/ArchiveOS로 지급해야 하는 synthetic payable 합계cashDeltaReason,topRevenueDrivers,topExpenseDrivers: Market 보유자금 변동 원인을 설명하기 위한 관제 필드
결제 캡처 시 Market은 synthetic fee revenue와 함께 다음 비용/지급 이벤트를 생성합니다.
PRODUCTION_PURCHASE_COST_INCURRED-> Archive-NexusLOGISTICS_FULFILLMENT_FEE_INCURRED-> Archive-LogisticsSETTLEMENT_AGENCY_FEE_INCURRED-> Archive-LedgerCONTROL_TOWER_FEE_INCURRED-> ArchiveOSREFUND_RESERVE_BOOKEDCLAIM_RESERVE_BOOKEDRISK_RESERVE_ALLOCATED
이 구조는 GMV가 커져도 Market의 이익률이 과도하게 높아 보이지 않도록, 생태계 서비스로 흘러가는 비용과 reserve allocation을 함께 반영합니다.
누적 synthetic data에 따라 operatingProfit은 음수일 수 있으며, 이는 Market이 총 주문 규모 전체가 아니라 수수료성 인식 매출에서 production/logistics/settlement/control tower 비용과 reserve를 차감하는 구조를 반영한 결과입니다.
Cashflow 항목:
availableCashexpectedReceivablependingSettlementAmountpayrollCostproductionRequestCostlogisticsRequestCostledgerFeenetProfitworkingCapital
Synthetic workforce 역할:
ORDER_OPERATORPRICING_ANALYSTCUSTOMER_SUPPORTCLAIM_HANDLERMARKET_MANAGER
각 역할은 capacityPerDay, wagePerDay, productivityScore를 가집니다. 주문 수가 workforce capacity를 초과하면 backlog로 계산하고, backlog가 커질수록 cancellationRate, claimRate, delayRisk가 증가합니다.
Summary GET API는 read-only입니다. GET /api/operations/summary, GET /api/market-economy/summary, GET /api/market-workforce/summary, GET /api/market-cashflow/summary, GET /api/market-productivity/summary는 workforce allocation seed/insert를 수행하지 않고, 데이터가 없으면 0 또는 empty summary를 반환합니다.
Workforce allocation은 workdayId + workforceRole 기준으로 idempotent하게 upsert됩니다. market_workforce_allocation_workforce_role_key duplicate 오류가 보이면 V7 migration 적용 여부를 확인해야 합니다.
Productivity summary는 다음 의사결정 힌트를 제공합니다.
- 인력 증원
- 할인 축소
- 고위험 주문 보류
- 클레임 처리 우선순위 조정
Outbox target:
NEXUSLEDGERARCHIVE_OS
Nexus 이벤트:
MARKET_ORDER_PLACEDPRODUCTION_REQUESTEDSHIPMENT_REQUESTEDORDER_CANCELLEDRETURN_REQUESTEDQUALITY_CLAIM_CREATED
Ledger 이벤트:
SALES_REVENUE_CONFIRMEDPAYMENT_CAPTUREDREFUND_REQUESTEDCLAIM_COMPENSATION_CONFIRMEDMARKET_SERVICE_FEE_PAIDPAYMENT_PROCESSING_FEE_PAID
ArchiveOS review 이벤트:
ORDER_REQUIRES_REVIEWLOW_MARGIN_ORDER_DETECTEDHIGH_RISK_ORDER_DETECTED
모든 외부 이벤트 envelope에는 순환 방지를 위해 다음 필드를 포함합니다.
simulationRunIdsettlementCycleIdcorrelationIdcausationIdhopCountmaxHopidempotencyKey
안전 규칙:
hopCount > maxHop이벤트는 거부 또는 publish 차단eventId또는idempotencyKey중복 이벤트는 재처리하지 않음- payment/refund/review/fee 이벤트가 다시 무한 평가나 fee 이벤트를 만들지 않도록 상태와 idempotency로 방어
- 실측 비용 어댑터는 assessment cost component만 갱신하고 review outbox를 재발행하지 않음
V1__init_market_schema.sql: Market 기본 도메인, outbox/inbox, audit, daily closeV2__create_spring_batch_tables.sql: Spring Batch 메타 테이블V3__add_indexes.sql: 조회/중복 방지 인덱스V4__add_profitability_pricing_engine.sql: pricing policy, profitability assessment, risk profile, price recommendationV5__add_profitability_cost_component_adjustments.sql: 실측 비용 component adjustmentV6__add_working_capital_workforce_model.sql: workforce allocation, workday snapshotV7__fix_workforce_allocation_idempotency.sql: workforce role 단독 unique 제거,workday_id + workforce_role복합 unique 적용
curl.exe -X POST http://localhost:8094/api/products/seed
curl.exe -X POST "http://localhost:8094/api/simulations/orders?count=100"
curl.exe http://localhost:8094/api/operations/summary
curl.exe http://localhost:8094/api/market-economy/summary
curl.exe http://localhost:8094/api/market-profitability/summary
curl.exe http://localhost:8094/api/market-cashflow/summary
curl.exe http://localhost:8094/api/market-workforce/summary
curl.exe http://localhost:8094/api/market-productivity/summary
curl.exe http://localhost:8094/api/outbox/summary
curl.exe -X POST http://localhost:8094/api/outbox/publishmarket.integration.enabled=false이면 outbox publish는 Nexus, Ledger, ArchiveOS를 실제 호출하지 않고 DRY_RUN 또는 SKIPPED 상태로 처리합니다.
.\gradlew.bat test --no-daemon --console=plain
.\gradlew.bat build --no-daemon --console=plain
docker compose config --quietdocs/architecture.mddocs/event-contract.mddocs/runtime-event-contract.mddocs/market-runtime-event-contract.mddocs/market-workforce-model.mddocs/operations-summary-contract.mddocs/archiveos-live-flow-contract.mddocs/market-economy-model.mddocs/profitability-engine.mddocs/pricing-policy.mddocs/customer-risk-profile.mddocs/measured-cost-adapters.mddocs/archiveos-review-event-contract.mddocs/nexus-integration-contract.mddocs/ledger-integration-contract.mddocs/archiveos-integration-contract.mddocs/simulation-scenario.mddocs/operations-runbook.mddocs/portfolio-bullets.mddocs/api-examples.http
Nexus는 Market outbox의 MARKET_ORDER_PLACED, PRODUCTION_REQUESTED, SHIPMENT_REQUESTED 이벤트를 기준으로 생산/출하 흐름을 시작하면 됩니다. 생산 실측 비용이 확정되면 POST /api/events/external로 synthetic production cost 이벤트를 보내 Market profitability assessment를 갱신할 수 있습니다.
Logistics는 Nexus 출하 이후 배송/운송 비용을 계산하고, synthetic logistics cost 이벤트를 POST /api/events/external로 전달하면 Market의 LOGISTICS_COST component에 반영됩니다.
Ledger는 Market의 SALES_REVENUE_CONFIRMED, PAYMENT_CAPTURED, REFUND_REQUESTED, CLAIM_COMPENSATION_CONFIRMED 이벤트를 정산 기준으로 처리합니다. 정산 수수료나 결제 처리 수수료가 확정되면 external inbox로 실측 비용 이벤트를 보내 Market 평가 비용을 보정할 수 있습니다.
ArchiveOS는 다음 API를 읽어 Market의 수요, 매출, 수익성, 자금, 인력 상태를 관제하면 됩니다.
GET /api/market-economy/summaryGET /api/operations/summaryGET /api/outbox/summaryGET /api/ordersGET /api/claimsGET /api/returnsGET /api/market-profitability/summaryGET /api/market-cashflow/summaryGET /api/market-workforce/summaryGET /api/market-productivity/summary