Skip to content

Commit

Permalink
feat: add drizzle orm with sqlite (#13)
Browse files Browse the repository at this point in the history
Co-authored-by: Anbraten <[email protected]>
  • Loading branch information
aaa006bd and anbraten authored Aug 7, 2023
1 parent 0e149b3 commit aa58424
Show file tree
Hide file tree
Showing 15 changed files with 1,325 additions and 848 deletions.
1 change: 1 addition & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ NUXT_PUBLIC_GITHUB_CLIENT_ID=
NUXT_GITHUB_CLIENT_SECRET=
NUXT_API_URL=
DATA_PATH=./data
DATABASE_NAME=
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ jobs:
run_install: true

- name: Check format
run: pnpm check-format
run: pnpm format:check
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ logs
.env
.env.*
!.env.example

# Sqlite database
*.db
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ pnpm-lock.yaml
dist
coverage/
.pnpm-store/
server/db
29 changes: 4 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,10 @@ Use the command `python uvicorn pyserver:app --reload --app-dir=ai` to start the

[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/geprog/codecaptain)

## ToDo

- [ ] use CodeSplitter and code-detector to get code parts
- [x] test with more questions
- [x] add UI
- [ ] add more context / data to embeddings
- [x] file structure
- [ ] summary
- [ ] language of code
- [x] include issues
- [ ] include PRs
- [ ] include issue comments
- [ ] include PR comments
- [ ] try gpt-4 and system messages
- [ ] update embeddings on commits
- [ ] show related code parts in UI
- [ ] add some proper database for user and repos
- [ ] check **ACCESS** of user to repo
- [ ] use message history when asking a question
- [ ] autocomplete while asking questions
- [ ] skip gitignored and .git files when indexing
- [ ] add limits
- [ ] max number of questions per day
- [ ] max number of repos per user
- [ ] max number of repo updates per month
## Database

We are using Drizzle ORM and sqlite as of now. The schemas need to be inside db/schemas and the migrations will be inside db/migrations. checkout `drizzle.config.ts` for the settings.
use `pnpm push-schema` to directly update the database with new table schemas. This is only intended for development only. Use other commands along with `await migrate(db, { migrationsFolder: "" });` function call in a production environment. More information [https://orm.drizzle.team/kit-docs/quick](here). User `pnpm db-exporer` to open drizzle studio which is in beta state right now.

## Appreciations

Expand Down
13 changes: 13 additions & 0 deletions drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { Config } from 'drizzle-kit';

// For config references visit https://orm.drizzle.team/kit-docs/config-reference

export default {
schema: ['./server/**/*.schema.ts'],
out: './server/db/migrations',
dbCredentials: {
url: 'code_captain.db',
},
driver: 'better-sqlite',
breakpoints: true,
} satisfies Config;
30 changes: 20 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,36 @@
"private": true,
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"start": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare",
"check-format": "prettier --check .",
"db:generate-migration": "drizzle-kit generate:sqlite",
"db:drop": "drizzle-kit drop",
"db:push": "drizzle-kit push:sqlite",
"db:explorer": "drizzle-kit studio",
"clean": "rm -rf dist/ node_modules/ .eslintcache",
"format:check": "prettier --check .",
"format:fix": "prettier --write .",
"typecheck": "tsc --noEmit"
},
"devDependencies": {
"@nuxt/devtools": "^0.7.4",
"@nuxtjs/tailwindcss": "^6.8.0",
"@types/node": "^18",
"nuxt": "^3.6.5",
"@nuxt/devtools": "latest",
"@nuxtjs/tailwindcss": "6.8.0",
"@types/node": "18",
"@types/better-sqlite3": "7.6.4",
"better-sqlite3": "8.5.0",
"drizzle-kit": "^0.19.12",
"nuxt": "3.6.1",
"prettier": "^3.0.1",
"typescript": "^5.1.6"
},
"dependencies": {
"nuxt-icon": "^0.4.1",
"octokit": "^2.1.0",
"simple-git": "^3.19.1",
"vue-markdown-render": "^2.0.1"
"better-sqlite3": "8.5.0",
"drizzle-orm": "0.27.2",
"nuxt-icon": "0.4.1",
"octokit": "2.1.0",
"simple-git": "3.19.1",
"vue-markdown-render": "2.0.1"
}
}
Loading

0 comments on commit aa58424

Please sign in to comment.