Β
High-Level System Design Diagram:
Β
Β
Sequence Diagram
Β
User FastAPI App GitHub ChatGPT Supabase DB β β β β β β POST /run with β β β β β githubURL & prompt β β β β β ββββββββββββββββββββββ> β β β β β β ββ Fetch code ββ> β β β β β <β Return codeβββ β β β β β β β β β β βββββββββββ code + prompt βββββββββββββ> β β β β <βββββββββββ suggestion ββββββββββββββββββ€ β | | | | | | | | | | | β ββββββββ suggestion + prompt ββββββββββ> β β β β <βββββββββββ reflection ββββββββββββββββββ€ β | | | | | β β <ββββββββββββββββββ€ β β β β Calculate diff β β β β β β β β Store in DB ββββββββββββββββββββββββββββββββββββββββββββββ> | β <---- Return diff β β β
Β
Text-Based System Design
Β
System Components:
- FastAPI Server - The core application server that handles web requests.
- GitHub Interaction Module - Fetches code from a specified GitHub repository URL.
- ChatGPT Interaction Module - Sends prompts to the ChatGPT API and retrieves code suggestions.
- Reflection Module - Processes the ChatGPT suggestions further, potentially refining them.
- Diff Generator - Calculates the differences between the original code and the suggested code.
- Supabase DB - Database for storing information about the operations and their results.
Β
Workflow:
- The User sends a POST request to the FastAPI server with a 'githubURL' and a 'prompt'.
- The FastAPI server validates the request and passes the 'githubURL' to the GitHub Interaction Module.
- The GitHub Interaction Module fetches the code from the GitHub repository.
- The FastAPI server sends the fetched code and 'prompt' to the ChatGPT Interaction Module.
- ChatGPT Interaction Module requests a code suggestion from the ChatGPT API based on the prompt.
- Once the suggestion is received, it is sent to the Reflection Module for further processing (if needed).
- The Reflection Module sends the refined code back to the FastAPI server.
- The Diff Generator compares the original code with the suggested code to calculate the diff.
- The results, including the original code, the suggestion, and the diff, are stored in the Supabase DB.
- The FastAPI server sends the response back to the User with the calculated diff and any other relevant information.
Β
Endpoints:
POST
: /run - Accepts 'githubURL' and 'prompt' via body, initiates the workflow, and returns the results via a unified diff.
Β
Data Storage:
- Stores in a
requests
table: - id: Unique request identifier
int8
. - repo_url:
text
- prompt:
text
- original_code:
text
- fixed_code:
text
- diff: Returned unified diff of changes
text
- timestamp: Time/date object of request
timestamp
Β