This is the backend API server for the SingleStore Knowledge Graph application. It can be deployed both locally and on Replit or Railway.
- Python 3.12.9
- SingleStore database access
- OpenAI API key
- Google Gemini API key
- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Create a
.env
file in the root directory with:
OPENAI_API_KEY=your_openai_key
GEMINI_API_KEY=your_gemini_key
SINGLESTORE_HOST=your_host
SINGLESTORE_PORT=your_port
SINGLESTORE_USER=your_user
SINGLESTORE_PASSWORD=your_password
SINGLESTORE_DATABASE=your_database
- Run the server locally:
./start_backend_services.sh # On Windows: python main.py
The server will start at http://localhost:8000
- Create a new Python repl on Replit
- Upload all the files from this directory
- Add environment variables in Replit Secrets
- Click "Run" to deploy
The server will be available at your Replit URL (e.g., https://your-repl-name.username.repl.co
)
- Fork this repository
- Create a new project on Railway
- Connect your GitHub repository
- Add the following environment variables in Railway:
OPENAI_API_KEY=your_openai_key GEMINI_API_KEY=your_gemini_key SINGLESTORE_HOST=your_host SINGLESTORE_PORT=your_port SINGLESTORE_USER=your_user SINGLESTORE_PASSWORD=your_password SINGLESTORE_DATABASE=your_database API_KEY=your_secure_api_key
- Deploy! Railway will automatically build and deploy your application
The server will be available at your Railway URL (e.g., https://your-app-name.railway.app
)
.
├── .replit # Replit configuration
├── api/ # API endpoints
├── config/ # Configuration management
├── core/ # Core business logic
├── db/ # Database operations
├── processors/ # Document processors
├── search/ # Search functionality
├── tasks/ # Background tasks
├── utils/ # Utility functions
├── main.py # FastAPI application
├── requirements.txt # Python dependencies
└── start_backend_services.sh # Local startup script
/kbdata
: Knowledge base statistics/config
: System configuration/upload
: Document upload/search
: Document search/graph
: Knowledge graph/task-status
: Processing status/cancel-processing
: Cancel tasks
Visit /docs
or /redoc
for complete API documentation.
See .env.example
for all required environment variables.
- Free tier Replit has limitations (512MB RAM, 500MB storage)
- Server sleeps after inactivity on free tier
- Consider "Always On" feature for production use