Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hupe1980 committed Jul 20, 2023
1 parent 788cb53 commit e536db3
Show file tree
Hide file tree
Showing 30 changed files with 1,894 additions and 2 deletions.
57 changes: 57 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
linters-settings:
errcheck:
check-type-assertions: true
goconst:
min-len: 2
min-occurrences: 3
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
govet:
check-shadowing: true
nolintlint:
require-explanation: true
require-specific: true

linters:
disable-all: true
enable:
- bodyclose
#- depguard
- dogsled
#- dupl
- errcheck
- exportloopref
- exhaustive
#- goconst TODO
- gofmt
- goimports
#- gomnd
- gocyclo
- gosec
- gosimple
- govet
- ineffassign
- misspell
#- nolintlint
- nakedret
- prealloc
- predeclared
#- revive #TODO
- staticcheck
- stylecheck
- thelper
- tparallel
- typecheck
- unconvert
- unparam
- unused
- whitespace
- wsl

run:
issues-exit-code: 1
34 changes: 34 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
PROJECTNAME=$(shell basename "$(PWD)")

# Go related variables.
# Make is verbose in Linux. Make it silent.
MAKEFLAGS += --silent

.PHONY: setup
## setup: Setup installes dependencies
setup:
@go mod tidy

.PHONY: lint
## test: Runs the linter
lint:
@golangci-lint run --color=always --sort-results ./...

.PHONY: run
## run: Runs awsrecon
run:
@go run -race main.go -h

.PHONY: test
## test: Runs go test with default values
test:
@go test -v -race -count=1 -coverprofile=coverage.out ./...

.PHONY: help
## help: Prints this help message
help: Makefile
@echo
@echo " Choose a command run in "$(PROJECTNAME)":"
@echo
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
@echo
106 changes: 104 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,104 @@
# go-genie
👻 go-genie
# 👻 genie
![Build Status](https://github.com/hupe1980/genie/workflows/build/badge.svg)
[![Go Reference](https://pkg.go.dev/badge/github.com/hupe1980/genie.svg)](https://pkg.go.dev/github.com/hupe1980/genie)
> Genie is a Proof of Concept (POC) source code generator that showcases the potential of utilizing Large Language Models (LLMs) for code generation. As a limited prototype, Genie provides a glimpse into the capabilities of LLM-based code generation tools. It allows users to experiment with generating source code based on simplified prompts or descriptions.
Genie is based on https://github.com/smol-ai/developer.

## How to use
```text
Usage:
genie [flags]
Examples:
genie -p "Create a python hello world"
genie -p prompt.txt
Flags:
--api-key string openAI api key
-h, --help help for genie
-m, --model string model to use (default "gpt-3.5-turbo")
-o, --outdir string outdir to use (default "dist")
-p, --prompt string prompt to use (required)
-t, --temperature float32 temperature to use (default 0.4)
-v, --version version for genie
```
## Example
```bash
genie -p _examples/aws_cdk/prompt.md -o _examples/aws_cdk/dist
```

Outputs:
```text
██████ ███████ ███ ██ ██ ███████
██ ██ ████ ██ ██ ██
██ ███ █████ ██ ██ ██ ██ █████
██ ██ ██ ██ ██ ██ ██ ██
██████ ███████ ██ ████ ██ ███████
Create list of files:
• src/api/api.ts
• src/api/todoController.ts
• src/lambda/todoHandler.ts
• src/dynamoDB/todoTable.ts
• .env
• .gitignore
• README.md
• cdk.json
• jest.config.js
• package.json
• projenrc.json
• tsconfig.json
Reasoning:
• The app requires an API Gateway to expose the CRUD endpoints.
• The Lambda functions will handle the API requests and interact with DynamoDB, so we need to create a Lambda Backend.
• DynamoDB is needed to store the todo items.
• We'll use 'projen' to manage the AWS CDK project and its dependencies.
• To implement the CRUD operations, we'll need to create the necessary API endpoints.
Create list of shared Dependecies:
• {dataSchemas Shared data schemas for the request and response bodies [TodoItem CreateTodoRequest CreateTodoResponse GetAllTodosResponse GetTodoByIdResponse UpdateTodoRequest UpdateTodoResponse]}
• {environmentVariables Shared environment variables for configuring DynamoDB table name and settings [DYNAMODB_TABLE_NAME]}
• {errorHandlingUtilities Shared utilities for error handling [createErrorResponse]}
• {awsCdkLibraries Shared AWS CDK related libraries [aws_cdk aws_lambda aws_apigateway aws_dynamodb]}
Reasoning:
• To identify the shared dependencies between the generated files, we need to analyze the content of each file and look for common symbols or entities used across multiple files.
• Starting with the API endpoints, there might be shared data schemas for the request and response bodies.
• The todoController.ts file is responsible for handling the API requests and might have dependencies on the data schemas.
• The todoHandler.ts file implements the Lambda functions for CRUD operations and might have dependencies on the data schemas as well.
• The todoTable.ts file creates the DynamoDB table and might have dependencies on the data schemas, as it needs to define the primary key.
• Other shared dependencies could include environment variables, error handling utilities, and AWS CDK related libraries.
• We'll analyze the content of each file and identify the shared symbols to create the shared_dependencies list.
File src/lambda/todoHandler.ts created
File src/dynamoDB/todoTable.ts created
File .env created
File src/api/api.ts created
File .gitignore created
File src/api/todoController.ts created
File cdk.json created
File jest.config.js created
File package.json created
File tsconfig.json created
File projenrc.json created
File README.md created
Tokens Used: 28404
Prompt Tokens: 24452
Completion Tokens: 3952
Successful Requests: 14
Total Cost (USD): $0.00
```

## Contributing
Contributions are welcome! Feel free to open an issue or submit a pull request for any improvements or new features you would like to see.

## References
- https://github.com/smol-ai/developer
- https://github.com/hupe1980/golc

## License
This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.
1 change: 1 addition & 0 deletions _examples/aws_cdk/dist/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DYNAMODB_TABLE_NAME=myTodoTable
17 changes: 17 additions & 0 deletions _examples/aws_cdk/dist/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# .gitignore

# Node.js
node_modules
package-lock.json

# AWS CDK
.cdk.staging
.cdk.out

# CDK generated files
cdk.out
CDKOutputs.json

# IDE
.idea
.vscode
131 changes: 131 additions & 0 deletions _examples/aws_cdk/dist/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# AWS CDK Todo App Specification

## Overview

This specification outlines the requirements for an AWS CDK (Cloud Development Kit) app that implements a CRUD (Create, Read, Update, Delete) API for managing todo items. The app will consist of the following components:

1. API Gateway: Exposes HTTP endpoints to interact with the backend Lambda functions.
2. Lambda Backend: Responsible for handling API requests and interacting with the DynamoDB.
3. DynamoDB: A managed NoSQL database used to store todo items.

The project will be managed using `projen`, a project generator tool that simplifies the setup and configuration of AWS CDK projects.

## Requirements

The app should satisfy the following requirements:

1. API Gateway:
- Expose HTTP endpoints for CRUD operations on todo items.
- Use AWS Lambda as the integration for API endpoints.
- Utilize API Gateway REST API.
- Implement proper error handling and validation.

2. Lambda Backend:
- Implement Lambda functions to handle CRUD operations for todo items.
- Ensure secure access to DynamoDB tables.
- Handle proper error responses and validations.
- Use environment variables to configure the DynamoDB table name and other settings.

3. DynamoDB:
- Create a DynamoDB table to store todo items.
- The table should have a primary key to uniquely identify each todo item.

4. Projen:
- Use `projen` to manage the AWS CDK project and its dependencies.
- Configure common project settings such as TypeScript, Jest, and AWS CDK.

## API Endpoints

1. Create a Todo Item

Endpoint: `POST /todos`

Request Body:
```
{
"title": "string",
"description": "string"
}
```

Response:
- Status: 201 Created
- Body:
```
{
"id": "string",
"title": "string",
"description": "string",
"createdAt": "string",
"updatedAt": "string"
}
```

2. Get All Todo Items

Endpoint: `GET /todos`

Response:
- Status: 200 OK
- Body:
```
[
{
"id": "string",
"title": "string",
"description": "string",
"createdAt": "string",
"updatedAt": "string"
},
...
]
```

3. Get a Todo Item by ID

Endpoint: `GET /todos/{id}`

Response:
- Status: 200 OK
- Body:
```
{
"id": "string",
"title": "string",
"description": "string",
"createdAt": "string",
"updatedAt": "string"
}
```

4. Update a Todo Item

Endpoint: `PUT /todos/{id}`

Request Body:
```
{
"title": "string",
"description": "string"
}
```

Response:
- Status: 200 OK
- Body:
```
{
"id": "string",
"title": "string",
"description": "string",
"createdAt": "string",
"updatedAt": "string"
}
```

5. Delete a Todo Item

Endpoint: `DELETE /todos/{id}`

Response:
- Status: 204 No Content
21 changes: 21 additions & 0 deletions _examples/aws_cdk/dist/cdk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"app": "npx ts-node bin/todo-app.ts",
"context": {
"aws:cdk:enable-path-metadata": "true",
"aws:cdk:path-metadata-experimental": "true"
},
"output": "dist",
"context": {
"availabilityZones": "us-east-1a,us-east-1b,us-east-1c",
"aws-cdk:enable-asset-metadata": "false",
"aws-cdk:enable-role-usage-report": "true"
},
"watch": true,
"language": "typescript",
"context": {
"aws-cdk:enable-privacy-mode": "true"
},
"context": {
"aws-cdk:enable-stack-trace": "true"
}
}
8 changes: 8 additions & 0 deletions _examples/aws_cdk/dist/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
testEnvironment: "node",
transform: {
"^.+\\.tsx?$": "ts-jest",
},
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
testMatch: ["**/*.test.ts"],
};
Loading

0 comments on commit e536db3

Please sign in to comment.