By Samuel Toh
Implementation Notes on Integrating Multiple Data Sources
For a while, my work involved bringing structured data from different regions into the product. The agent used semantic and keyword search to find the content it needed to answer questions. These sources differed in format, language, and update frequency, and some also had access restrictions.
At first, I mainly focused on whether the whole flow could run end to end, including writing scrapers, cleaning the data, storing it in the DB, and building the search service. After integrating a few sources, I found that a lot of the work kept repeating, yet each source had its own differences—copying the previous code still meant spending time adapting it.
In addition, when someone else needed to take over, they also had to relearn where the data came from, what processing it went through, and where to look when something went wrong. So I started organizing a shared process, writing down what needs to be handled at each stage and how to check it.
I organized data integration work into six parts:
- Data acquisition: confirm how to access the source, and implement a scraper or API integration.
- Data storage: define the schema and how data is written and queried.
- Data maintenance: handle scheduled updates, version changes, and data removal.
- Retrieval service: build the indexes and query interfaces needed for semantic search and keyword search.
- Agent tool: let the agent use these retrieval capabilities through tools.
- Integration and handoff process: record each stage’s outputs, checks, and known issues.
Organizing it this way also came from problems I’d run into before. Once, after wiring up the whole pipeline, I discovered the schema needed changes, and both the data processing and downstream queries had to be modified as a result.
After that, I started checking the output of each stage before moving on. For example, after scraping is done, confirm the content and format before moving on to storage and retrieval. That way, when a problem comes up, it’s easier to know which part to go back to.
I spent a fair amount of time working out a shared schema for the different sources.
I used to scrape the data first, then decide how to store it based on its contents. As the number of sources grew, each dataset developed its own structure, and downstream services had to keep handling the differences between sources.
I later used Pydantic models to define a shared data structure before integrating each source, clearly specifying the fields and types downstream would always need, while keeping room for source-specific extensions. That way, when integrating a new source, I could first confirm how it maps to the shared structure and which information needs separate handling.
Another thing to think through up front was how to preserve past content after data is updated.
Some queries need to know what the data looked like at a given point in time, so I kept historical versions in the update flow and recorded each version’s time and status. Regular queries use the currently valid data, and queries about the past retrieve the version that matches the requested time.
When upstream data is removed, the related status and history are also kept. This lets later processing distinguish whether data was updated, removed, or is still valid.
These designs all affect how downstream queries work, so thinking through the expected usage before starting implementation helped a lot with the work that followed.
Once the data could be updated on a schedule, the next thing I tackled was how to cut down unnecessary repeated work.
Since source data doesn’t all change every time, reprocessing everything and recomputing embeddings on each update would take a lot of time and increase API costs.
I split change detection into two stages:
- First, check the update information provided by the source to filter out data that may have changed.
- Then compare the actual content, creating new versions and updating embeddings only for the parts that changed.
This way, update work can focus on content that has actually changed. The whole flow is also easier to trace: you know which data an update processed and why it needed to be recomputed.
This made me pay more attention to the cost of maintaining data. After bringing data in the first time, you still need to consider how often it will update, how much content each update processes, and which work can actually be skipped when running over the long term.
Deployment and scheduling also brought some problems.
For example, I once built a Docker image on a Mac and only discovered after deploying it to the runtime environment that the architecture didn’t match. I fixed the build’s target platform and added it to the deployment checklist.
Another problem I ran into more often was scrapers stopping partway through. Connections to some sources weren’t very stable, and if each run started from scratch, work that had already been finished would be done again.
Later I added checkpoints, saving progress after each batch of data was processed, so a run could resume from the recorded position after an interruption. Beyond knowing whether a job succeeded or failed, I could also see where it stopped and which parts were already done.
These problems may seem unrelated to the data itself, but when actually maintaining a pipeline, they all affect whether jobs can run to completion reliably.
After organizing these processes, I also wrote them up as a checklist to refer to when integrating a new data source. It mainly covers:
- Which source characteristics and limits to confirm before starting.
- What each stage needs to produce, and how to check it.
- Which issues to watch for during deployment, updates, or interruptions.
Later, when colleagues took on new data sources, they could use this checklist alongside the existing code as a reference. When discussing progress, it was also easier to see which stage we were at and which parts of a new source needed separate handling.
Looking back, the useful part was writing down what I had learned from integrating several sources. Questions like how much of the schema to settle up front, what information to keep for version updates, and how to resume after an interruption were all problems I used to handle only when I hit them during implementation.
Writing these things down clearly also helped me better understand which needs different sources share and which differences still need separate handling. Now, when integrating new data, I have a process to check against, which I then adjust to the characteristics of the source.