레시피 수집(ETL)
이 문서로 해결할 질문
- Mealio 레시피 데이터는 어디서 오고 어떻게 가공되나요?
- fetch·parse-submit·parse-retrieve·persist·embed-submit·embed-retrieve 단계는 각각 무엇을 하나요?
- 로컬에서 파이프라인 job을 어떻게 실행하나요?
목적
식약처 공공데이터 레시피를 수집하고, OpenAI Batch API로 정규화·매핑한 뒤 PostgreSQL에 영속화합니다.
단계 요약
| 단계 | 실행 | 결과 |
|---|---|---|
| fetch | cron / CLI | status: fetched |
| parse-submit | cron / CLI | parse_batch_id, parse_submitted |
| parse-retrieve | cron / CLI | parse_retrieved + Kafka 이벤트 |
| persist | always-on consumer | persisted + Recipe row |
| embed-submit | cron / CLI + Kafka | embed_batch_id, embed_submitted |
| embed-retrieve | cron / CLI | RecipeEmbedding(pgvector) upsert + embed_retrieved |
저장소
| 저장소 | 내용 |
|---|---|
MongoDB recipe_ingestion_jobs | 파이프라인 job 문서 |
MongoDB recipe_ingestion_state | API 페이징 커서 |
| PostgreSQL | 최종 Recipe 도메인·RecipeEmbedding(pgvector) |
운영 특성
fetch,parse-submit,parse-retrieve,embed-submit,embed-retrieve는 독립 job이며 cron으로 조율합니다.- fetch·submit cron 주기와
fetchLimit는 운영 runbook에서 조율합니다. persist는 always-on Consumer가 Kafka 이벤트를 소비해 PostgreSQL에 반영합니다.
로컬 실행 (CLI)
인프라·Consumer가 기동된 상태에서 루트 스크립트로 각 단계를 실행할 수 있습니다.
pnpm run recipe-ingestion:fetch
pnpm run recipe-ingestion:parse-submit
pnpm run recipe-ingestion:parse-retrieve
pnpm run recipe-ingestion:embed-submit
pnpm run recipe-ingestion:embed-retrieve