mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-07-16 17:47:22 +00:00
Pipeline: Add LLM and mocked user generation to the pipeline (#230)
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
#ifndef BIERGARTEN_PIPELINE_INCLUDES_SERVICES_CURATED_DATA_CURATED_DATA_SERVICE_H_
|
||||
#define BIERGARTEN_PIPELINE_INCLUDES_SERVICES_CURATED_DATA_CURATED_DATA_SERVICE_H_
|
||||
|
||||
/**
|
||||
* @file services/curated_data/curated_data_service.h
|
||||
* @brief Abstraction for loading curated location, persona, and name data.
|
||||
*/
|
||||
|
||||
#include <filesystem>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#include "data_model/models.h"
|
||||
|
||||
using ForenameList = std::vector<ForenameEntry>;
|
||||
using SurnameList = std::vector<std::string>;
|
||||
using LocationsList = std::vector<Location>;
|
||||
using PersonasList = std::vector<UserPersona>;
|
||||
using ForenamesByCountryMap = std::unordered_map<std::string, ForenameList>;
|
||||
using SurnamesByCountryMap = std::unordered_map<std::string, SurnameList>;
|
||||
|
||||
/**
|
||||
* @brief Interface for services that load curated data used to seed
|
||||
* brewery/user generation.
|
||||
*/
|
||||
class ICuratedDataService {
|
||||
public:
|
||||
ICuratedDataService() = default;
|
||||
virtual ~ICuratedDataService() = default;
|
||||
|
||||
ICuratedDataService(const ICuratedDataService&) = delete;
|
||||
ICuratedDataService& operator=(const ICuratedDataService&) = delete;
|
||||
ICuratedDataService(ICuratedDataService&&) = delete;
|
||||
ICuratedDataService& operator=(ICuratedDataService&&) = delete;
|
||||
|
||||
/**
|
||||
* @brief Loads all curated location records.
|
||||
*/
|
||||
virtual const LocationsList& LoadLocations() = 0;
|
||||
|
||||
/**
|
||||
* @brief Loads all curated persona records.
|
||||
*/
|
||||
virtual const PersonasList& LoadPersonas() = 0;
|
||||
virtual const ForenamesByCountryMap& LoadForenamesByCountry() = 0;
|
||||
virtual const SurnamesByCountryMap& LoadSurnamesByCountry() = 0;
|
||||
};
|
||||
|
||||
#endif // BIERGARTEN_PIPELINE_INCLUDES_SERVICES_CURATED_DATA_CURATED_DATA_SERVICE_H_
|
||||
@@ -0,0 +1,63 @@
|
||||
#ifndef BIERGARTEN_PIPELINE_INCLUDES_JSON_HANDLING_JSON_LOADER_H_
|
||||
#define BIERGARTEN_PIPELINE_INCLUDES_JSON_HANDLING_JSON_LOADER_H_
|
||||
|
||||
/**
|
||||
* @file json_handling/json_loader.h
|
||||
* @brief JSON-backed implementation of ICuratedDataService.
|
||||
*/
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
#include "data_model/models.h"
|
||||
#include "services/curated_data/curated_data_service.h"
|
||||
|
||||
/**
|
||||
* @brief File locations for the curated JSON fixtures consumed by
|
||||
* CuratedJsonDataService.
|
||||
*/
|
||||
struct CuratedDataFilePaths {
|
||||
std::filesystem::path locations_path;
|
||||
std::filesystem::path personas_path;
|
||||
std::filesystem::path forenames_path;
|
||||
std::filesystem::path surnames_path;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Loads curated location, persona, and name data from JSON files.
|
||||
*/
|
||||
class CuratedJsonDataService final : public ICuratedDataService {
|
||||
struct cache {
|
||||
LocationsList locations;
|
||||
PersonasList personas;
|
||||
ForenamesByCountryMap forenames_by_country;
|
||||
SurnamesByCountryMap surnames_by_country;
|
||||
|
||||
cache() = default;
|
||||
~cache() = default;
|
||||
};
|
||||
|
||||
CuratedDataFilePaths filepaths_;
|
||||
cache cache_;
|
||||
|
||||
public:
|
||||
explicit CuratedJsonDataService(CuratedDataFilePaths filepaths);
|
||||
|
||||
/**
|
||||
* @brief Parses a JSON array file and returns all location records.
|
||||
*/
|
||||
const LocationsList& LoadLocations() override;
|
||||
|
||||
/**
|
||||
* @brief Parses a JSON array file and returns all persona records.
|
||||
*/
|
||||
const PersonasList& LoadPersonas() override;
|
||||
|
||||
const ForenamesByCountryMap& LoadForenamesByCountry() override;
|
||||
|
||||
/**
|
||||
* @brief Parses a JSON file and returns all the forenames per country.
|
||||
*/
|
||||
const SurnamesByCountryMap& LoadSurnamesByCountry() override;
|
||||
};
|
||||
|
||||
#endif // BIERGARTEN_PIPELINE_INCLUDES_JSON_HANDLING_JSON_LOADER_H_
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef BIERGARTEN_PIPELINE_INCLUDES_SERVICES_CURATED_DATA_MOCK_CURATED_DATA_SERVICE_H_
|
||||
#define BIERGARTEN_PIPELINE_INCLUDES_SERVICES_CURATED_DATA_MOCK_CURATED_DATA_SERVICE_H_
|
||||
|
||||
/**
|
||||
* @file services/curated_data/mock_curated_data_service.h
|
||||
* @brief In-memory ICuratedDataService backed by a small fixed dataset, used
|
||||
* when file-backed curated data is disabled (mock mode).
|
||||
*/
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
#include "data_model/models.h"
|
||||
#include "services/curated_data/curated_data_service.h"
|
||||
|
||||
/**
|
||||
* @brief Curated data service returning a small fixed in-memory dataset in
|
||||
* place of the JSON fixture files used by JsonLoader.
|
||||
*/
|
||||
class MockCuratedDataService final : public ICuratedDataService {
|
||||
public:
|
||||
MockCuratedDataService();
|
||||
|
||||
const LocationsList& LoadLocations() override;
|
||||
|
||||
const PersonasList& LoadPersonas() override;
|
||||
|
||||
const ForenamesByCountryMap& LoadForenamesByCountry() override;
|
||||
|
||||
const SurnamesByCountryMap& LoadSurnamesByCountry() override;
|
||||
|
||||
private:
|
||||
LocationsList locations_;
|
||||
PersonasList personas_;
|
||||
ForenamesByCountryMap forenames_by_country_;
|
||||
SurnamesByCountryMap surnames_by_country_;
|
||||
};
|
||||
|
||||
#endif // BIERGARTEN_PIPELINE_INCLUDES_SERVICES_CURATED_DATA_MOCK_CURATED_DATA_SERVICE_H_
|
||||
Reference in New Issue
Block a user