A lightweight knowledge graph generator using FastAPI and Cytoscape.js
This project is a knowledge graph generator that utilizes FastAPI for the backend and Cytoscape.js for visualizing the graphs in the frontend. It is designed to be lightweight and easy to deploy using Docker and Kubernetes.
This repository accompanies a tutorial article. You can read it here.
- Python: Version 3.11
- Docker: Version 20.10 or higher
- Kubernetes: Version 1.21 or higher
- Node.js: For building frontend assets (if applicable)
- Accounts: Access to a Kubernetes cluster (e.g., GKE, EKS, AKS)
- Clone the repository:
git clone https://github.com/yourusername/civo-knowledge-graph-generator.git cd civo-knowledge-graph-generator - Build the Docker images:
docker build -t knowledge-backend ./ docker build -t knowledge-frontend ./frontend
- Set up environment variables (create a
.envfile):echo "RELAXAI_API_KEY=your_api_key" >> .env echo "RELAXAI_API_URL=https://api.example.com" >> .env
- Deploy to Kubernetes:
kubectl apply -f kubernetes/
- Access the application:
- Use the external IP of the frontend service to access the application in your browser.
.
├── .gitignore
├── Dockerfile
├── frontend
│ └── Dockerfile
├── requirements.txt
├── backend
│ └── main.py
├── frontend
│ └── index.html
└── kubernetes
├── backend-deployment.yaml
├── frontend-deployment.yaml
├── backend-service.yaml
└── frontend-service.yaml
- FastAPI: A modern web framework for building APIs with Python 3.6+ based on standard Python type hints.
- Cytoscape.js: A JavaScript library for visualizing complex networks and graphs.
- Docker & Kubernetes: Tools for containerization and orchestration, allowing for scalable deployment of applications.
- FastAPI Application: The main FastAPI application in
backend/main.pydemonstrates how to handle API requests and process data for generating knowledge graphs. - Docker Configuration: The
Dockerfilefor the backend shows how to create a lightweight containerized application with proper dependency management. - Kubernetes Deployment: The YAML files in the
kubernetesdirectory illustrate how to deploy the application in a Kubernetes environment, including service exposure and scaling.
This project is licensed under the MIT License. See the LICENSE file for details.