SurfSmart/README.md
2025-06-10 12:02:57 +08:00

57 lines
1.6 KiB
Markdown

# SurfSmart
SurfSmart is a web application with a Flask backend and a React/Vite frontend.
## Deployment Overview
1. **System packages**
```bash
sudo dnf install -y git python3.12 python3.12-virtualenv nodejs npm redis
```
2. **Clone the repository**
```bash
git clone <repo-url> /opt/surfsmart
cd /opt/surfsmart
```
Remove any bundled virtual environment if present:
```bash
rm -rf backend_flask/flask
```
3. **Create a Python virtual environment and install dependencies**
```bash
python3.12 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install -r backend_flask/requirements.txt
```
4. **Environment variables**
Create a `.env` file and define at least the following:
```bash
MONGO_URI="mongodb+srv://<user>:<pass>@cluster.mongodb.net/?retryWrites=true&w=majority"
SECRET_KEY="replace_with_random_secret"
FRONTEND_ORIGIN="https://surfsmart.tech"
FLASK_CONFIG="production"
CELERY_BROKER_URL="redis://localhost:6379/0"
CELERY_RESULT_BACKEND="redis://localhost:6379/0"
```
5. **Systemd services**
See `surfsmart-backend.service` and `surfsmart-celery.service` examples in the repository root for running Gunicorn and Celery as services.
6. **Build the React frontend**
```bash
cd frontend_react
npm install
npm run build
```
The build artifacts will be located in `frontend_react/dist`.
7. **Nginx configuration**
Configure Nginx to serve the static frontend and proxy `/api/` requests to Gunicorn running the Flask application.
This is only a brief outline. Adjust file paths and domain names to your environment.