- Docker and Docker Compose
- OpenAI API key for semantic analysis
- Anthropic API key (optional, for multimodal analysis)
Create a .env file in the root directory with the following variables:
# API Keys (at least one is required)
ANTHROPIC_API_KEY=your_anthropic_api_key_here
OPENAI_API_KEY=your_openai_api_key_here
# Database Configuration (not needed with Docker setup)
# DATABASE_URL is automatically configured in docker-compose.yml
# Server Configuration
PORT=8000 # FastAPI's conventional development port- Clone the Repository
git clone <repository-url>
cd knowledge-graph-expander- Quick Start
./run.shThis single command will:
- Set up the Docker environment
- Initialize the database
- Build the frontend
- Start the backend server
- Automatically find an available port (default: 8080)
- Make the application available at http://localhost:[PORT]
Note: If port 8080 is in use, the script will automatically find the next available port.
The application includes a user-friendly web interface for exploring and managing the knowledge graph:
- URL: http://localhost:[PORT]/explorer
- Features:
- Text analysis for automatic node and relationship extraction
- Manual node and relationship creation
- Graph visualization and exploration
- Advanced graph operations (export, suggestions, etc.)
- Options and Flags
# Start with database persistence
./run.sh --persist-db
# Force rebuild of Docker images
./run.sh --build
# Run in development mode with hot reloading
./run.sh --dev
# Run with a specific port
./run.sh --port=3000
# Stop the application
./stop.sh
# Stop and remove all data
./stop.sh --clean
# Force stop and clean up resources
./stop.sh --forceIf you prefer to run without Docker:
- Clone the Repository
git clone <repository-url>
cd knowledge-graph-expander- Install Python Dependencies
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt- Install Frontend Dependencies
cd frontend
npm install
npm run build
cd ..- Set up PostgreSQL
- Install PostgreSQL
- Create a database
- Update DATABASE_URL in your .env file
- Run the Server
uvicorn server.app:app --host 0.0.0.0 --port 8000 --reloadThe database schema is automatically created when the application starts. The schema includes:
- Nodes: Core entities in the knowledge graph
- Edges: Relationships between nodes
CREATE TABLE IF NOT EXISTS nodes (
id SERIAL PRIMARY KEY,
label TEXT NOT NULL,
type TEXT NOT NULL DEFAULT 'concept',
metadata JSONB DEFAULT '{}'::jsonb
);
CREATE TABLE IF NOT EXISTS edges (
id SERIAL PRIMARY KEY,
source_id INTEGER REFERENCES nodes(id),
target_id INTEGER REFERENCES nodes(id),
label TEXT NOT NULL DEFAULT 'related_to',
weight FLOAT NOT NULL DEFAULT 1.0,
metadata JSONB DEFAULT '{}'::jsonb
);For active development with hot reloading:
./run.sh --devThis will:
- Mount your local code directories into the container
- Enable hot reloading for both frontend and backend
- Show live logs in the console
The application is designed to be deployed in various environments:
- Configure your environment variables in
.env - Run
./run.sh --persist-dbto ensure data persistence - The application will be available on port 8080
For cloud environments like Heroku, Railway, or DigitalOcean:
- Use the Dockerfile for container-based deployments
- Configure database URL and API keys as environment variables
- Ensure the port is properly exposed and mapped
-
Docker Issues
- Ensure Docker and Docker Compose are installed and running
- Check logs with
docker-compose logs - The script automatically handles port conflicts by finding an available port
- You can manually specify a port with
--port=PORT(e.g.,--port=3000)
-
API Keys
- Verify at least one of OPENAI_API_KEY or ANTHROPIC_API_KEY is set
- Check for proper API key format
- Monitor API usage and rate limits
-
Database Issues
- If using external database, check connection string
- Verify database user has appropriate permissions
- Review database logs for errors
-
Frontend Issues
- Clear browser cache
- Check browser console for errors
- Verify WebSocket connection status
- Docker Logs:
docker-compose logs -f api - Database Monitoring: Connect to PostgreSQL with psql or a GUI tool
- API Metrics: Available at
/api/healthendpoint