# fegones/segundocerebro architecture

> Architecture diagram of the GitHub repository fegones/segundocerebro, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fegones/segundocerebro
- Repository: https://github.com/fegones/segundocerebro

## Overview

Segundo Cerebro is a local, multi-account NotebookLM content client that exposes an authorized, evidence-focused knowledge base to Claude Code and Codex through MCP. The principal workflow is: configure Google profiles and notebook scope locally, synchronize available notebook metadata/text or import files, store indexed content encrypted, then retrieve cited excerpts or abstain; audit, version comparison, exports, and optional Gemini synthesis extend that workflow. Edges follow the README and SOURCE INDEX references; unsampled implementation details are not inferred.

Main entry points: [`src/notebook_conexion/second_brain.py`](https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/second_brain.py) (Knowledge orchestrator), [`src/notebook_conexion/desktop.py`](https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/desktop.py) (Desktop panel), [`src/notebook_conexion/mcp_server.py`](https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/mcp_server.py) (MCP server), [`src/notebook_conexion/operations.py`](https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/operations.py) (Notebook operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User interfaces"]
  node_desktop["Desktop panel<br/>[desktop.py]"]
  node_cli["Command-line interface<br/>[cli.py]"]
  node_mcp["MCP server<br/>[mcp_server.py]"]
  node_agent_setup["Agent setup<br/>[agent_install.py]"]
end

subgraph group_access["Accounts and access"]
  node_operations["Notebook operations<br/>[operations.py]"]
  node_catalog["Notebook catalog<br/>[catalog.py]"]
  node_notebook_client["Notebook API client<br/>[notebook.py]"]
  node_oauth["Google OAuth<br/>[oauth.py]"]
  node_scope["Authorized scope<br/>[brain_scope.py]"]
  node_grants["Temporary grants<br/>[grants.py]"]
end

subgraph group_knowledge["Knowledge processing"]
  node_second_brain["Knowledge orchestrator<br/>[second_brain.py]"]
  node_local_import["Local file import<br/>[brain_import.py]"]
  node_retrieval["Evidence retrieval<br/>[brain_retrieval.py]"]
  node_answers["Cited answers<br/>[brain_answers.py]"]
  node_audit["Source audit<br/>[brain_audit.py]"]
  node_exports["Controlled exports<br/>[exports.py]"]
end

subgraph group_storage["Local state"]
  node_index[("Encrypted index<br/>[brain_store.py]")]
  node_profiles[("Profile configuration<br/>[store.py]")]
end

subgraph group_integrations["External services"]
  node_google_notebook{{"Gemini Notebook API"}}
  node_gemini["Optional Gemini synthesis<br/>[gemini.py]"]
  node_gemini_api{{"Gemini API"}}
end

node_user(("Local owner"))
node_agents(("Claude Code / Codex"))

node_user -->|"configures locally"| node_desktop
node_user -->|"uses commands"| node_cli
node_agents -->|"invoke tools"| node_mcp
node_desktop -->|"sets selection"| node_scope
node_desktop -->|"starts login"| node_oauth
node_desktop -->|"manages knowledge"| node_second_brain
node_desktop -->|"connects agents"| node_agent_setup
node_cli -->|"runs knowledge tasks"| node_second_brain
node_mcp -->|"dispatches requests"| node_second_brain
node_mcp -->|"dispatches operations"| node_operations
node_mcp -->|"requests exports"| node_exports
node_operations -->|"lists notebooks"| node_catalog
node_operations -->|"performs API actions"| node_notebook_client
node_operations -->|"exports results"| node_exports
node_operations -->|"checks permissions"| node_grants
node_catalog -->|"collects pages"| node_notebook_client
node_notebook_client -->|"obtains access token"| node_oauth
node_notebook_client -->|"sends API requests"| node_google_notebook
node_oauth -->|"loads account profile"| node_profiles
node_second_brain -->|"validates active scope"| node_scope
node_second_brain -->|"fetches notebook content"| node_notebook_client
node_second_brain -->|"collects sources"| node_catalog
node_second_brain -->|"stores synchronized text"| node_index
node_second_brain -->|"imports local files"| node_local_import
node_second_brain -->|"requests evidence search"| node_retrieval
node_second_brain -->|"builds cited answers"| node_answers
node_second_brain -->|"runs comparisons"| node_audit
node_retrieval -->|"reads indexed text"| node_index
node_answers -->|"retrieves evidence"| node_retrieval
node_answers -.->|"optionally synthesizes"| node_gemini
node_gemini -->|"sends selected text"| node_gemini_api
node_second_brain -->|"stores imported content"| node_index
node_second_brain -->|"loads account profiles"| node_profiles
node_mcp -->|"checks temporary permissions"| node_grants

click node_desktop "https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/desktop.py"
click node_cli "https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/cli.py"
click node_mcp "https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/mcp_server.py"
click node_agent_setup "https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/agent_install.py"
click node_operations "https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/operations.py"
click node_catalog "https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/catalog.py"
click node_notebook_client "https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/notebook.py"
click node_oauth "https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/oauth.py"
click node_scope "https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/brain_scope.py"
click node_second_brain "https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/second_brain.py"
click node_local_import "https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/brain_import.py"
click node_retrieval "https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/brain_retrieval.py"
click node_answers "https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/brain_answers.py"
click node_audit "https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/brain_audit.py"
click node_index "https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/brain_store.py"
click node_profiles "https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/store.py"
click node_grants "https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/grants.py"
click node_exports "https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/exports.py"
click node_gemini "https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/gemini.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_desktop,node_cli,node_mcp,node_agent_setup toneBlue
class node_operations,node_catalog,node_notebook_client,node_oauth,node_scope,node_grants toneAmber
class node_second_brain,node_local_import,node_retrieval,node_answers,node_audit,node_exports toneMint
class node_index,node_profiles toneRose
class node_google_notebook,node_gemini,node_gemini_api,node_user,node_agents toneIndigo
```

## Components

### User interfaces

- [Desktop panel](https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/desktop.py): `src/notebook_conexion/desktop.py`
- [Command-line interface](https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/cli.py): `src/notebook_conexion/cli.py`
- [MCP server](https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/mcp_server.py): `src/notebook_conexion/mcp_server.py`
- [Agent setup](https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/agent_install.py): `src/notebook_conexion/agent_install.py`

### Accounts and access

- [Notebook operations](https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/operations.py): `src/notebook_conexion/operations.py`
- [Notebook catalog](https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/catalog.py): `src/notebook_conexion/catalog.py`
- [Notebook API client](https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/notebook.py): `src/notebook_conexion/notebook.py`
- [Google OAuth](https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/oauth.py): `src/notebook_conexion/oauth.py`
- [Authorized scope](https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/brain_scope.py): `src/notebook_conexion/brain_scope.py`
- [Temporary grants](https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/grants.py): `src/notebook_conexion/grants.py`

### Knowledge processing

- [Knowledge orchestrator](https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/second_brain.py): `src/notebook_conexion/second_brain.py`
- [Local file import](https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/brain_import.py): `src/notebook_conexion/brain_import.py`
- [Evidence retrieval](https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/brain_retrieval.py): `src/notebook_conexion/brain_retrieval.py`
- [Cited answers](https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/brain_answers.py): `src/notebook_conexion/brain_answers.py`
- [Source audit](https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/brain_audit.py): `src/notebook_conexion/brain_audit.py`
- [Controlled exports](https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/exports.py): `src/notebook_conexion/exports.py`

### Local state

- [Encrypted index](https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/brain_store.py): `src/notebook_conexion/brain_store.py`
- [Profile configuration](https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/store.py): `src/notebook_conexion/store.py`

### External services

- **Gemini Notebook API**
- [Optional Gemini synthesis](https://github.com/fegones/segundocerebro/blob/main/src/notebook_conexion/gemini.py): `src/notebook_conexion/gemini.py`
- **Gemini API**

### Other components

- **Local owner**
- **Claude Code / Codex**

## Connections

- Local owner → Desktop panel: configures locally (evidence: `README.md`)
- Local owner → Command-line interface: uses commands (evidence: `README.md`)
- Claude Code / Codex → MCP server: invoke tools (evidence: `README.md`)
- Desktop panel → Authorized scope: sets selection (evidence: `src/notebook_conexion/desktop.py`)
- Desktop panel → Google OAuth: starts login (evidence: `src/notebook_conexion/desktop.py`)
- Desktop panel → Knowledge orchestrator: manages knowledge (evidence: `src/notebook_conexion/desktop.py`)
- Desktop panel → Agent setup: connects agents (evidence: `src/notebook_conexion/desktop.py`)
- Command-line interface → Knowledge orchestrator: runs knowledge tasks (evidence: `src/notebook_conexion/cli.py`)
- MCP server → Knowledge orchestrator: dispatches requests (evidence: `src/notebook_conexion/mcp_server.py`)
- MCP server → Notebook operations: dispatches operations (evidence: `src/notebook_conexion/mcp_server.py`)
- MCP server → Controlled exports: requests exports (evidence: `src/notebook_conexion/mcp_server.py`)
- Notebook operations → Notebook catalog: lists notebooks (evidence: `src/notebook_conexion/operations.py`)
- Notebook operations → Notebook API client: performs API actions (evidence: `src/notebook_conexion/operations.py`)
- Notebook operations → Controlled exports: exports results (evidence: `src/notebook_conexion/operations.py`)
- Notebook operations → Temporary grants: checks permissions (evidence: `src/notebook_conexion/operations.py`)
- Notebook catalog → Notebook API client: collects pages (evidence: `src/notebook_conexion/catalog.py`)
- Notebook API client → Google OAuth: obtains access token (evidence: `src/notebook_conexion/notebook.py`)
- Notebook API client → Gemini Notebook API: sends API requests (evidence: `README.md`)
- Google OAuth → Profile configuration: loads account profile (evidence: `src/notebook_conexion/oauth.py`)
- Knowledge orchestrator → Authorized scope: validates active scope (evidence: `src/notebook_conexion/second_brain.py`)
- Knowledge orchestrator → Notebook API client: fetches notebook content (evidence: `src/notebook_conexion/second_brain.py`)
- Knowledge orchestrator → Notebook catalog: collects sources (evidence: `src/notebook_conexion/second_brain.py`)
- Knowledge orchestrator → Encrypted index: stores synchronized text (evidence: `src/notebook_conexion/second_brain.py`)
- Knowledge orchestrator → Local file import: imports local files (evidence: `src/notebook_conexion/second_brain.py`)
- Knowledge orchestrator → Evidence retrieval: requests evidence search (evidence: `src/notebook_conexion/second_brain.py`)
- Knowledge orchestrator → Cited answers: builds cited answers (evidence: `src/notebook_conexion/second_brain.py`)
- Knowledge orchestrator → Source audit: runs comparisons (evidence: `src/notebook_conexion/second_brain.py`)
- Evidence retrieval → Encrypted index: reads indexed text (evidence: `src/notebook_conexion/brain_retrieval.py`)
- Cited answers → Evidence retrieval: retrieves evidence (evidence: `src/notebook_conexion/brain_answers.py`)
- Cited answers → Optional Gemini synthesis: optionally synthesizes (evidence: `README.md`)
- Optional Gemini synthesis → Gemini API: sends selected text (evidence: `README.md`)
- Knowledge orchestrator → Encrypted index: stores imported content (evidence: `src/notebook_conexion/second_brain.py`)
- Knowledge orchestrator → Profile configuration: loads account profiles (evidence: `src/notebook_conexion/second_brain.py`)
- MCP server → Temporary grants: checks temporary permissions (evidence: `src/notebook_conexion/mcp_server.py`)
