docs: add Phase 2 (Ingest Layer) documentation#20
Conversation
- Update README.md with API Endpoints section and ingest examples - Mark Phase 2 as completed in PHASE-index.md - Add comprehensive Phase 2 documentation (2-INGEST_LAYER.md) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Reviewer's GuideDocuments completion of Phase 2 (Ingest Layer) by adding a new detailed phase document, updating the phase index to mark the ingest layer as complete and describe its API behavior, and enhancing the top-level README with API endpoint documentation and examples for the POST /ingest/sales-daily ingest endpoint. Sequence diagram for POST /ingest/sales-daily request processingsequenceDiagram
actor Client
participant ApiServer as FastAPI_app
participant IngestRouter as ingest_routes
participant IngestService as ingest_service
participant KeyResolver as KeyResolver
participant DB as PostgreSQL
Client->>ApiServer: POST /ingest/sales-daily
ApiServer->>IngestRouter: validate SalesDailyIngestRequest
IngestRouter->>IngestService: upsert_sales_daily_batch(records)
IngestService->>KeyResolver: resolve_store_codes(codes)
KeyResolver->>DB: SELECT code,id FROM store WHERE code IN codes
DB-->>KeyResolver: store_code -> store_id map
KeyResolver-->>IngestService: store_code_to_id
IngestService->>KeyResolver: resolve_skus(skus)
KeyResolver->>DB: SELECT sku,id FROM product WHERE sku IN skus
DB-->>KeyResolver: sku -> product_id map
KeyResolver-->>IngestService: sku_to_product_id
IngestService->>KeyResolver: resolve_dates(dates)
KeyResolver->>DB: SELECT date FROM calendar WHERE date IN dates
DB-->>KeyResolver: existing_dates
KeyResolver-->>IngestService: valid_dates
IngestService->>IngestService: validate rows, collect errors
IngestService->>DB: INSERT ... ON CONFLICT DO UPDATE (valid_rows)
DB-->>IngestService: upsert completed
IngestService-->>IngestRouter: SalesDailyIngestResponse
IngestRouter-->>ApiServer: JSON response
ApiServer-->>Client: processed_count, rejected_count, errors, duration_ms
Entity relationship diagram for SalesDaily ingest grain and key resolutionerDiagram
STORE {
int id PK
string code UK
string name
}
PRODUCT {
int id PK
string sku UK
string name
}
CALENDAR {
date date PK
int year
int month
int day
}
SALES_DAILY {
int id PK
date date FK
int store_id FK
int product_id FK
int quantity
decimal unit_price
decimal total_amount
datetime created_at
datetime updated_at
string unique_date_store_product_uk_date_store_id_product_id
}
STORE ||--o{ SALES_DAILY : has
PRODUCT ||--o{ SALES_DAILY : has
CALENDAR ||--o{ SALES_DAILY : provides_date
Class diagram for ingest layer schemas and service componentsclassDiagram
class SalesDailyIngestRow {
date date_type
store_code str
sku str
quantity int
unit_price Decimal
total_amount Decimal
}
class SalesDailyIngestRequest {
records list~SalesDailyIngestRow~
}
class IngestRowError {
row_index int
store_code str
sku str
date date_type
error_code str
error_message str
}
class SalesDailyIngestResponse {
processed_count int
rejected_count int
total_received int
errors list~IngestRowError~
duration_ms float
}
class KeyResolver {
+resolve_store_codes(db, codes) dict~str,int~
+resolve_skus(db, skus) dict~str,int~
+resolve_dates(db, dates) set~date_type~
}
class UpsertResult {
processed_count int
rejected_count int
total_received int
errors list~IngestRowError~
duration_ms float
}
class IngestService {
+upsert_sales_daily_batch(db, records, key_resolver) UpsertResult
}
SalesDailyIngestRequest "1" o-- "many" SalesDailyIngestRow : contains
SalesDailyIngestResponse "1" o-- "many" IngestRowError : aggregates
IngestService ..> KeyResolver : uses
IngestService ..> SalesDailyIngestRow : processes
IngestService ..> UpsertResult : returns
SalesDailyIngestResponse <.. UpsertResult : compatible
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary
Changes
Test plan
🤖 Generated with Claude Code
Summary by Sourcery
Document completion of Phase 2 (Ingest Layer) and introduce public API details for the sales ingestion endpoint.
Documentation: