https://github.com/asmitranjansinha/flowcraft-api
A FastAPI-based backend that validates whether a directed graph is a Directed Acyclic Graph (DAG) using Kahn’s Algorithm. It integrates with the Flowcraft frontend to analyze graph pipelines.
https://github.com/asmitranjansinha/flowcraft-api
dag fastapi flowcraft graph-algorithms kahns-alogrithm python
Last synced: 2 months ago
JSON representation
A FastAPI-based backend that validates whether a directed graph is a Directed Acyclic Graph (DAG) using Kahn’s Algorithm. It integrates with the Flowcraft frontend to analyze graph pipelines.
- Host: GitHub
- URL: https://github.com/asmitranjansinha/flowcraft-api
- Owner: asmitranjansinha
- License: mit
- Created: 2024-12-04T15:53:10.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2025-02-04T15:18:33.000Z (8 months ago)
- Last Synced: 2025-02-04T16:25:37.166Z (8 months ago)
- Topics: dag, fastapi, flowcraft, graph-algorithms, kahns-alogrithm, python
- Language: Python
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FastAPI DAG Checker (flowcraft-api)
## 📌 Project Overview
This is a FastAPI-based backend that provides an API to check if a directed graph is a Directed Acyclic Graph (DAG). It is designed to work with the **Flowcraft** frontend, which submits a pipeline to determine whether the graph is a DAG.
## 🚀 Features
- Parses and analyzes graph structures submitted via API
- Uses **Kahn’s Algorithm** to determine if the graph is a DAG
- Provides CORS support for frontend integration
- Fast and efficient processing using FastAPI## 🏗️ Project Architecture
```
backend/
├── main.py # FastAPI application
├── requirements.txt # Python dependencies
├── README.md # Project documentation
```## ⚙️ Installation and Setup
To run this project locally, follow these steps:
1. Clone the repository:
```sh
git clone
cd backend
```2. Create a virtual environment and activate it:
```sh
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```3. Install dependencies:
```sh
pip install -r requirements.txt
```4. Run the FastAPI server:
```sh
uvicorn main:app --reload
```The API will be available at `http://127.0.0.1:8000/`.
## 📡 API Endpoints
### Health Check
- **Endpoint:** `/`
- **Method:** `GET`
- **Response:** `{ "Ping": "Pong" }`### Parse Pipeline
- **Endpoint:** `/pipelines/parse`
- **Method:** `POST`
- **Request Body:**```json
{
"nodes": [{ "id": "A" }, { "id": "B" }, { "id": "C" }],
"edges": [
{ "source": "A", "target": "B" },
{ "source": "B", "target": "C" }
]
}
```- **Response:**
```json
{
"num_nodes": 3,
"num_edges": 2,
"is_dag": true
}
```## 🛠️ Dependencies
- `fastapi` - Web framework for Python
- `uvicorn` - ASGI server to run FastAPI apps## 🛡️ CORS Configuration
The backend supports CORS to allow requests from the frontend:
```python
app.add_middleware(
CORSMiddleware,
allow_origins=["http://localhost:3000"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
```## 🔗 Integration with Flowcraft
This backend is designed to work seamlessly with the **Flowcraft** frontend, which allows users to visually create and submit pipeline graphs for validation.
## 📜 License
This project is open-source and available under the [MIT License](LICENSE).
---
Feel free to contribute, report issues, or suggest improvements!
Happy coding! 🚀