PromptBuilder is a web application designed to help users create, manage, and utilize prompt templates for various Large Language Models (LLMs). It features a .NET backend API (serving both the API and the frontend) and a React frontend, using an embedded SQLite database.
This README provides instructions for running and deploying the application both with Docker and without Docker.
Ensure you have Docker installed on your system:
- macOS: Docker Desktop for Mac
- Windows: Docker Desktop for Windows (WSL 2 backend recommended)
- Linux: Docker Engine
- Clone the repository:
git clone https://github.com/well2/PromptBuilder.git cd PromptBuilder - Build the Docker image:
docker build -t promptbuilder-app . - Run the application container:
docker run -p 8080:8080 --name promptbuilder-instance promptbuilder-app
- Use
-dfor detached mode. - For database persistence, add a volume:
-v /path/on/host:/app/promptbuilder.db
- Use
- Access:
http://localhost:8080 - Stop:
Ctrl + Cordocker stop promptbuilder-instance - Remove Container:
docker rm promptbuilder-instance(Note: Deletes internal SQLite DB unless a volume is mounted).
Build the image (docker build) and run it on the server (docker run).
- Linux Server:
- Install Docker Engine.
- Clone repo, build image.
- Run container:
docker run -d -p 8080:8080 --restart always --name promptbuilder-instance promptbuilder-app - (Recommended) Use a volume for DB persistence:
-v /path/on/host/db:/app/promptbuilder.db - (Recommended) Setup a reverse proxy (Nginx/Apache) for SSL, domain mapping, forwarding to
http://localhost:8080.
- Windows Server:
- Install Docker Desktop.
- Clone repo, build image.
- Run container:
docker run -d -p 8080:8080 --restart always --name promptbuilder-instance promptbuilder-app - (Recommended) Use a volume for DB persistence:
-v C:\path\on\host\db:/app/promptbuilder.db - (Recommended) Setup IIS as a reverse proxy.
- Database: SQLite DB (
promptbuilder.db) is created inside the container at/app. Use volume mounting for persistence. - Frontend API URL: Set to
/apiduring build, assuming API is at the same origin. - Backend Environment: Defaults to
Production. Override with-e ASPNETCORE_ENVIRONMENT=Developmentif needed.
Ensure you have the following installed:
- .NET 8 SDK: Download .NET (Includes the runtime)
- Node.js and npm: Download Node.js (LTS version recommended)
- Git: Download Git
-
Clone the repository:
git clone <repository-url> cd PromptBuilder
-
Build the Frontend:
cd frontend npm install npm run build cd ..
This creates a
distfolder insidefrontend. -
Prepare the Backend:
- Ensure the backend project (
backend/src/PromptBuilder.API/PromptBuilder.API.csproj) is configured to serve static files (this should be the case based on recent changes). - Create the
wwwrootdirectory if it doesn't exist:# On Linux/macOS mkdir -p backend/src/PromptBuilder.API/wwwroot # On Windows (Command Prompt) mkdir backend\src\PromptBuilder.API\wwwroot # On Windows (PowerShell) New-Item -ItemType Directory -Force -Path backend/src/PromptBuilder.API/wwwroot
- Copy the frontend build output to the backend's
wwwroot:# On Linux/macOS cp -a frontend/dist/. backend/src/PromptBuilder.API/wwwroot/ # On Windows (Command Prompt) xcopy frontend\dist backend\src\PromptBuilder.API\wwwroot /E /I /Y # On Windows (PowerShell) Copy-Item -Path frontend/dist/* -Destination backend/src/PromptBuilder.API/wwwroot/ -Recurse -Force
- Ensure the backend project (
-
Run the Backend:
cd backend/src/PromptBuilder.API dotnet run- The application will start, apply database migrations (creating
promptbuilder.dbin thebackend/src/PromptBuilder.APIdirectory if it doesn't exist), and listen typically onhttp://localhost:5000orhttps://localhost:5001(check the console output). The port might differ based onlaunchSettings.json.
- The application will start, apply database migrations (creating
-
Access the application: Open your browser to the URL provided in the
dotnet runoutput (e.g.,http://localhost:5000). -
Stop the application: Press
Ctrl + Cin the terminal wheredotnet runis executing.
- Prerequisites:
- Install the .NET 8 Runtime (not the full SDK unless you build on the server). Instructions
- Install a web server like Nginx or Apache.
- Publish the Application:
- On your development machine (or the server if SDK is installed), navigate to the solution directory (
cd PromptBuilder) and run:dotnet publish backend/src/PromptBuilder.API/PromptBuilder.API.csproj -c Release -o ./publish/backend
- Build the frontend (if not already done):
cd frontend npm install npm run build cd ..
- Copy the frontend build (
frontend/dist/*) into the backend publish directory'swwwroot:# Create wwwroot in publish output mkdir -p publish/backend/wwwroot # Copy frontend build cp -a frontend/dist/. publish/backend/wwwroot/
- On your development machine (or the server if SDK is installed), navigate to the solution directory (
- Copy Files to Server: Transfer the contents of the
./publish/backenddirectory to your server (e.g., to/var/www/promptbuilder). - Configure Web Server (Nginx Example):
- Create an Nginx site configuration file (e.g.,
/etc/nginx/sites-available/promptbuilder):server { listen 80; server_name your_domain.com; # Or server IP location / { proxy_pass http://localhost:5000; # Assuming Kestrel runs on 5000 proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection keep-alive; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } }
- Enable the site:
sudo ln -s /etc/nginx/sites-available/promptbuilder /etc/nginx/sites-enabled/ - Test Nginx config:
sudo nginx -t - Reload Nginx:
sudo systemctl reload nginx - (Recommended) Configure HTTPS using Let's Encrypt / Certbot.
- Create an Nginx site configuration file (e.g.,
- Run the Application as a Service (systemd Example):
- Create a service file (e.g.,
/etc/systemd/system/promptbuilder.service):[Unit] Description=PromptBuilder Web Application [Service] WorkingDirectory=/var/www/promptbuilder ExecStart=/usr/bin/dotnet /var/www/promptbuilder/PromptBuilder.API.dll Restart=always # Restart service after 10 seconds if dotnet service crashes RestartSec=10 KillSignal=SIGINT SyslogIdentifier=promptbuilder User=www-data # Or another user with appropriate permissions Environment=ASPNETCORE_ENVIRONMENT=Production Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false # Add other environment variables if needed [Install] WantedBy=multi-user.target
- Enable and start the service:
sudo systemctl enable promptbuilder.service sudo systemctl start promptbuilder.service sudo systemctl status promptbuilder.service - Ensure the
User(e.g.,www-data) has write permissions to the application directory if the SQLite DB needs to be created/written to.
- Create a service file (e.g.,
- Prerequisites:
- Install the .NET 8 Hosting Bundle. Download (Installs runtime, IIS module, etc.)
- Ensure IIS is installed with the ASP.NET Core Module v2.
- Publish the Application:
- Follow step 2 from the Linux deployment section to publish the backend and copy the frontend build into the
publish/backend/wwwrootdirectory.
- Follow step 2 from the Linux deployment section to publish the backend and copy the frontend build into the
- Copy Files to Server: Transfer the contents of
./publish/backendto a folder on the server (e.g.,C:\inetpub\wwwroot\promptbuilder). - Configure IIS:
- Open IIS Manager.
- Create a new Application Pool (e.g., "PromptBuilderPool") with ".NET CLR version" set to "No Managed Code".
- Create a new Website or Application pointing to the deployment folder (
C:\inetpub\wwwroot\promptbuilder). - Assign the created Application Pool to the site/application.
- Ensure the Application Pool identity has read/write permissions to the deployment folder (for SQLite DB creation/access).
- The
web.configfile generated during publish should configure the ASP.NET Core Module correctly.
- Set Environment Variables (Optional):
- You can set environment variables like
ASPNETCORE_ENVIRONMENT=Productionwithin the IIS Application settings or globally on the server.
- You can set environment variables like
- Start Website: Ensure the website is started in IIS Manager. Access it via the configured binding (e.g.,
http://your_server_ip).
This README provides basic instructions. Specific configurations for web servers, permissions, and environment variables might need adjustments based on your exact server setup and security requirements.