Skip to content

Commit

Permalink
Deployment completed
Browse files Browse the repository at this point in the history
  • Loading branch information
Tangeyo committed Aug 12, 2024
1 parent 623a169 commit c482135
Show file tree
Hide file tree
Showing 33 changed files with 1,313 additions and 114 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 2 additions & 3 deletions fly.toml → frontend/fly.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# fly.toml app configuration file generated for syntaxsorcerer on 2024-08-11T14:46:24-07:00
# fly.toml app configuration file generated for please-work-frozen-moon on 2024-08-12T00:00:01-07:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'syntaxsorcerer'
app = 'please-work-frozen-moon'
primary_region = 'sjc'
kill_signal = 'SIGINT'
kill_timeout = '5s'
Expand All @@ -15,7 +15,6 @@ kill_timeout = '5s'

[http_service]
internal_port = 3000
force_https = false
auto_stop_machines = 'stop'
auto_start_machines = true
min_machines_running = 0
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
83 changes: 83 additions & 0 deletions frontend/src/interface.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// Download a codebase
export async function downloadCodebase() {
const ec2 = "http://18.226.98.245:80";
const local = "http://localhost:3000";
const apiURL = "https://syntaxsorcerer-backend.fly.dev";
const url = document.getElementById("codebase-url").value;
if (url.trim() === "") return;

const response = await fetch(`${apiURL}/api/download`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ url }),
});

const result = await response.json();
if (result.error) {
alert(result.error);
} else {
alert("Codebase downloaded and cached");
}
}

// Send a message to the ChatGPT API
export async function sendMessage() {
const userInput = document.getElementById("user-input").value;
if (userInput.trim() === "") return;

appendMessage("You", userInput);
document.getElementById("user-input").value = "";

const sendButton = document.getElementById("send-button");
sendButton.disabled = true;

await fetchChatGPTResponse(userInput);

sendButton.disabled = false;
}

// Display a message on the frontend
export function appendMessage(sender, message) {
const messagesDiv = document.getElementById("messages");
const messageElement = document.createElement("div");
messageElement.classList.add("message");

const senderElement = document.createElement("div");
senderElement.classList.add("sender");
senderElement.textContent = sender.toUpperCase();

const contentElement = document.createElement("div");
contentElement.classList.add("content");
contentElement.textContent = message;

messageElement.appendChild(senderElement);
messageElement.appendChild(contentElement);
messagesDiv.appendChild(messageElement);

messagesDiv.scrollTop = messagesDiv.scrollHeight;
}

// Fetch a response from the ChatGPT API
export async function fetchChatGPTResponse(userInput) {
const ec2 = "https://18.226.98.245:443";
const local = "http://localhost:3000";
const apiURL = "https://syntaxsorcerer-backend.fly.dev";
const codebasePath = "../../codebases/main";

const response = await fetch(`${apiURL}/api/chatgpt`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ prompt: userInput, codebasePath }),
});

const botMessage = await response.json();
if (botMessage.error) {
appendMessage("Error", botMessage.error);
} else {
appendMessage("Assistant", botMessage.text);
}
}
File renamed without changes.
File renamed without changes.
Binary file removed public/favicon.ico
Binary file not shown.
Binary file removed public/logo.png
Binary file not shown.
Binary file removed public/logo192.png
Binary file not shown.
Binary file removed public/logo512.png
Binary file not shown.
25 changes: 0 additions & 25 deletions public/manifest.json

This file was deleted.

3 changes: 0 additions & 3 deletions public/robots.txt

This file was deleted.

3 changes: 3 additions & 0 deletions server/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# flyctl launch added from .gitignore
**/node_modules
fly.toml
2 changes: 2 additions & 0 deletions server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.env
15 changes: 15 additions & 0 deletions server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node

RUN mkdir -p /usr/src/app

WORKDIR /usr/src/app

COPY package.json /usr/src/app/

RUN npm install

COPY . /usr/src/app

EXPOSE 3000

CMD [ "npm", "start" ]
15 changes: 15 additions & 0 deletions server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Basic express server

Base code from https://github.com/hayk-simonyan/basic-express-api!

Dockerized express server for testing deployments

## To run locally

$ docker build -t basic-express-api .
$ docker run -p 3000:3000 basic-express-api

## Without docker

$ npm i
$ npm start
22 changes: 22 additions & 0 deletions server/fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# fly.toml app configuration file generated for syntaxsorcerer-backend on 2024-08-12T00:47:50-07:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'syntaxsorcerer-backend'
primary_region = 'sjc'

[build]

[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = 'stop'
auto_start_machines = true
min_machines_running = 0
processes = ['app']

[[vm]]
memory = '1gb'
cpu_kind = 'shared'
cpus = 1
Loading

0 comments on commit c482135

Please sign in to comment.