Multi-tenant knowledge graph system for personal data synchronization with Google services (Calendar, Contacts, Drive, Photos).
EPANSA Orchestrator is a FastAPI-based backend system that:
- Authenticates users via Google OAuth
- Synchronizes data from Google services
- Builds and maintains personal knowledge graphs in Neo4j
- Provides secure storage for OAuth tokens in PostgreSQL
- Uses AI/ML models for data processing and embeddings
- Python 3.11+ - Core language
- FastAPI - Web framework
- Neo4j 5 - Graph database for knowledge graphs
- PostgreSQL 15 - Relational database for secure token storage
- Docker - Containerization
- uv - Fast Python package installer and resolver
- uv - Fast Python package manager
- Docker and Docker Compose
- Python 3.11 or higher (if running locally)
- Go to the Google Cloud Console.
- Create a new project or select an existing one for Web application.
- Navigate to "APIs & Services" > "Credentials".
- Click "Create Credentials" and select "OAuth 2.0 Client IDs".
- Choose "Web application" as the application type.
- Set the authorized redirect URIs to `http://localhost:5000/auth/callback
- Download the
client_secret.jsonfile. - Place the
client_secret.jsonfile in the project root directory.
# On macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# On Windows
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"# Create virtual environment and install all dependencies
uv sync
# Activate the virtual environment
source .venv/bin/activate # On macOS/Linux
# or
.venv\Scripts\activate # On Windows# Copy the example environment file
cp example.env .env
# Edit .env with your actual configuration
# - Database credentials
# - Neo4j credentials
# - Google OAuth client credentials
# - JWT secrets# Start all services (PostgreSQL, Neo4j, API)
docker compose up -d
# View logs
docker compose logs -f api
# Stop all services
docker compose downThe API will be available at http://localhost:5000
Neo4j Browser will be available at http://localhost:7474
# Add a new dependency
uv add package-name
# Add a development dependency
uv add --dev package-name
# Add a dependency with version constraint
uv add "package-name>=1.0.0,<2.0.0"# Update all dependencies
uv sync --upgrade
# Update a specific package
uv add package-name --upgrade# Remove a dependency
uv remove package-nameThe Dockerfile uses a multi-stage build with uv:
- Builder stage: Installs dependencies using uv into a virtual environment
- Runtime stage: Copies the virtual environment and application code
Benefits:
- Smaller final image size
- Faster builds with better caching
- Reproducible builds with
uv.lock
.
├── backend/ # FastAPI application
│ ├── app.py # Main application entry point
│ ├── core/ # Core utilities (config, auth, security)
│ ├── models/ # Pydantic models
│ ├── routers/ # API route handlers
│ └── services/ # Business logic services
├── libs/ # Shared libraries
│ └── llm_graph_builder/ # Knowledge graph builder
├── data/ # Runtime data (sync state, temp files)
├── pyproject.toml # Project configuration and dependencies
├── uv.lock # Locked dependency versions
├── Dockerfile # Multi-stage Docker build
└── docker-compose.yml # Service orchestration
POST /auth/login- Initiate Google OAuth flowPOST /auth/callback- OAuth callback handlerGET /auth/me- Get current user infoPOST /sync/trigger- Trigger manual sync for a user- More endpoints documented in the FastAPI auto-generated docs at
/docs
# Install dependencies
uv sync
# Run the API locally (without Docker)
uvicorn backend.app:app --reload --port 5000
# Run tests (if available)
uv run pytest
# Format code (if you add formatters)
uv run black backend/
uv run isort backend/
# Type checking (if you add mypy)
uv run mypy backend/This project has been migrated from requirements.txt to pyproject.toml with uv:
pip install -r requirements.txt
pip install -r libs/llm_graph_builder/requirements.txtuv syncAll dependencies from both requirements.txt files are now consolidated in pyproject.toml.
- Ensure you have the latest version of uv in the Dockerfile
- Clear Docker build cache:
docker builder prune
- Delete
.venvand runuv syncagain - Check
uv.lockis committed to version control
- Ensure you've activated the virtual environment
- Run
uv syncto ensure all dependencies are installed
[Add your license here]
[Add contribution guidelines here]