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.
- 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
backend/
├── main.py # FastAPI application
├── requirements.txt # Python dependencies
├── README.md # Project documentation
To run this project locally, follow these steps:
-
Clone the repository:
git clone <repository-url> cd backend
-
Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Run the FastAPI server:
uvicorn main:app --reload
The API will be available at http://127.0.0.1:8000/
.
- Endpoint:
/
- Method:
GET
- Response:
{ "Ping": "Pong" }
-
Endpoint:
/pipelines/parse
-
Method:
POST
-
Request Body:
{ "nodes": [{ "id": "A" }, { "id": "B" }, { "id": "C" }], "edges": [ { "source": "A", "target": "B" }, { "source": "B", "target": "C" } ] }
-
Response:
{ "num_nodes": 3, "num_edges": 2, "is_dag": true }
fastapi
- Web framework for Pythonuvicorn
- ASGI server to run FastAPI apps
The backend supports CORS to allow requests from the frontend:
app.add_middleware(
CORSMiddleware,
allow_origins=["http://localhost:3000"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
This backend is designed to work seamlessly with the Flowcraft frontend, which allows users to visually create and submit pipeline graphs for validation.
This project is open-source and available under the MIT License.
Feel free to contribute, report issues, or suggest improvements!
Happy coding! 🚀