#pragma once

#include <Core/Common/String.h>
#include <Core/Container/Vector.h>
#include <Core/Common/CoreUtils.h>

#include <Core/Thread/Mutex.h>

namespace Romeo
{
    struct FileEntry
    {
        Juliet::String HeaderPath;
        Juliet::String CppPath;
        
        // Stored as Windows FILETIME (uint64_t) for easy comparison
        uint64_t LastModifiedHeader = 0;
        uint64_t LastModifiedCpp = 0;

        uint64_t LastMarkdownCreatedTime = 0;
        uint64_t LastAIGeneratedTime = 0;

        Juliet::String Description;
    };

    struct Database
    {
        Juliet::VectorArena<FileEntry, 512> Entries = {};
        Juliet::Arena* DbArena = nullptr;
        Juliet::Mutex Mutex;
    };

    // Initialize the DB using the provided memory arena
    void DB_Init(Database& db, Juliet::Arena* arena);

    // Scan a workspace directory for pairs of .h/.cpp and update the database structure.
    void DB_ScanWorkspace(Database& db, Juliet::Arena* tempArena, const Juliet::String& rootDir);

    // Save and load DB state from disk (e.g. Romeo/docs/romeo_db.json or .bin)
    bool DB_Save(const Database& db, const Juliet::String& filePath);
    bool DB_Load(Database& db, const Juliet::String& filePath);

} // namespace Romeo
