This guide provides step -by -step instructions to deploy Brazilware in a production environment.
Prerequisites
Before you start deployment, make sure the server meets the following requirements:
- Node.js (version 18.x or higher)
- NPM (version 8.x or higher)
- Access to a terminal/command line
- Git (optional, to clone the repository)
- OpenAi API Key (for AI functionality)
Implementation steps
1. Get the source code
There are two ways to get the source code:
Option 1: Git repository cloning
git clone https://github.com/azurejoga/brasilware.git
cd brasilware
Option 2: Upload directly from files
If you already have the project files, upload to the server and navigate to the project directory.
2. Install dependencies
Run the following command to install all necessary dependencies:
npm install
4. Build the Project
Run the build command to generate optimized production files:
npm run build
5. Start the server
for start the server in production mode, execute:
npm run start
To keep the server running permanently, we recommend using a tool like PM2:
# Install PM2 globally
npm install -g pm2
# Start the application with PM2
pm2 start npm --name "brasilware" -- start
# Configure PM2 to start automatically after restarting the server
pm2 startup
pm2 save
6. Configure a reverse proxy (optional, but recommended)
For better performance and safety, we recommend setting up an NGINX server as Reverse Proxy:
NGINX Installation:
# In systems based on Debian/Ubuntu
sudo apt update
sudo apt install nginx
# In RHEL/centos -based systems
sudo yum install nginx
NGINX configuration:
Create a configuration file for your site:
sudo nano /etc/nginx/sites-available/brasilware
Add the following content:
server {
listen 80;
server_name yor-domain.com www.yor-domain.com;
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Activate the configuration and restart NGINX:
sudo ln -s /etc/nginx/sites-available/brasilware /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
7. Configure https with let's Encrypt (recommended)
For additional security, set up https using let's Encrypt:
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d yor-domain.com -d www.yor-domain.com
Follow the instructions to generate and configure certificates automatically.
Important Directories Structure
client/
: Code of Frontend Sourceserver/
: Backend source codeshared/
: Schemes and shared typesuploads/
: Directory where charged files are storeddocs/
: Project Documentation
Maintenance and Monitoring
Logs
To view application logs when managed by PM2:
pm2 logs brasilware
Update
To update the app with a new version:
# Stop the application
pm2 stop brasilware
# Pull changes if you are using git
git pull
# Or, update the files manually if necessary
# Install dependencies and reconstruct
npm install
npm run build
# Restart the application
pm2 restart brasilware
Backup
It is important to make regular backup of the following directories:
data/
: Contains local storage datauploads/
: Contains all PDFs and charged modules
Backup Command Example:
# Create a backup directory
mkdir -p ~/backups
# Back up data and uploads
tar -czf ~/backups/brasilware-data-$(date +%Y%m%d).tar.gz ./data ./uploads
Common problem solving
The server does not start
Check the error logs with:
npm run start > error.log 2>&1
cat error.log
Problems with file permissions
Make sure the user who runs the application has reading/writing permissions in the directories data
and uploads
:
sudo chown -R yor-username:yor-group ./data ./uploads
sudo chmod -R 777 ./data ./uploads
Error in integration with the OpenAi API
Check that the API key is correctly configured in the settings
Requirements recommended resources
For the typical use of Brazilware in a production environment, recomendamos:
- CPU: 1 core or more
- RAM: Minimum of 1GB, recommended 2GB
- Storage: 20MB or more, depending on the volume of stored PDFs and modules
- Bandwidth: At least 10 Mbps for Upload/Download Reports
Contact and support
For additional help, contact the development team: