๐ Datapizza-AI PHP
Designed and built on a Raspberry Pi Model B (2011). No GPU, no Docker, no excuses.
Datapizza-AI PHP is an educational, ultra-minimal port of the original Datapizza AI, rewritten in pure PHP 7.x.
It doesnโt try to compete with Python. It exists to remind you that understanding beats horsepower.
This project lets you explore how an AI system actually works โ embeddings, vector stores, retrieval pipelines, and agents โ using the most classic web language of them all.
๐ง Why?
Most AI frameworks assume a cloud GPU farm. This one assumes you have an SD card, a coffee, and curiosity โ and a clear view of how APIs really work.
Datapizza-AI PHP is API-first by design. Instead oโฆ
๐ Datapizza-AI PHP
Designed and built on a Raspberry Pi Model B (2011). No GPU, no Docker, no excuses.
Datapizza-AI PHP is an educational, ultra-minimal port of the original Datapizza AI, rewritten in pure PHP 7.x.
It doesnโt try to compete with Python. It exists to remind you that understanding beats horsepower.
This project lets you explore how an AI system actually works โ embeddings, vector stores, retrieval pipelines, and agents โ using the most classic web language of them all.
๐ง Why?
Most AI frameworks assume a cloud GPU farm. This one assumes you have an SD card, a coffee, and curiosity โ and a clear view of how APIs really work.
Datapizza-AI PHP is API-first by design. Instead of hiding remote calls behind black boxes, it exposes how every request, embedding, and retrieval happens step by step.
It was built to:
- demystify AI logic for web developers and hobbyists,
- prove that PHP can still teach serious computer science,
- run on low-power hardware (file-based, no DB, no composer),
- serve as a DIY / educational sandbox for students, makers, and retro-computing fans.
Itโs not enterprise-grade cloud software โ but itโs perfectly capable of powering local automations, document search, and home-lab AI experiments.
With native integration for n8n and Model Context Protocol (MCP), Datapizza-AI PHP acts as a bridge between your local logic and modern AI ecosystems. You can orchestrate flows, manage context, and exchange data between models and sensors โ all from a Raspberry Pi or any small self-hosted box.
Every cosine distance, every JSON write, every API call is visible and hackable.
๐งฉ How it differs from everything else out there
Most AI frameworks โ Python or otherwise โ are monuments to dependency hell. They need Conda, CUDA, Poetry, virtual environments, and a small prayer. Even the few PHP ones that exist wrap around massive SDKs and require hardware that would melt a Raspberry Pi.
Datapizza-AI PHP takes the opposite path: itโs not a layer on top of another layer โ itโs the ground floor, built brick by brick.
- No Composer, no Docker, no Conda.
- No hidden daemons or background services.
- Algorithms written line by line, from scratch.
- Vector stores as plain JSON, readable with any text editor.
- Cosine similarity calculated in vanilla PHP โ no math libraries required.
- Designed to run where complexity isnโt welcome: your local machine.
If Python frameworks are skyscrapers, this oneโs the garage workshop โ messy, curious, and transparent. You can open it, break it, fix it, and understand it.
๐งฉ Architecture overview
datapizza-ai-php/
โโโ agents/ # Core agents (Base, ReactAgent, AgentWithMemory)
โโโ clients/ # API clients (OpenAI, Anthropic, DeepSeek, etc.)
โโโ embedders/ # Text embedding generators
โโโ integrations/ # Tiny HTTP server + endpoints
โโโ memory/ # Conversation state manager
โโโ modules/ # Parsers, retrieval utilities
โโโ pipeline/ # DAG + ingestion + RAG pipeline
โโโ tools/ # External tools (Wikipedia, DuckDuckGo, Calculator)
โโโ utils/ # Helpers (cosine, locks, logs)
โโโ vectorstores/ # Local JSON-based vector store
โโโ examples/ # Demos and quick tests
Each folder is self-contained, readable, and ready to hack.
โ๏ธ Requirements
- PHP โฅ 7.0 (only
curlandjson) - 256 MB RAM is plenty
- Internet required only for API calls
Works on:
- Raspberry Pi Model B (2011) โ launched at $35, sipping around 3 watts of power
- Zero W / 3B / 4
- Any shared hosting or XAMPP/LAMP stack
โRuns happily on boards that cost less than your monthly coffee habit.โ
๐ Quick start
git clone https://github.com/yourhandle/datapizza-ai-php.git
cd datapizza-ai-php
php -S localhost:8080 -t examples
php examples/hello_pizza.php
Expected output:
๐ Hello from Datapizza-AI PHP โ running fine on pure curiosity!
๐งฎ How it works
- Embeddings โ text โ vector (
text-embedding-3-small), saved in/data/vectors.json. - Vector Store โ file-based cosine search in PHP; no SQL, no FAISS, just math.
- RAG Pipeline โ
ingestion_pipeline.phpindexes,dag_pipeline.phpretrieves context. - Agents + Tools โ
ReactAgentreasons and callscalculator,wikipedia_search,duckduckgo_search. - Memory โ
conversation_memory.phpkeeps a lightweight dialogue state.
๐งช Demo scripts
Everything lives in plain JSON. Similarity is computed transparently:
$similarity = $dot / (sqrt($na) * sqrt($nb));
No vector databases. No hidden optimizations. Just logic and loops.
Thatโs it โ no NumPy, no BLAS, no GPU acceleration. Just math, curiosity, and a board that sips about 3 watts of power.
๐งฉ Design principles
- Zero dependencies โ everything hand-coded in PHP
- API-first โ callable via HTTP or CLI
- Readable > Optimal โ clarity beats performance
- Runs anywhere โ shared hosts, Raspberry Pi, old netbooks
- Transparent โ trace every step, understand every result
This is not about horsepower โ itโs about comprehension.
๐ For DIY, Makers & Local Hosting
Despite its educational DNA, Datapizza-AI PHP can actually do work. Run it on your Raspberry Pi or an old laptop and it becomes a local AI sandbox โ ideal for:
- indexing and querying personal notes or PDF docs,
- powering a voice or chat assistant for your home automation,
- experimenting with sensors, APIs, and reasoning tasks,
- building fully private prototypes that never leave your LAN.
No cloud lock-in. No telemetry. Just your data, your machine, and a few hundred lines of PHP.
๐งโ๐ซ Educational example
require_once 'pipeline/ingestion_pipeline.php';
require_once 'agents/react_agent.php';
$agent = new ReactAgent(['calculator','wikipedia_search']);
echo $agent->run("Who invented the microprocessor?");
Pipeline:
- Create embedding
- Store vectors into the local vector store (
/data/vectors.json) - Retrieve context
- Prompt LLM
- Print answer
Thatโs RAG โ no frameworks, no cloud, no mystery.
โ ๏ธ Known limits
- Remote embeddings only
- File I/O uses simple locks
- Single-thread execution
- Educational purpose only
๐ก Future ideas
- Optional SQLite backend
- Tiny web UI for debugging
- Extra tools (YouTube, PDF)
- SHA-1 embedding cache
- โAI on Raspberryโ tutorial series
๐ License
MIT License ยฉ 2025 Built by Paolo [paolomulas]
โค๏ธ Credits
Inspired by Datapizza Labs This PHP port brings RAG and AI agents to the PHP ecosystem, running on vintage Raspberry Pi hardware.