-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(backend): common file struct and backend, frontend code generate…
… prompt (#67) Co-authored-by: Jackson Chen <[email protected]> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
0d8900a
commit 0bd0d4b
Showing
7 changed files
with
3,192 additions
and
0 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
backend/src/build-system/node/backend-code-generate/prompt.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
export const generateBackendCodePrompt = ( | ||
projectName: string, | ||
sitemapDoc: string, | ||
DatamapDoc: string, | ||
currentFile: string, | ||
dependencyFile: string, | ||
): string => { | ||
return `You are an expert backend developer. Your task is to generate a complete backend codebase within a single file for a project named "AwesomeApp". The code should be written using the Express framework and should include all necessary functionalities to cover essential backend operations while ensuring scalability and maintainability. | ||
### Based on the following input: | ||
- **Project Name:** ${projectName} | ||
- **Sitemap Documentation:** ${sitemapDoc} | ||
- **Data Analysis Document:** ${DatamapDoc} | ||
### Instructions and Rules: | ||
**Include:** | ||
1. **Server Setup:** | ||
- Initialize the server using the Express framework. | ||
- Configure middleware for JSON parsing and CORS. | ||
2. **Route Definitions:** | ||
- Define RESTful API endpoints based on the sitemap documentation. | ||
- Implement at least two example routes (e.g., GET /api/users, POST /api/users). | ||
3. Include all controllers, model, and service in one file. | ||
4. **Error Handling:** | ||
- Implement basic error handling middleware. | ||
- Ensure that meaningful error messages are returned for invalid requests. | ||
5. **Comments and Documentation:** | ||
- Add comments explaining the purpose of each section and major code blocks. | ||
- Ensure the code is readable and follows best practices. | ||
**Do Not Include:** | ||
- Database connections or ORM integrations. | ||
- External service integrations. | ||
- Complex business logic beyond basic CRUD operations. | ||
**File Naming and Structure:** | ||
- Since all code is to be included in a single file, organize the code with clear sections using comments. | ||
- Follow consistent coding conventions and formatting as per the Express standards. | ||
### Ask Yourself: | ||
1. Are you covering all the necessary routes based on the sitemap documentation? If not, add the missing routes. | ||
2. Are the controller functions adequately handling the requests and responses? If not, enhance them. | ||
3. Is the error handling comprehensive enough for basic testing? If not, improve it. | ||
4. Are the comments clear and descriptive to aid understanding and maintenance? | ||
### Output Format: | ||
Provide the backend code within markdown code blocks as follows: | ||
\`\`\`javascript | ||
\`\`\` | ||
`; | ||
}; |
48 changes: 48 additions & 0 deletions
48
backend/src/build-system/node/frontend-code-generate/prompt.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
export const generateFrontEndCodePrompt = ( | ||
sitemapDoc: string, | ||
uxDatamapDoc: string, | ||
currentFile: string, | ||
dependencyFile: string, | ||
): string => { | ||
return `You are an expert frontend developer. | ||
Your task is to generate complete and production-ready React or Next.js frontend code based on the provided inputs. | ||
The code should include all necessary files, folders, and logic to cover UI components, API integration, routing, and state management while ensuring scalability and maintainability. | ||
Based on following inputs: | ||
- Sitemap Documentation: ${sitemapDoc} | ||
- UX Datamap Documentation: ${uxDatamapDoc} | ||
- Current File Context: ${currentFile} | ||
- Dependency File: ${dependencyFile} | ||
### Instructions and Rules: | ||
File Requirements: | ||
The generated file must fully implement the requirements defined in the sitemap and UX datamap documents. | ||
Include all necessary imports, state management, and interactions to ensure functionality (no placeholders import). | ||
If applicable, integrate hooks, APIs, or context from the provided dependencies. | ||
Code Standards: | ||
Use functional components and React hooks. | ||
Adhere to any styling guidelines defined in the dependency file (e.g., Tailwind CSS or CSS Modules). | ||
Use descriptive and meaningful names for variables, functions, and components. | ||
Ensure accessibility best practices, including aria attributes. | ||
Comments: | ||
Add comments describing the purpose of each major code block or function. | ||
Include placeholders for any additional features or data-fetching logic that may need integration later. | ||
Error Handling: | ||
Handle potential edge cases, such as loading, error states, and empty data. | ||
Output Completeness: | ||
The generated file must be functional and complete, ready to be added directly to the project. | ||
This final result must be 100% complete. Will be directly use in the production | ||
`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.