digraph EvidenceLab {
    bgcolor="white"
    fontcolor="#2C3E50"
    fontsize=14
    fontname="Helvetica"
    rankdir=TB
    ranksep=0.9
    nodesep=0.6
    pad=0.5
    dpi=150
    splines=true
    newrank=true

    node [
        shape=box
        style="rounded,filled"
        fillcolor="#fafbfc"
        color="#5B8FA8"
        fontcolor="#2C3E50"
        fontname="Helvetica"
        fontsize=11
        penwidth=1.5
        margin="0.3,0.2"
    ]

    edge [
        color="#5B8FA8"
        fontcolor="#4A7490"
        fontname="Helvetica"
        fontsize=10
        penwidth=1.5
    ]

    ui [label=<
        <TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0" CELLPADDING="2">
        <TR><TD ALIGN="CENTER"><FONT FACE="Helvetica" POINT-SIZE="13" COLOR="#2C3E50"><B>Frontend UI</B></FONT></TD></TR>
        <TR><TD ALIGN="CENTER"><FONT FACE="Helvetica" POINT-SIZE="10" COLOR="#6B7876">React + TypeScript</FONT></TD></TR>
        </TABLE>
    > fillcolor="#fafbfc"]

    api [label=<
        <TABLE BORDER="0" CELLBORDER="0" CELLSPACING="8" CELLPADDING="4">
        <TR><TD COLSPAN="4"><FONT FACE="Helvetica" POINT-SIZE="13" COLOR="#2C3E50"><B>Backend API</B></FONT><BR/><FONT FACE="Helvetica" POINT-SIZE="10" COLOR="#6B7876">FastAPI</FONT></TD></TR>
        <TR>
            <TD BGCOLOR="#EDF2F7" BORDER="1" COLOR="#5B8FA8" STYLE="ROUNDED" VALIGN="TOP" WIDTH="120"><FONT FACE="Helvetica" COLOR="#2C3E50" POINT-SIZE="11"><B>Search Service</B><BR/><BR/><FONT POINT-SIZE="9" COLOR="#6B7876">EMBEDDING<BR/>RERANK</FONT></FONT></TD>
            <TD BGCOLOR="#EDF2F7" BORDER="1" COLOR="#5B8FA8" STYLE="ROUNDED" VALIGN="TOP" WIDTH="120"><FONT FACE="Helvetica" COLOR="#2C3E50" POINT-SIZE="11"><B>AI Summary</B><BR/><BR/><FONT POINT-SIZE="9" COLOR="#6B7876">LLM</FONT></FONT></TD>
            <TD BGCOLOR="#EDF2F7" BORDER="1" COLOR="#5B8FA8" STYLE="ROUNDED" VALIGN="TOP" WIDTH="120"><FONT FACE="Helvetica" COLOR="#2C3E50" POINT-SIZE="11"><B>Research Assistant</B><BR/><BR/><FONT POINT-SIZE="9" COLOR="#6B7876">LLM<BR/>EMBEDDING</FONT></FONT></TD>
            <TD BGCOLOR="#EDF2F7" BORDER="1" COLOR="#5B8FA8" STYLE="ROUNDED" VALIGN="TOP" WIDTH="120"><FONT FACE="Helvetica" COLOR="#2C3E50" POINT-SIZE="11"><B>Auth Module</B><BR/><BR/><FONT POINT-SIZE="9" COLOR="#6B7876">OAUTH<BR/>EMAIL</FONT></FONT></TD>
        </TR>
        </TABLE>
    > fillcolor="#fafbfc" color="#5B8FA8" penwidth=1.5 margin="0.2,0.15"]

    pg [label=<
        <TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0" CELLPADDING="2">
        <TR><TD ALIGN="CENTER"><FONT FACE="Helvetica" POINT-SIZE="11" COLOR="#2C3E50"><B>PostgreSQL</B></FONT></TD></TR>
        <TR><TD ALIGN="CENTER"><FONT FACE="Helvetica" POINT-SIZE="9" COLOR="#6B7876">Users · Groups · Docs<BR/>Ratings · Activity</FONT></TD></TR>
        </TABLE>
    > fillcolor="#fafbfc" width=1.9]

    qd [label=<
        <TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0" CELLPADDING="2">
        <TR><TD ALIGN="CENTER"><FONT FACE="Helvetica" POINT-SIZE="11" COLOR="#2C3E50"><B>Qdrant</B></FONT></TD></TR>
        <TR><TD ALIGN="CENTER"><FONT FACE="Helvetica" POINT-SIZE="9" COLOR="#6B7876">Dense Vectors · BM25<BR/>Payload Index</FONT></TD></TR>
        </TABLE>
    > fillcolor="#fafbfc" width=1.9]

    redis [label=<
        <TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0" CELLPADDING="2">
        <TR><TD ALIGN="CENTER"><FONT FACE="Helvetica" POINT-SIZE="11" COLOR="#2C3E50"><B>Redis</B></FONT></TD></TR>
        <TR><TD ALIGN="CENTER"><FONT FACE="Helvetica" POINT-SIZE="9" COLOR="#6B7876">Celery Broker<BR/> </FONT></TD></TR>
        </TABLE>
    > fillcolor="#fafbfc" width=1.9]

    oauth [label=<
        <TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0" CELLPADDING="2">
        <TR><TD ALIGN="CENTER"><FONT FACE="Helvetica" POINT-SIZE="11" COLOR="#2C3E50"><B>OAuth Providers</B></FONT></TD></TR>
        <TR><TD ALIGN="CENTER"><FONT FACE="Helvetica" POINT-SIZE="9" COLOR="#6B7876">Microsoft · Google<BR/> </FONT></TD></TR>
        </TABLE>
    > fillcolor="#fafbfc" width=1.9]

    pipeline [label=<
        <TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0" CELLPADDING="2">
        <TR><TD ALIGN="CENTER"><FONT FACE="Helvetica" POINT-SIZE="13" COLOR="#2C3E50"><B>Pipeline Worker</B></FONT><BR/><FONT FACE="Helvetica" POINT-SIZE="10" COLOR="#6B7876">Celery</FONT></TD></TR>
        <TR><TD ALIGN="CENTER"><FONT FACE="Helvetica" POINT-SIZE="9" COLOR="#6B7876"><BR/>Scan → Parse → Summarise → Tag → Chunk → Embed → Index<BR/><BR/>EMBEDDING (vectorise chunks)  ·  LLM (summarise + tag documents)</FONT></TD></TR>
        </TABLE>
    > fillcolor="#fafbfc" margin="0.2,0.15"]

    models [label=<
        <TABLE BORDER="0" CELLBORDER="0" CELLSPACING="8" CELLPADDING="6" BGCOLOR="#fafbfc">
        <TR><TD COLSPAN="5" ALIGN="CENTER"><FONT FACE="Helvetica" POINT-SIZE="13" COLOR="#2C3E50"><B>Models</B></FONT><BR/><FONT FACE="Helvetica" POINT-SIZE="10" COLOR="#6B7876">config.json model_combo</FONT></TD></TR>
        <TR>
            <TD BGCOLOR="#EDF2F7" BORDER="1" COLOR="#5B8FA8" STYLE="ROUNDED" COLSPAN="2" VALIGN="TOP">
                <TABLE BORDER="0" CELLBORDER="0" CELLSPACING="4" CELLPADDING="3">
                <TR><TD COLSPAN="2" ALIGN="CENTER"><FONT FACE="Helvetica" COLOR="#4A7490" POINT-SIZE="11"><B>Local</B></FONT></TD></TR>
                <TR>
                    <TD BGCOLOR="#fafbfc" BORDER="1" COLOR="#5B8FA8" STYLE="ROUNDED" ALIGN="CENTER" VALIGN="TOP" WIDTH="130"><FONT FACE="Helvetica" COLOR="#2C3E50" POINT-SIZE="11"><B>Embedding</B></FONT><BR/><BR/><FONT FACE="Helvetica" COLOR="#6B7876" POINT-SIZE="9">Infinity server +<BR/>HF models</FONT></TD>
                    <TD BGCOLOR="#fafbfc" BORDER="1" COLOR="#5B8FA8" STYLE="ROUNDED" ALIGN="CENTER" VALIGN="TOP" WIDTH="130"><FONT FACE="Helvetica" COLOR="#2C3E50" POINT-SIZE="11"><B>Rerank</B></FONT><BR/><BR/><FONT FACE="Helvetica" COLOR="#6B7876" POINT-SIZE="9">Jina v2<BR/>multilingual</FONT></TD>
                </TR>
                </TABLE>
            </TD>
            <TD BGCOLOR="#EDF2F7" BORDER="1" COLOR="#5B8FA8" STYLE="ROUNDED" COLSPAN="3" VALIGN="TOP">
                <TABLE BORDER="0" CELLBORDER="0" CELLSPACING="4" CELLPADDING="3">
                <TR><TD COLSPAN="3" ALIGN="CENTER"><FONT FACE="Helvetica" COLOR="#4A7490" POINT-SIZE="11"><B>Remote API</B></FONT></TD></TR>
                <TR>
                    <TD BGCOLOR="#fafbfc" BORDER="1" COLOR="#5B8FA8" STYLE="ROUNDED" ALIGN="CENTER" VALIGN="TOP" WIDTH="130"><FONT FACE="Helvetica" COLOR="#2C3E50" POINT-SIZE="11"><B>Embedding</B></FONT><BR/><BR/><FONT FACE="Helvetica" COLOR="#6B7876" POINT-SIZE="9">Azure text-embedding-3<BR/>Google gemini-embedding</FONT></TD>
                    <TD BGCOLOR="#fafbfc" BORDER="1" COLOR="#5B8FA8" STYLE="ROUNDED" ALIGN="CENTER" VALIGN="TOP" WIDTH="130"><FONT FACE="Helvetica" COLOR="#2C3E50" POINT-SIZE="11"><B>LLMs</B></FONT><BR/><BR/><FONT FACE="Helvetica" COLOR="#6B7876" POINT-SIZE="9">Azure GPT-4.1<BR/>HF Qwen 2.5 / Llama 3.1<BR/>Google Gemini 2.5</FONT></TD>
                    <TD BGCOLOR="#fafbfc" BORDER="1" COLOR="#5B8FA8" STYLE="ROUNDED" ALIGN="CENTER" VALIGN="TOP" WIDTH="130"><FONT FACE="Helvetica" COLOR="#2C3E50" POINT-SIZE="11"><B>Rerank</B></FONT><BR/><BR/><FONT FACE="Helvetica" COLOR="#6B7876" POINT-SIZE="9">Azure Cohere<BR/>Google Vertex Ranker</FONT></TD>
                </TR>
                </TABLE>
            </TD>
        </TR>
        </TABLE>
    > fillcolor="#fafbfc" color="#5B8FA8" penwidth=1.5 margin="0.2,0.15"]

    // Layout
    {rank=same; pg; qd; redis; oauth}

    // Connections
    ui -> api [label="  REST API / SSE  " dir=both weight=10]

    api -> pg [label="  Relational Data  " dir=both weight=5]
    api -> qd [label="  Search  " dir=both weight=5]
    api -> redis [label="  Doc Reprocessing  " weight=5]
    api -> oauth [label="  SSO  " dir=both weight=5]

    redis -> pipeline [label="  Tasks  " weight=10]

    pipeline -> pg [label="  Relational Data  " dir=both]
    pipeline -> qd [label="  Index Vectors  "]

    api -> models [label="  EMBEDDING + LLM + RERANK  " dir=both weight=2]
    pipeline -> models [label="  EMBEDDING + LLM  " dir=both weight=2]
}
