Skip to content

Esempi pratici

Questa pagina contiene esempi reali d'uso di DeepBase per diversi scenari e tipologie di progetto.


πŸ“ Esempio 1: Progetto Python Flask

Struttura progetto:

my-flask-app/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ routes.py          # <- focus qui
β”‚   β”œβ”€β”€ models.py          # <- focus qui
β”‚   β”œβ”€β”€ forms.py
β”‚   β”œβ”€β”€ templates/         # <- da ignorare
β”‚   └── static/
β”œβ”€β”€ config.py
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ tests/                   # <- da ignorare
└── instance/
    └── app.db               # <- database

Configurazione .deepbase.toml:

ignore_dirs = ["app/templates", "tests", "instance", "__pycache__"]
ignore_files = ["*.pyc", ".env", ".flaskenv"]

Comando:

deepbase . --light --focus "app/routes.py" --focus "app/models.py"

Output: Struttura light dell'intero progetto + contenuto completo di routes e models.


πŸ“ Esempio 2: Progetto React + Node.js

Struttura progetto:

my-react-app/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ Button.jsx
β”‚   β”‚   └── Card.jsx
β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”œβ”€β”€ Home.jsx       # <- focus qui
β”‚   β”‚   └── Dashboard.jsx  # <- focus qui
β”‚   └── utils/
β”‚       └── api.js
β”œβ”€β”€ public/
β”œβ”€β”€ node_modules/            # <- da ignorare
β”œβ”€β”€ build/                   # <- da ignorare
β”œβ”€β”€ package.json
└── package-lock.json        # <- da ignorare

Configurazione .deepbase.toml:

ignore_dirs = ["node_modules", "build", "dist", "coverage", ".next"]
ignore_files = ["package-lock.json", "yarn.lock", "*.log"]

Comando:

deepbase . --light --focus "src/pages/*"

πŸ“ Esempio 3: Analisi Database SQLite

Scenario: Vuoi documentare lo schema del database + alcune query importanti.

Struttura:

data-project/
β”œβ”€β”€ migrations/
β”‚   β”œβ”€β”€ 001_initial.sql    # <- focus qui
β”‚   └── 002_add_users.sql  # <- focus qui
β”œβ”€β”€ queries/
β”‚   β”œβ”€β”€ reports.sql        # <- focus qui
β”‚   └── analytics.sql
└── production.db          # <- database da analizzare

Configurazione .deepbase.toml:

ignore_dirs = ["backups", "temp"]
significant_extensions = [".sql", ".db", ".sqlite"]

Comando:

deepbase . --light --focus "production.db" --focus "migrations/*" --focus "queries/reports.sql"

Output: Schema completo del database + contenuto SQL dei file focalizzati.


πŸ“ Esempio 4: Monorepo con piΓΉ package

Struttura:

monorepo/
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   └── package.json
β”‚   β”œβ”€β”€ ui/                  # <- focus solo questo
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   └── package.json
β”‚   └── utils/
β”‚       └── src/
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ web/
β”‚   └── admin/
└── turbo.json

Comando:

deepbase . --light --focus "packages/ui/**/*"

πŸ“ Esempio 5: Documentazione LaTeX

Struttura:

thesis/
β”œβ”€β”€ chapters/
β”‚   β”œβ”€β”€ introduction.tex
β”‚   β”œβ”€β”€ methods.tex          # <- focus qui
β”‚   β”œβ”€β”€ results.tex          # <- focus qui
β”‚   └── conclusion.tex
β”œβ”€β”€ figures/
β”œβ”€β”€ bibliography.bib
└── main.tex

Comando:

deepbase . --light --focus "chapters/methods.tex" --focus "chapters/results.tex"

πŸ“ Esempio 6: Configurazione granulare (esclusioni complesse)

Scenario: Progetto con molti file temporanei e configurazioni locali.

.deepbase.toml:

# Directory
ignore_dirs = [
    "node_modules",
    "__pycache__",
    ".pytest_cache",
    "dist",
    "build",
    "coverage",
    ".tox",
    # Esclusioni specifiche per percorso
    "legacy/old_components",      # solo questa specifica
    "experiments/temp_*",         # tutte le cartelle temp_*
    "src/components/__dev__"      # cartella dev interna
]

# File
ignore_files = [
    "*.log",
    "*.tmp",
    "*.bak",
    ".env*",
    "local.settings.json",
    "secrets.*",
    # Esclusioni specifiche per percorso
    "config/local.yaml",
    "src/debug_utils.py"
]

# Estensioni extra
significant_extensions = [".prisma", ".graphql", ".proto"]

Comando:

deepbase . --light

πŸ“ Esempio 7: Focus da file esterno

Scenario: Hai una lista lunga di file da analizzare.

File focus-list.txt:

src/auth/login.js
src/auth/register.js
src/middleware/jwt.js
config/auth.yaml
tests/auth.test.js

Comando:

deepbase . --light --focus-file focus-list.txt

πŸ“ Esempio 8: CI/CD - Generazione automatica contesto

Scenario: Generare contesto per PR review automatica.

Script .github/workflows/context.yml:

name: Generate LLM Context

on:
  pull_request:
    paths:
      - 'src/**'

jobs:
  context:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Install DeepBase
        run: pip install deepbase

      - name: Generate context
        run: |
          deepbase . --light --focus "src/**" -o pr-context.md

      - name: Upload artifact
        uses: actions/upload-artifact@v3
        with:
          name: llm-context
          path: pr-context.md

πŸ“ Esempio 9: Confronto tra versioni

Scenario: Hai due branch e vuoi confrontare le differenze di struttura.

# Branch main
git checkout main
deepbase . --light -o context-main.md

# Branch feature
git checkout feature-branch
deepbase . --light -o context-feature.md

# Ora confronta i due file con diff o LLM
diff context-main.md context-feature.md

πŸ“ Esempio 10: Progetto complesso multi-linguaggio

Struttura:

fullstack-app/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ controllers/     # Python
β”‚   β”‚   β”œβ”€β”€ models/          # Python
β”‚   β”‚   └── main.py
β”‚   β”œβ”€β”€ migrations/          # SQL
β”‚   └── requirements.txt
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/      # React/TS
β”‚   β”‚   └── pages/
β”‚   └── package.json
β”œβ”€β”€ mobile/
β”‚   └── ios/                 # <- da ignorare (build)
β”œβ”€β”€ shared/
β”‚   └── types.ts             # <- focus qui (tipi condivisi)
└── README.md

.deepbase.toml:

ignore_dirs = [
    "backend/__pycache__",
    "frontend/node_modules",
    "mobile/ios",
    "mobile/android",
    "mobile/build"
]

ignore_files = [
    "frontend/package-lock.json",
    "backend/*.pyc"
]

Comando:

deepbase . --light --focus "backend/src/main.py" --focus "shared/types.ts"

πŸ’‘ Tips & Tricks

Verifica cosa verrΓ  incluso

# Genera solo struttura (veloce, per controllare)
deepbase . > structure.md

# Poi aggiungi --light o --all quando sei soddisfatto

Stima token prima di generare

Guarda la stima nell'output dell'albero:

πŸ“ my-project/ (245.6 KB | ~61.4k t)

Se troppo alto, aumenta le esclusioni nel TOML.

Ignorare file giΓ  nel contesto

DeepBase ignora automaticamente l'output file (llm_context.md di default) per evitare loop.

Usa con pipe

deepbase . --light | head -n 100  # prime 100 righe
deepbase . --light | wc -l        # conta righe

Hai un caso d'uso particolare? Apri una issue per aggiungerlo agli esempi!