cheshire-cat-ai / plugins-backend

The backend of The Cheshire Cat plugin directory
GNU General Public License v3.0
7 stars 5 forks source link

Awesome plugins backend

The backend of The Cheshire Cat plugin directory

Getting started...

Using Docker

$ docker compose up

Using local python environment

Install requirements:

$ pip install -r requirements.txt

Start uvicorn server:

$ python ./main.py

API Documentation

Welcome to the API documentation for our plugin directory. Below, you'll find a list of available endpoints to interact with the system.

Index


List all Plugins (Paginated)

GET /plugins

List all the plugins.

Order Parameter:

Pagination Parameters:

Example: Return the second page, 3 plugins per page ordered from newest to oldest

/plugins?page=2&page_size=3&order=newest

List Excluded Plugins (Paginated)

POST /excluded

List the plugins excluding the ones you pass in the body.

Request Body:

{
  "excluded": ["plugin to exclude", "other plugin I don't want"]
}

Pagination Parameters:

Example: Return the second page, 3 plugins per page

/exclude?page=2&page_size=3

List Plugins by Author (Paginated)

POST /author

List all the plugins from a specific author.

Request Body:

{
  "author_name": "Nicola Corbellini"
}

Pagination Parameters:

Example: Return the second page, 3 plugins per page

/author?page=2&page_size=3

Get All Available Tags

GET /tags

Return the list of all available plugins' tags.


Get Plugins by Tag (Paginated)

GET /tag/{tag}

Return all the plugins that have a specific tag.

Pagination Parameters:

Example: Return the second page, 3 plugins per page

/tag/{tag}?page=2&page_size=3

Download a Single Plugin (.zip)

POST /download

Download a single plugin in .zip format.

Request Body:

{
  "url": "https://github.com/pieroit/meow-todo-list"
}

Search for a Plugin

POST /search

Search for a plugin. This will perform a search in plugins' description, name, author, and tags.

Request Body:

{
  "query": "llm embedding nicola corbellini"
}

Get Plugins' Analytics

GET /analytics

Return all the plugins' analytics.


Plot Plugins' Analytics Graph

GET /analytics/graph

Return an HTML webpage with an image of plugins' analytics graph.

Graph example


Plugin manifest validation

The validation process for the plugin.json manifest ensures the integrity and usability of plugins within the repository. To successfully pass validation, the plugin.json file must reside within the main branch of the repository and include essential fields such as "name" and "author_name". While other fields remain optional, including additional information not only enhances the user experience but also improves searchability within the directory. Maintaining these validation criteria not only guarantees the quality of plugins but also contributes to a more robust and user-friendly plugin ecosystem.

Caching System

Our caching system is designed to optimize performance and reduce redundant operations. Currently, most of the caching is memory-based, which means it gets reset upon system shutdown. Additionally, our cache is invalidated on a daily basis, precisely every 1440 minutes.

File Cache

When the /download endpoint is initially called, our system sets up two essential folders: zip_cache and repository_cache.

We employ a comprehensive strategy to determine whether a repository or release has been downloaded and whether it's up-to-date. If the repository is present and current, we retrieve and provide the existing zip file. However, if the repository is outdated or if any issues arise while verifying its status, the existing repository is deleted. Subsequently, we initiate a fresh download to ensure accuracy.

This approach serves two key purposes: efficient repository caching and the prevention of unnecessary cloning operations when a repository is already available and up-to-date.

Analytics

The implementation of analytics within our plugin's directory is designed with utmost consideration for user privacy. We maintain an analytics.json file that is updated each time a plugin is downloaded, providing us with valuable insights into usage trends without compromising individual user identities. Importantly, we do not track unique downloads or store any sensitive data such as IP addresses. Our approach to analytics prioritizes user privacy, ensuring that our data collection methods, while not overly precise, remain fair and respectful of the privacy of our users. This commitment to data ethics underscores our dedication to creating a transparent and user-friendly environment within our plugin ecosystem.