replaced everything with ws

This commit is contained in:
Mykhailo Svishchov
2026-03-04 21:42:35 +02:00
parent 68d04f2203
commit 313bd13ef9
378 changed files with 29072 additions and 824 deletions

View File

@@ -1,6 +1,6 @@
# Honey Backend
# Lottery Backend
Spring Boot backend application for Honey project.
Spring Boot backend application for Lottery project.
## Technology Stack
@@ -30,7 +30,7 @@ Spring Boot backend application for Honey project.
3. **Create `.env` file** (for local development):
```env
DB_NAME=honey_db
DB_NAME=lottery_db
DB_USERNAME=root
DB_PASSWORD=password
DB_ROOT_PASSWORD=password
@@ -75,7 +75,7 @@ Railway is the primary deployment platform for staging. It provides built-in log
1. In your Railway project, click **"+ New"** → **"GitHub Repo"** (or **"Empty Service"**)
2. If using GitHub:
- Connect your GitHub account
- Select the `honey-be` repository
- Select the `lottery-be` repository
- Railway will automatically detect it's a Java/Maven project
3. If using Empty Service:
- Click **"Empty Service"**
@@ -122,12 +122,12 @@ PORT=8080
1. In your backend service, go to **"Settings"** → **"Networking"**
2. Click **"Generate Domain"** to get a public URL
3. Or use the default Railway domain
4. Copy the URL (e.g., `https://honey-be-production.up.railway.app`)
4. Copy the URL (e.g., `https://lottery-be-production.up.railway.app`)
#### Step 9: Create Frontend Service (Optional - if deploying frontend to Railway)
1. In your Railway project, click **"+ New"** → **"GitHub Repo"**
2. Select your `honey-fe` repository
2. Select your `lottery-fe` repository
3. Railway will detect it's a Node.js project
4. Add environment variable:
```env
@@ -140,7 +140,7 @@ PORT=8080
If you need persistent storage:
1. In your Railway project, click **"+ New"** → **"Volume"**
2. Name it (e.g., `honey-data`)
2. Name it (e.g., `lottery-data`)
3. Mount it to your service if needed
### Inferno Deployment (Production Environment)
@@ -184,16 +184,16 @@ Inferno Solution provides the production environment. It requires manual server
5. **Create project directory**:
```bash
mkdir -p /opt/honey
cd /opt/honey
mkdir -p /opt/lottery
cd /opt/lottery
```
#### Step 2: Clone Repository
```bash
cd /opt/honey
git clone https://github.com/your-username/honey-be.git
cd honey-be
cd /opt/lottery
git clone https://github.com/your-username/lottery-be.git
cd lottery-be
```
#### Step 3: Create Secret Configuration File
@@ -206,14 +206,14 @@ sudo mkdir -p /run/secrets
sudo chmod 700 /run/secrets
# Create secret file
sudo nano /run/secrets/honey-config.properties
sudo nano /run/secrets/lottery-config.properties
```
Add the following content (replace with your actual values):
```properties
SPRING_DATASOURCE_URL=jdbc:mysql://db:3306/honey_db
SPRING_DATASOURCE_USERNAME=honey_user
SPRING_DATASOURCE_URL=jdbc:mysql://db:3306/lottery_db
SPRING_DATASOURCE_USERNAME=lottery_user
SPRING_DATASOURCE_PASSWORD=your_secure_mysql_password
TELEGRAM_BOT_TOKEN=your_telegram_bot_token
FRONTEND_URL=https://your-frontend-domain.com
@@ -233,7 +233,7 @@ The `docker-compose.inferno.yml` file is already configured. Make sure it's pres
#### Step 5: Build and Start Services
```bash
cd /opt/honey/honey-be
cd /opt/lottery/lottery-be
# Build and start all services
docker-compose -f docker-compose.inferno.yml up -d --build
@@ -249,7 +249,7 @@ This will:
1. **Edit nginx configuration**:
```bash
nano nginx/conf.d/honey.conf
nano nginx/conf.d/lottery.conf
```
2. **Update server_name** (if using HTTPS):
@@ -278,7 +278,7 @@ This will:
sudo certbot --nginx -d your-domain.com
```
3. **Update nginx config** to use HTTPS (uncomment HTTPS server block in `nginx/conf.d/honey.conf`)
3. **Update nginx config** to use HTTPS (uncomment HTTPS server block in `nginx/conf.d/lottery.conf`)
4. **Reload nginx**:
```bash
@@ -304,21 +304,21 @@ sudo ufw enable
Create a systemd service to ensure services start on boot:
```bash
sudo nano /etc/systemd/system/honey.service
sudo nano /etc/systemd/system/lottery.service
```
Add:
```ini
[Unit]
Description=Honey Application
Description=Lottery Application
Requires=docker.service
After=docker.service
[Service]
Type=oneshot
RemainAfterExit=yes
WorkingDirectory=/opt/honey/honey-be
WorkingDirectory=/opt/lottery/lottery-be
ExecStart=/usr/local/bin/docker-compose -f docker-compose.inferno.yml up -d
ExecStop=/usr/local/bin/docker-compose -f docker-compose.inferno.yml down
TimeoutStartSec=0
@@ -331,8 +331,8 @@ Enable the service:
```bash
sudo systemctl daemon-reload
sudo systemctl enable honey.service
sudo systemctl start honey.service
sudo systemctl enable lottery.service
sudo systemctl start lottery.service
```
#### Step 10: Set Up Grafana Integration (Production Logging)
@@ -357,13 +357,13 @@ sudo systemctl start honey.service
- url: http://loki:3100/loki/api/v1/push
scrape_configs:
- job_name: honey-backend
- job_name: lottery-backend
docker_sd_configs:
- host: unix:///var/run/docker.sock
refresh_interval: 5s
relabel_configs:
- source_labels: [__meta_docker_container_name]
regex: honey-backend
regex: lottery-backend
action: keep
```
@@ -398,14 +398,14 @@ docker-compose -f docker-compose.inferno.yml logs -f app
**Update application**:
```bash
cd /opt/honey/honey-be
cd /opt/lottery/lottery-be
git pull
docker-compose -f docker-compose.inferno.yml up -d --build
```
**Backup database**:
```bash
docker-compose -f docker-compose.inferno.yml exec db mysqldump -u honey_user -p honey_db > backup_$(date +%Y%m%d).sql
docker-compose -f docker-compose.inferno.yml exec db mysqldump -u lottery_user -p lottery_db > backup_$(date +%Y%m%d).sql
```
## Configuration
@@ -415,7 +415,7 @@ docker-compose -f docker-compose.inferno.yml exec db mysqldump -u honey_user -p
The application supports two configuration strategies:
1. **Environment Variables** (Railway): Set variables in Railway dashboard
2. **Secret File** (Inferno): Mount file at `/run/secrets/honey-config.properties`
2. **Secret File** (Inferno): Mount file at `/run/secrets/lottery-config.properties`
Priority: Secret file → Environment variables
@@ -511,10 +511,10 @@ docker-compose up --build
## Project Structure
```
honey-be/
lottery-be/
├── src/
│ ├── main/
│ │ ├── java/com/honey/honey/
│ │ ├── java/com/lottery/lottery/
│ │ │ ├── config/ # Configuration classes
│ │ │ ├── controller/ # REST controllers
│ │ │ ├── dto/ # Data transfer objects
@@ -540,3 +540,4 @@ honey-be/
[Your License Here]