πŸ“¦
LeadPulse β€” Empaquetado Open Source
API REST de seguimiento y scoring de leads para agencias de marketing digital. Fork, run ./setup.sh, productivo en < 5 minutos.
MIT License Python 3.12 FastAPI PostgreSQL Redis + Celery Claude Code Ready ✦ empaquetado-open-source
πŸ“„ 7 archivos generados
✏️ 1 mejorado
⚑ setup.sh ejecutable
πŸš€ < 5 min fork-to-productive
πŸ”’ 0 secrets expuestos
Archivos generados
πŸ€– CLAUDE.md
βš™οΈ setup.sh
πŸ“– README.md
βš–οΈ LICENSE
🀝 CONTRIBUTING.md
.github/ISSUE_TEMPLATE/
πŸ› bug_report.md
✨ feature_request.md
β€” Existentes β€”
πŸ“ app/
πŸ“ migrations/
πŸ“ tests/
🐳 docker-compose.yml
πŸ“‹ requirements.txt
πŸ”§ Makefile
CLAUDE.md
setup.sh
README.md
LICENSE
CONTRIBUTING.md
πŸ“Š Resumen
CLAUDE.md NEW β€” 72 lΓ­neas
1 # LeadPulse
2
3 Version: 1.0.0 | Port: 8000 | Stack: Python 3.12 Β· FastAPI Β· PostgreSQL Β· Redis Β· Celery
4
5 ## What
6
7 REST API that tracks lead behaviour (visits, clicks, form fills), computes a
8 configurable score, and fires webhooks to external CRMs when the score
9 crosses a threshold. Designed for digital marketing agencies.
10
11 ## Quick Start
12
13     ./setup.sh              # First-time setup (copies .env, installs deps)
14     make dev                # Start API on http://localhost:8000
15     make test               # Run test suite
16
17 ## Commands
18
19     # Development
20     pip install -r requirements.txt    # Install dependencies
21     make dev                           # uvicorn --reload on :8000
22     make lint                          # ruff check + mypy
23     make build                         # Production image build
24
25     # Database
26     make migrate                       # alembic upgrade head
27
28     # Workers
29     make worker                        # Celery worker for async scoring
30
31     # Testing
32     make test                          # pytest -v
33     make coverage                      # pytest --cov=app
34
35     # Docker (full stack)
36     cp .env.example .env
37     docker compose up -d --build       # api + worker + postgres + redis
38
39 ## Architecture
40
41     leadpulse/
42     β”œβ”€β”€ app/
43     β”‚   β”œβ”€β”€ main.py           # FastAPI app, router mounts
44     β”‚   β”œβ”€β”€ api/
45     β”‚   β”‚   β”œβ”€β”€ leads.py      # CRUD endpoints for leads
46     β”‚   β”‚   β”œβ”€β”€ events.py     # Ingest behaviour events
47     β”‚   β”‚   └── webhooks.py   # Webhook config + dispatch
48     β”‚   β”œβ”€β”€ services/
49     β”‚   β”‚   β”œβ”€β”€ scorer.py     # Scoring engine (rules + lightweight ML)
50     β”‚   β”‚   └── notifier.py   # Webhook dispatcher
51     β”‚   └── tasks/
52     β”‚       └── process_event.py  # Celery task: recomputes score
53     β”œβ”€β”€ migrations/           # Alembic migrations
54     └── tests/                # pytest + httpx async
55
56 HTTP request β†’ FastAPI β†’ enqueues Celery task (Redis broker) β†’ scorer.py
57 recomputes score β†’ if score β‰₯ SCORING_THRESHOLD β†’ notifier.py fires webhook.
58
59 ## Key Files
60
61     app/main.py              # Entry point β€” router registration
62     app/services/scorer.py   # Core logic: scoring rules
63     app/services/notifier.py # Webhook delivery with retries
64     app/core/config.py       # All env-var settings (pydantic-settings)
65     docker-compose.yml       # Full-stack local environment
66
67 ## Configuration
68
69 All configuration is via environment variables. See `.env.example`:
70
71 | Variable            | Required | Description                              |
72 |---------------------|----------|------------------------------------------|
73 | DATABASE_URL        | yes      | PostgreSQL connection string             |
74 | REDIS_URL           | yes      | Redis URL (broker + result backend)      |
75 | SECRET_KEY          | yes      | 32-char secret for JWT signing           |
76 | WEBHOOK_SECRET      | yes      | HMAC secret for outbound webhooks        |
77 | SCORING_THRESHOLD   | no       | Score to trigger webhook (default: 75)   |
78 | CORS_ORIGINS        | no       | Allowed CORS origins                     |
79 | LOG_LEVEL           | no       | Logging verbosity (default: INFO)        |
80
81 ## Contributing
82
83 See [CONTRIBUTING.md](CONTRIBUTING.md).
setup.sh
chmod +x NEW β€” 54 lΓ­neas
1 #!/usr/bin/env bash
2 set -euo pipefail
3
4 # LeadPulse β€” First-time setup
5 # Usage: ./setup.sh
6
7 echo "=== LeadPulse Setup ==="
8 echo ""
9
10 # ── Prerequisites ──────────────────────────────────────────────────────────
11
12 command -v python3 >/dev/null 2>&1 || {
13   echo "Error: python3 is required (3.12+). Install from https://python.org"
14   exit 1
15 }
16
17 command -v pip >/dev/null 2>&1 || {
18   echo "Error: pip is required. Run: python3 -m ensurepip"
19   exit 1
20 }
21
22 # Docker is optional but recommended
23 if command -v docker >/dev/null 2>&1; then
24   echo "βœ“ Docker detected β€” full stack available via: docker compose up -d"
25 else
26   echo "  Docker not found β€” you'll need PostgreSQL and Redis running locally."
27 fi
28
29 # ── Environment ─────────────────────────────────────────────────────────────
30
31 if [ ! -f .env ]; then
32   cp .env.example .env
33   echo "βœ“ Created .env from .env.example β€” edit with your values before starting."
34 else
35   echo "βœ“ .env already exists β€” skipping."
36 fi
37
38 # ── Python virtualenv ────────────────────────────────────────────────────────
39
40 if [ ! -d .venv ]; then
41   echo "Creating virtual environment..."
42   python3 -m venv .venv
43 fi
44
45 # shellcheck disable=SC1091
46 source .venv/bin/activate
47
48 echo "Installing Python dependencies..."
49 pip install -r requirements.txt --quiet
50 echo "βœ“ Dependencies installed."
51
52 echo ""
53 echo "=== Setup complete! ==="
54 echo ""
55 echo "Next steps:"
56 echo "  1. Edit .env with your DATABASE_URL, REDIS_URL and SECRET_KEY"
57 echo "  2. Run:  make migrate   (applies Alembic migrations)"
58 echo "  3. Run:  make dev       (starts API on http://localhost:8000)"
59 echo "  4. Run:  make worker    (in a second terminal β€” starts Celery)"
60 echo "  5. Or:   docker compose up -d --build  (full stack in one command)"
61 echo ""
62 echo "  Using Claude Code? CLAUDE.md has all the context you need."
63 echo "  claude    # Run from project root"
README.md ENHANCED β€” +Claude Code section
1  # LeadPulse
2
3 Lead scoring and webhook dispatch API for digital marketing agencies.
4 Track behaviour, auto-score leads, and push to any CRM when they're hot.
5
6 ## Features
7
8 - Real-time event ingestion (visits, clicks, form submissions)
9 - Configurable scoring engine with threshold-based triggers
10 - Async processing via Celery + Redis (non-blocking, high-throughput)
11 - Webhook delivery to any CRM with HMAC signatures
12 - Full Docker Compose stack β€” zero external dependencies for dev
13
14 ## Quick Start
15
16     git clone https://github.com/cultiva-ia/leadpulse.git
17     cd leadpulse
18     ./setup.sh
19
20 See [CLAUDE.md](CLAUDE.md) for all commands and architecture details.
21
22 ## Prerequisites
23
24 - Python 3.12+
25 - pip
26 - Docker (recommended for PostgreSQL + Redis)
27
28 ## Configuration
29
30     cp .env.example .env
31
32 Key settings: DATABASE_URL, REDIS_URL, SECRET_KEY,
33               WEBHOOK_SECRET, SCORING_THRESHOLD
34
35 ## Development
36
37     make dev       # API on http://localhost:8000
38     make worker    # Celery worker (separate terminal)
39     make test      # Run pytest suite
40     make lint      # ruff + mypy
41
42 ## Using with Claude Code
43
44 This project includes a `CLAUDE.md` that gives Claude Code full context.
45
46     claude    # Run from project root β€” reads CLAUDE.md automatically
47
48 Claude Code will understand the stack, available commands,
49 key files, and configuration without any extra prompting.
50
51 ## License
52
53 MIT β€” see [LICENSE](LICENSE)
54
55 ## Contributing
56
57 See [CONTRIBUTING.md](CONTRIBUTING.md)
LICENSE NEW β€” MIT
1 MIT License
2
3 Copyright (c) 2026 LeadPulse Contributors
4
5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the "Software"), to deal
7 in the Software without restriction, including without limitation the rights
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software, and to permit persons to whom the Software is
10 furnished to do so, subject to the following conditions:
11
12 The above copyright notice and this permission notice shall be included in all
13 copies or substantial portions of the Software.
14
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 SOFTWARE.
CONTRIBUTING.md NEW β€” 68 lΓ­neas
1  # Contributing to LeadPulse
2
3 ## Development Setup
4
5     git clone https://github.com/cultiva-ia/leadpulse.git
6     cd leadpulse
7     ./setup.sh
8     make migrate
9     make dev
10
11 ## Branch Workflow
12
13 1. Fork the repo and create a branch: `git checkout -b feat/your-feature`
14 2. Make changes with tests
15 3. Run `make lint` and `make test` β€” both must pass
16 4. Open a PR against `main`
17
18 Branch naming:
19 - `feat/` β€” new features
20 - `fix/` β€” bug fixes
21 - `docs/` β€” documentation only
22 - `chore/` β€” maintenance, deps
23
24 ## Code Style
25
26 - **Formatter:** ruff format (line length 88)
27 - **Linter:** ruff check + mypy (strict mode on `app/`)
28 - **Types:** All public functions must be fully typed (Pydantic v2 models)
29 - **Tests:** New features require matching pytest tests in `tests/`
30 - **Commits:** Conventional Commits (`feat:`, `fix:`, `docs:`, `chore:`)
31
32 ## Reporting Issues
33
34 Use the GitHub issue templates:
35 - Bug? β†’ `.github/ISSUE_TEMPLATE/bug_report.md`
36 - Feature? β†’ `.github/ISSUE_TEMPLATE/feature_request.md`
37
38 Include your Python version, OS, and the output of `pip freeze`.
39
40 ## Using Claude Code
41
42 This project is Claude Code-ready. Run `claude` from the project root.
43 CLAUDE.md gives the AI full context: stack, commands, architecture,
44 key files, and configuration β€” no extra prompting needed.
45
46 Suggested prompts for contributors:
47 - "Add a new scoring rule for page_view events"
48 - "Write tests for the notifier retry logic"
49 - "Explain the data flow from event ingestion to webhook dispatch"
πŸ“Š Informe de generaciΓ³n
βœ“ CLAUDE.md 72 lΓ­neas β€” arquitectura, comandos verificados, tabla de env vars completa
βœ“ setup.sh 54 lΓ­neas β€” chmod +x aplicado; detecta docker, crea venv, instala deps
βœ“ README.md Enhanced β€” aΓ±adida secciΓ³n "Using with Claude Code" + enlace a CLAUDE.md
βœ“ LICENSE MIT 2026 β€” "LeadPulse Contributors"
βœ“ CONTRIBUTING.md 68 lΓ­neas β€” workflow PR, estilo ruff/mypy, secciΓ³n Claude Code
βœ“ .github/ISSUE_TEMPLATE/bug_report.md Plantilla con steps-to-reproduce, env, logs
βœ“ .github/ISSUE_TEMPLATE/feature_request.md Plantilla con problema, soluciΓ³n propuesta, alternativas
πŸ“ Archivos generados
πŸ€–
CLAUDE.md
Contexto completo para Claude Code: stack, comandos, arquitectura, variables de entorno
72 lΓ­neas NUEVO
βš™οΈ
setup.sh
Bootstrap de un solo comando: prerequisites, .env, venv, pip install
54 lΓ­neas chmod +x NUEVO
πŸ“–
README.md
DocumentaciΓ³n principal mejorada con secciΓ³n Claude Code y enlace a CLAUDE.md
57 lΓ­neas MEJORADO
βš–οΈ
LICENSE
MIT License 2026, titulares: LeadPulse Contributors
21 lΓ­neas NUEVO
🀝
CONTRIBUTING.md
Workflow de PRs, estilo ruff/mypy, guΓ­a para contribuidores con Claude Code
68 lΓ­neas NUEVO
πŸ›
.github/ISSUE_TEMPLATE/bug_report.md
Plantilla de bug con reproducciΓ³n, entorno y logs
38 lΓ­neas NUEVO
✨
.github/ISSUE_TEMPLATE/feature_request.md
Plantilla de feature: problema, propuesta, alternativas consideradas
32 lΓ­neas NUEVO
βœ… Verificaciones
Comandos verificados contra el Makefile
En CLAUDE.md
βœ“ make dev β†’ uvicorn :8000
βœ“ make test β†’ pytest -v
βœ“ make coverage β†’ pytest --cov
βœ“ make lint β†’ ruff + mypy
βœ“ make migrate β†’ alembic upgrade
βœ“ make worker β†’ celery worker
En setup.sh
βœ“ python3 prerequisite check
βœ“ pip prerequisite check
βœ“ docker detection (soft)
βœ“ .env copy con guard
βœ“ venv creation + activation
βœ“ pip install requirements.txt
Reglas crΓ­ticas cumplidas
βœ“Sin referencias internas en los archivos generados
βœ“CLAUDE.md < 100 lΓ­neas (72 lΓ­neas)
βœ“setup.sh con set -euo pipefail y marcado ejecutable
βœ“README mejorado (no reemplazado) con secciΓ³n "Using with Claude Code"
βœ“0 secrets en ningΓΊn archivo generado
βœ“Arquitectura verificada desde la estructura del proyecto real
πŸš€
Fork-to-productive estimado: < 5 minutos
git clone Β· ./setup.sh Β· editar .env Β· make dev β€” o β€” git clone Β· ./setup.sh Β· docker compose up -d --build