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!