Skip to content

Repository files navigation

PolyFlexLLM

A full-stack web platform for interacting with various LLMs (OpenAI, Gemini, Claude), featuring full conversation context control, and Markdown + LaTeX rendering.

Tech Stack

  • Front End: Node.js, React.js, Next.js, Tailwind CSS, MUI
  • Back End: Node.js (Nest.js), Python (FastAPI)
  • Storage: PostgreSQL, RustFS, Redis
  • Authentication: Firebase (Email Verification), Google Sign-In
  • Infrastructure: Linux (Debian 12), Kubernetes (K3S), Nginx
  • DevOps: GitHub Actions
  • Payment: Creem

Live Demo

https://www.windsnow1025.com

Setup

Prepare Environment

  1. Copy ./app-secret.example.yaml to ./app-secret.yaml and ./app-secret-test.yaml, modify value for each key.

Debian Production

  1. Create and configure a Debian VM with 4GB RAM by following https://github.com/windsnow1025/Notes/blob/main/Configuration/CloudVM.md
  2. JetBrains IDEA >> Settings >> SSH Configurations: login as root

Nginx Installation

  1. Install Nginx with Stream module
  2. In <nginx_config_path>: create ./nginx.conf and ./sites-available/default
  • Stream Block in ./nginx.conf:

    stream {
        server {
            listen 3306;
            proxy_pass localhost:33306;
        }
        server {
            listen 6379;
            proxy_pass localhost:36379;
        }
        server {
            listen 9000;
            proxy_pass localhost:39000;
        }
        server {
            listen 9001;
            proxy_pass localhost:39001;
        }
    }
    
  • HTTP Block in ./sites-available/default:

    server {
    
      server_name <domain_name>;
    
      client_max_body_size 100M;
    
        location / {
            proxy_pass http://localhost:30080/;
            
            proxy_buffering off;
            proxy_request_buffering off;
    
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Forwarded-Port $server_port;
            proxy_set_header X-Forwarded-Host $host;
    
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
    
        location /kubernetes/ {
            proxy_pass http://localhost:34466;
    
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Forwarded-Port $server_port;
            proxy_set_header X-Forwarded-Host $host;
    
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
    }
    

Config and Environment Setup

JetBrains IDEA >> Settings >> Build, Execution, Deployment >> Deployment

  1. Add SFTP
  2. Add Mapping
    • Deployment Path: /root/kubernetes, Local Path: ./kubernetes
    • Deployment Path: /etc/nginx, Local Path: <nginx_config_path>
  3. Select Deployment Paths in Remote Host: Sync with local...

Nginx Configuration

  1. Install Certbot
  2. Nginx Sync with local

K3S Installation and Configuration

Follow https://github.com/windsnow1025/Notes/blob/main/Configuration/K3S.md

Apply Custom Configs in ./KubernetesCommand.md

Google Auth

In Google Auth Platform, for App and Test

  • Branding
    • Application home page: https://<domain_name>
    • Application privacy policy link: https://<domain_name>/about/privacy
    • Application terms of service link: https://<domain_name>/about/terms
    • Authorized domains: <top_domain_name>
  • Clients

Usage

  • Main
    • http://localhost:30080/
    • https://<domain_name>/
  • Kubernetes Dashboard
    • http://localhost:34466/kubernetes/
    • https://<domain_name>/kubernetes/
  • S3 Dashboard
    • http://localhost:39001/

Development

OpenSSH

  1. Prepare Private Key
dos2unix <id_rsa_filepath>
  1. Add in OpenSSH config
Host <tunnel_name>
    HostName <domain_name>
    User root
    IdentityFile <id_rsa_filepath>
    LocalForward 5432 localhost:5432
    LocalForward 6379 localhost:6379
    LocalForward 9000 localhost:9000
    LocalForward 9001 localhost:9001
    ExitOnForwardFailure yes
    ServerAliveInterval 30
  1. Run JetBrains Tunnel configs

CI/CD

GitHub >> Repository >> Settings >> Security >> Secrets and variables >> Actions

  • Secrets >> Repository secrets: add DOCKERHUB_TOKEN
  • Variables >> Repository variables: add DOCKERHUB_USERNAME

About

A full-stack web platform for interacting with various LLMs (OpenAI, Gemini, Claude), featuring full conversation context control, and Markdown + LaTeX rendering.

Topics

Resources

Stars

7 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages