/ai-rag

express.js, next.js,python flask, react.js, lerna+yarn

Primary LanguageJupyter Notebook

Monorepo Project

This project is a monorepo setup using Yarn workspaces. It includes:

  • A React.js frontend
  • A Python backend for AI and dataset pipeline
  • A JavaScript backend using Express.js or Next.js
  • Integration with Langchain for AI chat and RAG features to analyze and chat with PDF files

Getting Started

Prerequisites

Ensure you have the following installed:

  • Node.js and npm
  • Yarn
  • Python

Initial Setup

  1. Initialize the Monorepo

    Create a new directory and initialize it with a package.json file:

    mkdir ai-project
    cd ai-project
    npm init -y
  2. Set Up Yarn Workspaces

Add the following configuration to your package.json file:

{
  "private": true,
  "workspaces": [
    "packages/*"
  ],
  "scripts": {
    "start:frontend": "yarn workspace frontend start",
    "start:backend-python": "yarn workspace backend-python start",
    "start:backend-js": "yarn workspace backend-js start",
    "start": "concurrently \"yarn start:frontend\" \"yarn start:backend-python\" \"yarn start:backend-js\""
  }
}
  1. Add Packages

Create directories for each part of your project:

mkdir -p packages/frontend
mkdir -p packages/backend-python
mkdir -p packages/backend-js
  1. Set Up the Frontend

Navigate to the frontend package and set up a React.js project:

cd packages/frontend
npx create-react-app .
  1. Set Up the Backend (Python)

Navigate to the backend-python package and set up a Python project:

cd ../backend-python
python -m venv venv
source venv/bin/activate
pip install fastapi uvicorn langchain
# or: pip install -r requirements.txt
  1. Set Up the Backend (JavaScript)

Navigate to the backend-js package and set up an Express.js or Next.js project:

cd ../backend-js
npm init -y
npm install express
  1. Set up Next-js
$ cd packages
$ npx create-next-app@latest next-js
  1. Configure Yarn Workspaces

Ensure all dependencies are linked correctly. Add the following to your root package.json:

{
  "private": true,
  "workspaces": [
    "packages/*"
  ]
}
  1. Install Dependencies

Run Yarn to install all dependencies and link the packages:

yarn install
  1. Run the Project

Use the scripts defined in the root package.json to start your project:

yarn start

This setup should give you a working monorepo project with a React.js frontend, Python backend for AI and data processing, and a JavaScript backend using Express.js or Next.js. Integrate Langchain for AI chat and RAG features for PDF analysis as needed.

Summary

By following these steps and configurations, you’ll have a robust and maintainable monorepo setup that integrates JavaScript and Python projects efficiently. This approach ensures a consistent development environment and simplifies the management of multiple services within a single repository.

ai-rag