Skip to content

Commit

Permalink
Merge branch 'main' into feat-adding-embedding-config
Browse files Browse the repository at this point in the history
  • Loading branch information
ZHallen122 authored Jan 6, 2025
2 parents b9c1909 + 77f911e commit 50d3bd1
Show file tree
Hide file tree
Showing 38 changed files with 958 additions and 3,165 deletions.
3 changes: 2 additions & 1 deletion backend/.prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"singleQuote": true,
"trailingComma": "all"
"trailingComma": "all",
"endOfLine": "auto"
}
1 change: 1 addition & 0 deletions backend/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ module.exports = {
},
modulePaths: ['<rootDir>'],
moduleDirectories: ['node_modules', 'src'],
testPathIgnorePatterns: ['/template'],
};
35 changes: 34 additions & 1 deletion backend/src/build-system/__tests__/test.fullstack-gen.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ describe('Sequence: PRD -> UXSD -> UXSS -> UXDD -> DATABASE_REQ -> DBSchemas ->
description: 'Users can play music',
databaseType: 'SQLite',
steps: [
{
id: 'step-0',
name: 'Project Initialization',
parallel: false,
nodes: [
{
id: 'op:PROJECT::STATE:SETUP',
name: 'set up project folders',
},
],
},
{
id: 'step-1',
name: 'Initial Analysis',
Expand Down Expand Up @@ -96,6 +107,11 @@ describe('Sequence: PRD -> UXSD -> UXSS -> UXDD -> DATABASE_REQ -> DBSchemas ->
name: 'File_Arch',
requires: ['op:FILE:STRUCT', 'op:UX:DATAMAP:DOC'],
},
{
id: 'op:BACKEND:REQ',
name: 'Backend Requirements Node',
requires: ['op:DATABASE_REQ', 'op:UX:DATAMAP:DOC', 'op:UX:SMD'],
},
],
},
{
Expand All @@ -106,7 +122,24 @@ describe('Sequence: PRD -> UXSD -> UXSS -> UXDD -> DATABASE_REQ -> DBSchemas ->
{
id: 'op:BACKEND:CODE',
name: 'Backend Code Generator Node',
requires: ['op:DATABASE:SCHEMAS', 'op:UX:DATAMAP:DOC'],
requires: [
'op:DATABASE:SCHEMAS',
'op:UX:DATAMAP:DOC',
'op:BACKEND:REQ',
],
},
],
},
// TODO: code reviewer
{
id: 'step-7',
name: 'Backend Code Review',
parallel: false,
nodes: [
{
id: 'op:BACKEND:FILE:REVIEW',
name: 'Backend File Review Node',
requires: ['op:BACKEND:CODE', 'op:BACKEND:REQ'],
},
],
},
Expand Down
9 changes: 7 additions & 2 deletions backend/src/build-system/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ export type GlobalDataKeys =
| 'description'
| 'platform'
| 'databaseType'
| 'projectUUID';
| 'projectUUID'
| 'backendPath'
| 'frontendPath';

/**
* Generic context data type mapping keys to any value
Expand Down Expand Up @@ -72,7 +74,10 @@ export class BuilderContext {
this.globalContext.set('description', sequence.description || '');
this.globalContext.set('platform', 'web');
this.globalContext.set('databaseType', sequence.databaseType || 'SQLite');
this.globalContext.set('projectUUID', uuidv4());
this.globalContext.set(
'projectUUID',
new Date().toISOString().slice(0, 10).replace(/:/g, '-') + '-' + uuidv4(),
);
}

async execute(): Promise<void> {
Expand Down
16 changes: 15 additions & 1 deletion backend/src/build-system/handlers/backend/code-generate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
parseGenerateTag,
removeCodeBlockFences,
} from 'src/build-system/utils/database-utils';
import { saveGeneratedCode } from 'src/build-system/utils/files';
import * as path from 'path';

/**
* BackendCodeHandler is responsible for generating the backend codebase
Expand Down Expand Up @@ -33,17 +35,25 @@ export class BackendCodeHandler implements BuildHandler<string> {
// Destructure arguments with default values for optional parameters
const sitemapDoc = context.getNodeData('op:UX:SMD');
const datamapDoc = context.getNodeData('op:UX:DATAMAP:DOC');
const databaseSchemas = context.getNodeData('op:DATABASE:SCHEMAS');
//TODO: make this backend generate similar as FileGenerateHandler, do file arch, and then generate each backend code
const currentFile = 'backend.js';
//TODO: backend requirement
const backendRequirementDoc =
context.getNodeData('op:BACKEND:REQ').overview;

const currentFile = 'index.js';
const dependencyFile = 'dependencies.json';

// Generate the prompt using the provided documents and project name
const backendCodePrompt = generateBackendCodePrompt(
projectName,
sitemapDoc,
datamapDoc,
backendRequirementDoc,
databaseType,
databaseSchemas,
currentFile,
'javascript',
dependencyFile,
);

Expand All @@ -63,8 +73,12 @@ export class BackendCodeHandler implements BuildHandler<string> {
parseGenerateTag(modelResponse),
);

const uuid = context.getGlobalContext('projectUUID');
saveGeneratedCode(path.join(uuid, 'backend', currentFile), generatedCode);

this.logger.debug('Backend code generated and parsed successfully.');

// TODO: return backend api as output
return {
success: true,
data: generatedCode,
Expand Down
Loading

0 comments on commit 50d3bd1

Please sign in to comment.