Coder Social home page Coder Social logo

ground-truth's Introduction

Python-React Full Stack AI Application

This is a full stack application with a frontend built in React and a backend in Python Flask.

Project Structure

The project is divided into two main parts:

  • frontend: This directory contains the React app.
  • backend: This directory contains the Flask app that uses Langchain to query OpenAI.

Development

Backend

To set up and start the backend server, follow these steps:

  1. Navigate to the backend directory.

    cd backend
  2. Create a Python virtual environment and activate it.

    python3 -m venv venv
    source venv/bin/activate
  3. Install the required Python packages.

    pip install -r requirements.txt
  4. Start the Flask app. It will run on port 5001.

    export FLASK_APP=app.py
    export FLASK_ENV=development
    flask run --port=5001

Frontend

To start the frontend React app, follow these steps:

  1. Navigate to the frontend directory.

    cd frontend
  2. Install the required packages.

    npm install
  3. Start the React app. Note: it proxies requests to backend server at port 5001.

    npm run start

Production

To prepare the application for production, follow these steps:

  1. Navigate to the frontend directory and build the React app.

    cd frontend
    npm run build
  2. This creates a build directory inside the frontend directory with a production build of your React app. Now, start the Flask app in production mode:

    cd ../backend
    export FLASK_APP=app.py
    flask run --port=5001

Docker Deployment

To deploy the application using Docker, use the Dockerfile in the project root. This will create a Docker image with the Flask backend serving the React frontend. The application inside the Docker container will be available on port 5001.

  1. Build the Docker image.
docker build -t python-react-app .
  1. Run the Docker container.
docker run -p 5001:5001 -e OPENAI_API_KEY="" -e PINECONE_ENVIRONMENT="" -e PINECONE_API_KEY="" python-react-app

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.