This commit is contained in:
amirhouieh 2023-04-13 16:52:58 +02:00
commit 1af3136e58
11 changed files with 15759 additions and 0 deletions

122
.gitignore vendored Normal file
View File

@ -0,0 +1,122 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
# Next.js build output
.next
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
.DS_Store
# Yarn
**/.yarn/*
!**/.yarn/releases
!**/.yarn/plugins
!**/.yarn/sdks
!**/.yarn/versions
**/.pnp.*
.yarnrc.yml
yarn.lock
.yarn
# Project
.idea/
.vscode/
tools/dev

38
README.md Normal file
View File

@ -0,0 +1,38 @@
# README.md
# Logos Wiki Framework MVP - Development Proposal
This repository contains the development proposal for the Logos Wiki Framework MVP, a comprehensive and collaborative knowledge platform that put value not only to content but also the context, and easy to maintain.
## Key Features:
- Collaborative content creation using a frontend editor and GitHub
- Automatic context augmentation with visual citation and context enrichment
- Semantic search and generative Q&A features
- Real-time knowledge graph visualization
## Technical Details
### Technical Architecture and Tech Stack:
- Frontend: React, Editor.js
- Backend: NestJS (we use express for the POC)
- Content Storage & Database: GitHub and Weaviate
- User Management: Supabase with GitHub Auth
### Installation
1. Clone the repository locally.
2. `cd` into the cloned directory.
3. Run `yarn install` to install all dependencies.
4. Run `yarn start:dev` to start the development server.
### Contribution Guidelines and Best Practices
- Adhere to a standardized content structure and formatting guidelines
- Prioritize accuracy and relevance when contributing content
- Engage in active collaboration with other contributors and team members
## License
This project is licensed under the MIT License - see the [LICENSE.md](https://www.notion.so/LICENSE.md) file for details.

15296
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

39
package.json Normal file
View File

@ -0,0 +1,39 @@
{
"name": "create-nodejs-ts",
"version": "3.0.2",
"description": "NodeJS Starter Project Kit",
"type": "module",
"main": "dist/main.js",
"types": "dist/main.d.ts",
"private": false,
"bin": {
"create-nodejs-ts": "cmd/create-nodejs-ts/index.js"
},
"scripts": {
"start": "node dist/main.js",
"start:dev": "nodemon --ext js,ts,json,env --exec 'node --experimental-specifier-resolution=node --loader ts-node/esm' src/main.ts",
"build": "tsc --project tsconfig.build.json",
"build:clean": "rm -rf tsconfig.build.tsbuildinfo && rm -rf ./dist"
},
"license": "MIT",
"dependencies": {
"cors": "^2.8.5",
"dotenv": "^16.0.0",
"express": "^4.18.2",
"fs-extra": "^11.1.0",
"graphql": "^16.6.0",
"tslib": "^2.3.1",
"uuidv4": "^6.2.13",
"weaviate-ts-client": "^1.0.0"
},
"devDependencies": {
"@types/cors": "^2.8.13",
"@types/express": "^4.17.17",
"@types/fs-extra": "^11.0.1",
"@types/node": "^18.0.0",
"cross-env": "^7.0.3",
"nodemon": "^2.0.15",
"ts-node": "^10.7.0",
"typescript": "^4.6.3"
}
}

29
src/main.ts Normal file
View File

@ -0,0 +1,29 @@
import 'dotenv/config'
import express, {Request, Response} from 'express'
import cors from 'cors'
import { Weaviate } from './weaviate/client'
const port = 4000;
const app = express()
const weaviate = new Weaviate();
app.use(cors());
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.get('/api', (req: Request, res: Response) => {
res.send('Hello World!')
})
app.listen(port, () => {
console.log(`🚀 App listening on the port ${port}`);
});
(async() => {
try{
await weaviate.init();
}
catch (e){
console.log(e);
}
})();

View File

@ -0,0 +1,37 @@
import { WeaviateClass } from "weaviate-ts-client";
import { ParagraphClassProperties } from "./paragraph.class";
export type ArticleClassProperties = {
title: string;
content: string;
hasParagraphs: ParagraphClassProperties[]
}
export const ArticleClass: WeaviateClass = {
class: 'Article',
description: 'A wikipedia article with a title and crefs',
vectorizer: 'none',
vectorIndexConfig: {
skip: true,
},
properties: [
{
dataType: ['string'],
description: 'Title of the article',
name: 'title',
indexInverted: true,
},
{
dataType: ['Paragraph'],
description: 'List of paragraphs this article has',
name: 'hasParagraphs',
indexInverted: true,
},
{
dataType: ['Article'],
description: 'Articles this page links to',
name: 'linksToArticles',
indexInverted: true,
},
],
};

70
src/weaviate/client.ts Normal file
View File

@ -0,0 +1,70 @@
import {schemaClasses} from "./config";
import weaviate, {WeaviateClass, WeaviateClient} from "weaviate-ts-client";
import {ArticleClassProperties} from "./article.class";
import {ParagraphClassProperties} from "./paragraph.class";
import { uuid } from 'uuidv4';
export class Weaviate {
private client: WeaviateClient;
constructor() {
this.client = weaviate.client({
scheme: 'https',
host: process.env.WEAVIATE_HOST || 'localhost',
});
}
async init(){
await this.flushClasses()
for await (const classObj of schemaClasses) {
await this.createClass(classObj)
}
}
private listSchemaClasses() {
return this.client
.schema
.getter()
.do()
}
private async flushClasses() {
const {classes} = await this.listSchemaClasses();
for await (const classObj of classes as WeaviateClass[]) {
await this.client.schema.classDeleter().withClassName(classObj.class as string).do()
}
}
private async createClass(classObj: WeaviateClass) {
return this.client
.schema
.classCreator()
.withClass(classObj)
.do()
}
public addArticle(title: string, rawContent: string) {
const articleId = uuid();
const paragraphs: ParagraphClassProperties[] = rawContent
.split('\n').map((content, index) => ({
content,
order: index,
title: 'title',
inArticle: [{
beacon: `weaviate://localhost/Article/${articleId}`
}]
}))
const articleData: ArticleClassProperties = {
title: 'title',
content: 'content',
hasParagraphs: paragraphs
}
return this.client.data.creator()
.withClassName('Article')
.withProperties(articleData)
.do()
}
}

7
src/weaviate/config.ts Normal file
View File

@ -0,0 +1,7 @@
import { ArticleClass } from "./article.class";
import { ParagraphClass } from "./paragraph.class";
export const schemaClasses = [
ParagraphClass,
ArticleClass
]

View File

@ -0,0 +1,68 @@
export type ParagraphClassProperties = {
content: string;
order: number;
title: string;
inArticle: [{
beacon: string;
}]
}
export const ParagraphClass = {
class: 'Paragraph',
description: 'A wiki paragraph',
vectorIndexConfig: {
vectorCacheMaxObjects: 150000000000,
ef: 256,
efConstruction: 512,
maxConnections: 128,
},
properties: [
{
dataType: ['string'],
description: 'Title of the paragraph',
name: 'title',
indexInverted: true,
moduleConfig: {
'text2vec-transformers': {
skip: true,
vectorizePropertyName: false,
},
},
},
{
dataType: ['text'],
description: 'The content of the paragraph',
name: 'content',
indexInverted: true,
moduleConfig: {
'text2vec-transformers': {
skip: false,
vectorizePropertyName: false,
},
},
},
{
dataType: ['int'],
description: 'Order of the paragraph',
name: 'order',
indexInverted: true,
moduleConfig: {
'text2vec-transformers': {
skip: true,
vectorizePropertyName: false,
},
},
},
{
dataType: ['Article'],
description: 'Article this paragraph is in',
name: 'inArticle',
moduleConfig: {
'text2vec-transformers': {
skip: true,
vectorizePropertyName: false,
},
},
},
],
}

12
tsconfig.build.json Normal file
View File

@ -0,0 +1,12 @@
{
"extends": "./tsconfig.json",
"exclude": [
"dist",
"node_modules",
"__test",
"**/*.spec.ts",
"**/*.spec.js",
"*.spec.ts",
"**/spec.ts"
]
}

41
tsconfig.json Normal file
View File

@ -0,0 +1,41 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Node",
"types": ["node"],
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"importHelpers": true,
"resolveJsonModule": true,
"sourceMap": true,
"declaration": true,
"alwaysStrict": true,
"forceConsistentCasingInFileNames": true,
"removeComments": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"noImplicitThis": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noImplicitReturns": true,
"strict": true,
"noFallthroughCasesInSwitch": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"composite": true,
"skipLibCheck": true,
"noEmitHelpers": false,
"outDir": "dist",
"rootDir": "src",
"baseUrl": "."
},
"exclude": [
"dist",
"node_modules"
],
"include": ["src"]
}