Skip to content

Commit b7ef8b9

Browse files
authored
feat: Add reconciliation and forecasting services to Tiltfile (#931)
1 parent 24fc2b3 commit b7ef8b9

4 files changed

Lines changed: 187 additions & 2 deletions

File tree

Tiltfile

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ db_urls = {
8888
'party': os.getenv('PARTY_DATABASE_URL', 'postgres://meridian_party_user@cockroachdb:26257/meridian_party?sslmode=disable'),
8989
'internal_bank_account': os.getenv('INTERNAL_BANK_ACCOUNT_DATABASE_URL', 'postgres://meridian_internal_bank_account_user@cockroachdb:26257/meridian_internal_bank_account?sslmode=disable'),
9090
'market_information': os.getenv('MARKET_INFORMATION_DATABASE_URL', 'postgres://meridian_market_information_user@cockroachdb:26257/meridian_market_information?sslmode=disable'),
91+
'reconciliation': os.getenv('RECONCILIATION_DATABASE_URL', 'postgres://meridian_reconciliation_user@cockroachdb:26257/meridian_reconciliation?sslmode=disable'),
92+
'forecasting': os.getenv('FORECASTING_DATABASE_URL', 'postgres://meridian_forecasting_user@cockroachdb:26257/meridian_forecasting?sslmode=disable'),
9193
}
9294

9395
# NOTE: Migrations now run as Kubernetes Jobs inside the cluster
@@ -474,6 +476,8 @@ k8s_resource(
474476
# - Tenant: 50056
475477
# - InternalBankAccount: 50057
476478
# - MarketInformation: 50058
479+
# - Reconciliation: 50060
480+
# - Forecasting: 50061
477481
# - Gateway (HTTP): 8080
478482
# - HTTPHealth: 8081
479483
# - HTTPMetrics: 9090
@@ -534,6 +538,20 @@ grpc_microservice(
534538
resource_deps=['cockroachdb', 'migrate-market-information'],
535539
)
536540

541+
# Reconciliation Service - gRPC microservice for reconciliation processes and settlement
542+
grpc_microservice(
543+
'reconciliation',
544+
grpc_port=50060, # ports.Reconciliation
545+
resource_deps=['cockroachdb', 'migrate-reconciliation', 'position-keeping', 'current-account'],
546+
)
547+
548+
# Forecasting Service - gRPC microservice for forecasting strategies and forward curves
549+
grpc_microservice(
550+
'forecasting',
551+
grpc_port=50061, # ports.Forecasting
552+
resource_deps=['cockroachdb', 'migrate-forecasting', 'market-information'],
553+
)
554+
537555
# =============================================================================
538556
# Gateway Service
539557
# =============================================================================
@@ -752,6 +770,20 @@ migration_job(
752770
resource_deps=['init-database'], # Independent database, only needs init to complete
753771
)
754772

773+
migration_job(
774+
'migrate-reconciliation',
775+
'reconciliation',
776+
'reconciliation',
777+
resource_deps=['init-database'], # Independent database, only needs init to complete
778+
)
779+
780+
migration_job(
781+
'migrate-forecasting',
782+
'forecasting',
783+
'forecasting',
784+
resource_deps=['init-database'], # Independent database, only needs init to complete
785+
)
786+
755787
# Kafka cluster health check - runs automatically after kafka-cluster is ready
756788
local_resource(
757789
'kafka-health',
@@ -813,6 +845,8 @@ Microservices:
813845
• Tenant → localhost:50056 (gRPC)
814846
• Internal-Bank-Account → localhost:50057 (gRPC)
815847
• Market-Information → localhost:50058 (gRPC)
848+
• Reconciliation → localhost:50060 (gRPC)
849+
• Forecasting → localhost:50061 (gRPC)
816850
817851
Gateway:
818852
• HTTP Gateway → localhost:8090 (subdomain routing)
@@ -851,12 +885,14 @@ Database Architecture (database-per-service):
851885
- meridian_party
852886
- meridian_internal_bank_account
853887
- meridian_market_information
888+
- meridian_reconciliation
889+
- meridian_forecasting
854890
• Within each database: org schemas for multi-tenant isolation
855891
• Tables use singular, unqualified names (search_path routing)
856892
• See ADR-0003 for architecture details
857893
858894
Database Migrations:
859-
• Migrations run automatically on startup (8 resources):
895+
• Migrations run automatically on startup (10 resources):
860896
1. current_account → meridian_current_account (account, lien, audit tables)
861897
2. financial_accounting → meridian_financial_accounting (ledger, booking)
862898
3. position_keeping → meridian_position_keeping (positions, transactions)
@@ -865,7 +901,9 @@ Database Migrations:
865901
6. tenant → meridian_platform (tenant registry)
866902
7. internal_bank_account → meridian_internal_bank_account (internal accounts)
867903
8. market_information → meridian_market_information (price benchmarks, market data)
868-
• Parallel execution: current_account + financial_accounting + party + tenant + internal_bank_account + market_information
904+
9. reconciliation → meridian_reconciliation (reconciliation processes)
905+
10. forecasting → meridian_forecasting (forecasting strategies)
906+
• Parallel execution: current_account + financial_accounting + party + tenant + internal_bank_account + market_information + reconciliation + forecasting
869907
• Sequential dependencies:
870908
- position_keeping waits for current_account (Account FK)
871909
- payment_order waits for current_account (Account FK)
@@ -878,6 +916,8 @@ Database Migrations:
878916
- tilt trigger migrate-tenant
879917
- tilt trigger migrate-internal-bank-account
880918
- tilt trigger migrate-market-information
919+
- tilt trigger migrate-reconciliation
920+
- tilt trigger migrate-forecasting
881921
882922
Testing Kafka Failover:
883923
kubectl delete pod kafka-1 # Kill broker

scripts/init-database.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ DATABASES=(
2626
"meridian_party:meridian_party_user"
2727
"meridian_internal_bank_account:meridian_internal_bank_account_user"
2828
"meridian_market_information:meridian_market_information_user"
29+
"meridian_reconciliation:meridian_reconciliation_user"
30+
"meridian_forecasting:meridian_forecasting_user"
2931
)
3032

3133
echo "Initializing CockroachDB databases..."
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Atlas configuration for Forecasting Service
2+
// Manages forecasting strategies that generate forward curves from market data
3+
// Uses database-per-service architecture with unqualified table names
4+
5+
data "external_schema" "gorm" {
6+
program = [
7+
"go",
8+
"run",
9+
"-mod=mod",
10+
"./utilities/atlas-loader",
11+
"--schema=forecasting"
12+
]
13+
}
14+
15+
env "local" {
16+
// Service-specific migration directory
17+
migration {
18+
dir = "file://services/forecasting/migrations"
19+
}
20+
21+
// Dev database - uses default public schema
22+
dev = "docker://postgres/16/dev"
23+
24+
// Source schema from GORM models via external loader
25+
src = data.external_schema.gorm.url
26+
27+
// Lint configuration to catch dangerous changes
28+
lint {
29+
destructive {
30+
error = true
31+
}
32+
data_depend {
33+
error = true
34+
}
35+
incompatible {
36+
error = true
37+
}
38+
}
39+
}
40+
41+
env "ci" {
42+
migration {
43+
dir = "file://services/forecasting/migrations"
44+
}
45+
46+
dev = "docker://postgres/16/dev"
47+
48+
src = data.external_schema.gorm.url
49+
50+
lint {
51+
destructive {
52+
error = true
53+
}
54+
data_depend {
55+
error = true
56+
}
57+
incompatible {
58+
error = true
59+
}
60+
}
61+
}
62+
63+
env "production" {
64+
// Production environment - apply only, never diff
65+
// URL points to service-specific database (meridian_forecasting)
66+
url = getenv("DATABASE_URL")
67+
68+
migration {
69+
dir = "file://services/forecasting/migrations"
70+
}
71+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// Atlas configuration for Reconciliation Service
2+
// BIAN Service Domain: Reconciliation
3+
// Manages reconciliation processes and settlement
4+
// Uses database-per-service architecture with unqualified table names
5+
6+
data "external_schema" "gorm" {
7+
program = [
8+
"go",
9+
"run",
10+
"-mod=mod",
11+
"./utilities/atlas-loader",
12+
"--schema=reconciliation"
13+
]
14+
}
15+
16+
env "local" {
17+
// Service-specific migration directory
18+
migration {
19+
dir = "file://services/reconciliation/migrations"
20+
}
21+
22+
// Dev database - uses default public schema
23+
dev = "docker://postgres/16/dev"
24+
25+
// Source schema from GORM models via external loader
26+
src = data.external_schema.gorm.url
27+
28+
// Lint configuration to catch dangerous changes
29+
lint {
30+
destructive {
31+
error = true
32+
}
33+
data_depend {
34+
error = true
35+
}
36+
incompatible {
37+
error = true
38+
}
39+
}
40+
}
41+
42+
env "ci" {
43+
migration {
44+
dir = "file://services/reconciliation/migrations"
45+
}
46+
47+
dev = "docker://postgres/16/dev"
48+
49+
src = data.external_schema.gorm.url
50+
51+
lint {
52+
destructive {
53+
error = true
54+
}
55+
data_depend {
56+
error = true
57+
}
58+
incompatible {
59+
error = true
60+
}
61+
}
62+
}
63+
64+
env "production" {
65+
// Production environment - apply only, never diff
66+
// URL points to service-specific database (meridian_reconciliation)
67+
url = getenv("DATABASE_URL")
68+
69+
migration {
70+
dir = "file://services/reconciliation/migrations"
71+
}
72+
}

0 commit comments

Comments
 (0)