Skip to content

refactor: rewrite and cleanups #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file added .assets/how_it_works.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 15 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
node_modules
.cache
dist
build
build
.env*
!.env.example

*/generated/*
!*/generated/export_ignore.txt

*/library/lucide
*/library/shadcn

_ui
lucide_with_embeddings_dump.json

ui/src/components/openv0_generated
ui/src/components/generated_components_dump.json
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ignore-workspace-root-check=true
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
5 changes: 3 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

Copyright (c) [year] [fullname]
Copyright (c) raidendotai <[email protected]>
Copyright (c) Pooya Parsa <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +19,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
37 changes: 20 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,38 @@ It allows you to AI generate and iterate on React+Tailwind components, with live

The open-source project is inspired by vercel's [v0.dev](https://v0.dev/), which, at the time of writing, is still on private waitlisted alpha


Say hi [@n_raidenai](https://twitter.com/n_raidenai) 👋

Client is based on [React + Vite + TypeScript + shadcn/ui Template (react-vite-ui)](https://github.com/Dan5py/react-vite-ui/)

# Demo
## Demo

[openv0_demo.webm](https://github.com/raidendotai/openv0/assets/127366981/53b14c27-22ec-40a3-a431-539daf197f49)

# Install
## How It Works

* Open your terminal and run
Here is a simple explanation

```sh
npx openv0
```
![openv0_process](./.assets/how_it_works.png)

## Local Development

It will download openv0 and install dependencies *(alternatively, you can also clone this repo and install manually)*
Enable corepack:

* Replace your OpenAI API key in `openv0_server/.env`
* Start the local server + webapp
* start server `cd openv0_server && node index.js`
* start webapp `cd openv0_vitereact && npm run dev`
* Open you web browser, go to `http://localhost:5173/`
```sh
corepack enable
```

That is all. Have fun 🎉
Install dependencies:

# How It Works
```sh
pnpm install
```

Here is a simple explanation
Start server

![openv0_process](https://github.com/raidendotai/openv0/assets/127366981/dad08255-f54a-4437-bf87-9560f69940a7)
```sh
pnpm start
```

Go to http://localhost:3000/
39 changes: 39 additions & 0 deletions check_env.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import consola from "consola";
import { colors } from "consola/utils";
import { fileURLToPath } from "node:url";
import { update } from "rc9";

import "dotenv/config";

if (!process.env.OPENAI_API_KEY) {
consola.info("`OPENAI_API_KEY` is not set!");

const key = await consola.prompt(
`Enter your OpenAI API key: (you can fetch one from ${colors.cyan(
"https://platform.openai.com/account/api-keys",
)}`,
{
type: "text",
},
);

if (!key) {
consola.error("No key provided, exiting...");
process.exit(1);
}

const dotEnvPath = fileURLToPath(new URL("./.env", import.meta.url));
consola.info(`Writing key to \`${dotEnvPath}\``);
await update(
{
OPENAI_API_KEY: key,
OPENAI_MODEL: "gpt-4",
CONTEXT_TOKENS_PER_LIBRARY_COMPONENT_LIMIT: 950,
REACT_WEBAPP_DIR: "../ui",
REACT_WEBAP_COMPONENT_PING_INTERVAL_MS: 5000,
},
{
name: dotEnvPath,
},
);
}
7 changes: 0 additions & 7 deletions openv0_server/.env

This file was deleted.

1 change: 0 additions & 1 deletion openv0_server/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion openv0_server/README.md

This file was deleted.

8 changes: 0 additions & 8 deletions openv0_server/export_refresh.js

This file was deleted.

125 changes: 0 additions & 125 deletions openv0_server/generate.js

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading