Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate API Documentation Dynamically Using AI #176

Open
KrishnaVAMSI-2003 opened this issue Dec 11, 2024 · 1 comment · Fixed by #173
Open

Generate API Documentation Dynamically Using AI #176

KrishnaVAMSI-2003 opened this issue Dec 11, 2024 · 1 comment · Fixed by #173
Assignees
Labels
enhancement New feature or request

Comments

@KrishnaVAMSI-2003
Copy link
Contributor

KrishnaVAMSI-2003 commented Dec 11, 2024

Description

We aim to implement a feature that dynamically generates API documentation using AI when the server mounts. This feature will ensure that all routes, controllers, and serializer methods for each module in the application are documented comprehensively and professionally. The generated documentation will be accessible via a dedicated /api/documentation route.

Requirements

1. Route Data Extraction

  • On server startup, the system should automatically scan all modules to identify and extract route-related metadata, including:
    • Controller methods
    • Serializer methods
    • Additional details required to generate meaningful API documentation

2. AI-Powered Documentation Generation

  • Send the extracted route data to an AI model (e.g., OpenAI or any other suitable provider).
  • Include a descriptive prompt to ensure high-quality, contextually accurate documentation is generated for all provided routes.
  • There is a chance of having more number of routes in large projects, which might result issues with token size limits. The implementation should generate and inject the document in chunks.

3. Inject Generated Documentation and expose a route

  • Save the AI-generated documentation as static readme file under the dist folder.
  • This file should be structured to be easily accessed by the frontend.
  • Expose an api /api/get-documentation under documentation module, that returns the markdown documentation.

4. Frontend Integration

  • Serve the generated documentation via the /api/documentation route, enabling seamless access and display in the frontend.

Deliverables

  • Updated server logic to scan and process route data on startup.
  • A script or service to communicate with the AI model and handle documentation generation.
  • Integration logic to inject the documentation into the dist folder.
  • An accessible /api/documentation route for frontend consumption.

This feature is essential for improving the usability and accessibility of the backend API and will serve as a showcase of automation in the development pipeline.

@KrishnaVAMSI-2003
Copy link
Contributor Author

There are some issues/missed things that have been found while implemented this in Picket, which includes:

  • The documentation is incomplete, it haven't generated documentation for all the routes. There are about 78 routes, so this might have happened due to the token size limits. Need update the implementation to generate and inject the document in chunks.
  • There are some instances where the routes are incorrectly represented like /api/tournaments/(?::id)/games/(?::id)/game-final-outcomes, this is happening if there are "/:id" formatted route in server (base path of module). Just need to replace the regrex properly with :/id.

Which needs to be addressed in follow up PR's.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
1 participant