feat: Add full CRUD functionality, project detail panel, and improved UI
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled

- Add UPDATE and DELETE endpoints to backend
- Implement project detail panel with comprehensive editing
- Add drag-and-drop functionality for projects in mind map
- Show all projects in map (not just selected + children)
- Fix infinite render loop in MindMap component
- Improve UI spacing and button layouts
- Add local development database schema with RLS disabled
- Update docker-compose for regular docker-compose (not Swarm)
- Add CORS support and nginx API proxying
- Improve button spacing and modern design principles
This commit is contained in:
gitmuhammedalbayrak
2025-11-27 03:18:48 +03:00
parent 066c16221d
commit b9148cfa4b
15 changed files with 1306 additions and 161 deletions

View File

@@ -1,52 +1,114 @@
# Local Development with Docker Swarm
# Local Development with Docker Compose
This directory contains the configuration to run the Evrak application locally using Docker Swarm on Windows 11.
This directory contains the configuration to run the Evrak application locally using Docker Compose.
## Prerequisites
1. **Docker Desktop**: Ensure Docker Desktop is installed and running.
2. **Swarm Mode**: Enable Swarm mode if not already enabled:
```powershell
docker swarm init
```
1. **Docker Desktop**: Ensure Docker Desktop is installed and running on your machine.
2. **Ports**: Make sure ports 80, 3000, and 5432 are available on your host machine.
## How to Deploy
## Quick Start
### 1. Build Images
First, build the Docker images locally. `docker stack deploy` does not build images, so this step is required.
### 1. Build and Start Services
```powershell
docker compose -f deploy/local/docker-compose.yml build
From the project root directory, run:
```bash
docker compose -f deploy/local/docker-compose.yml up --build
```
### 2. Deploy to Swarm
Deploy the stack to your local Swarm cluster.
Or in PowerShell:
```powershell
docker stack deploy -c deploy/local/docker-compose.yml evrak
docker compose -f deploy/local/docker-compose.yml up --build
```
### 3. Verify
Check if the services are running:
This will:
- Build the Docker images for backend and frontend
- Start PostgreSQL database
- Start the backend API server
- Start the frontend web server
```powershell
docker service ls
docker stack ps evrak
```
### 2. Access the Application
Once all services are running, access the application at:
Access the application:
* **Frontend**: http://localhost
* **Backend API**: http://localhost:3000
* **Database**: localhost:5432
* **Database**: localhost:5432 (user: `evrak_user`, password: `evrak_password`, database: `evrak`)
### 4. Remove Stack
To stop and remove the application:
### 3. Stop Services
```powershell
docker stack rm evrak
To stop all services:
```bash
docker compose -f deploy/local/docker-compose.yml down
```
To stop and remove volumes (database data):
```bash
docker compose -f deploy/local/docker-compose.yml down -v
```
## Development Workflow
### Running in Detached Mode
To run services in the background:
```bash
docker compose -f deploy/local/docker-compose.yml up -d --build
```
### View Logs
View logs from all services:
```bash
docker compose -f deploy/local/docker-compose.yml logs -f
```
View logs from a specific service:
```bash
docker compose -f deploy/local/docker-compose.yml logs -f backend
docker compose -f deploy/local/docker-compose.yml logs -f frontend
docker compose -f deploy/local/docker-compose.yml logs -f postgres
```
### Rebuild After Code Changes
If you make changes to the code, rebuild the affected service:
```bash
docker compose -f deploy/local/docker-compose.yml up --build backend
docker compose -f deploy/local/docker-compose.yml up --build frontend
```
## Troubleshooting
* **Image not found**: Make sure you ran the build step.
* **Ports occupied**: Ensure ports 80, 3000, and 5432 are free on your host machine.
* **Build errors**: Make sure all dependencies are properly installed. Try removing `node_modules` and rebuilding.
* **Database connection issues**: Wait a few seconds after starting services for the database to initialize.
* **CORS errors**: The backend is configured to allow requests from `http://localhost:80`. If you're accessing from a different port, update the `FRONTEND_URL` environment variable in `docker-compose.yml`.
## Service Details
- **PostgreSQL**: Database service with automatic health checks and schema initialization
- The database schema (including ltree extension, indexes, and helper functions) is automatically initialized on first startup
- Row Level Security (RLS) is **disabled** for local development to simplify testing
- A default tenant is created automatically: `00000000-0000-0000-0000-000000000001`
- **Backend**: NestJS API server running on port 3000
- Supports hierarchical project structure using PostgreSQL ltree
- Multi-tenant architecture (RLS disabled for local dev)
- **Frontend**: React application served via Nginx on port 80, with API proxying configured
## Database Schema
The database is automatically initialized with:
- PostgreSQL extensions: `uuid-ossp`, `ltree`, `pg_trgm`
- Tables: `tenants`, `users`, `projects`
- Indexes: GIST for ltree paths, GIN for JSONB attributes
- Helper function: `move_project_subtree()` for moving project hierarchies
**Note**: For production deployments, use `backend/src/database/schema.sql` which enables Row Level Security (RLS) for proper tenant isolation.

111
deploy/local/TEST.md Normal file
View File

@@ -0,0 +1,111 @@
# Testing Instructions
## Prerequisites
1. **Start Docker Desktop** - Make sure Docker Desktop is running on your Windows machine
2. **Verify Docker is running**:
```powershell
docker ps
```
This should not show an error.
## Step 1: Start the Services
From the project root directory:
```powershell
docker compose -f deploy/local/docker-compose.yml up --build
```
Or to run in detached mode (background):
```powershell
docker compose -f deploy/local/docker-compose.yml up --build -d
```
## Step 2: Verify Services are Running
Check that all containers are running:
```powershell
docker compose -f deploy/local/docker-compose.yml ps
```
You should see three services:
- `evrak-postgres` (healthy)
- `evrak-backend` (running)
- `evrak-frontend` (running)
## Step 3: Check Logs
View logs to ensure everything started correctly:
```powershell
# All services
docker compose -f deploy/local/docker-compose.yml logs
# Specific service
docker compose -f deploy/local/docker-compose.yml logs backend
docker compose -f deploy/local/docker-compose.yml logs postgres
```
## Step 4: Test the API
### Test Backend Health
```powershell
curl http://localhost:3000
```
### Create a Tenant
```powershell
curl -X POST http://localhost:3000/tenants -H "Content-Type: application/json" -d "{\"name\":\"Test Tenant\"}"
```
### Create a Project
```powershell
curl -X POST http://localhost:3000/projects -H "Content-Type: application/json" -d "{\"name\":\"Test Project\",\"tenant_id\":\"00000000-0000-0000-0000-000000000001\",\"path\":\"test_project\"}"
```
### Get All Projects
```powershell
curl http://localhost:3000/projects
```
## Step 5: Access the Frontend
Open your browser and navigate to:
- **Frontend**: http://localhost
- **Backend API**: http://localhost:3000
## Step 6: Stop Services
When done testing:
```powershell
docker compose -f deploy/local/docker-compose.yml down
```
To also remove volumes (database data):
```powershell
docker compose -f deploy/local/docker-compose.yml down -v
```
## Troubleshooting
### Docker Desktop Not Running
- Start Docker Desktop from Windows Start Menu
- Wait for it to fully start (whale icon in system tray should be steady)
### Port Already in Use
- Check if ports 80, 3000, or 5432 are already in use
- Stop conflicting services or change ports in docker-compose.yml
### Database Connection Issues
- Wait a few seconds after starting for database to initialize
- Check postgres logs: `docker compose -f deploy/local/docker-compose.yml logs postgres`
### Build Errors
- Make sure you're in the project root directory
- Try: `docker compose -f deploy/local/docker-compose.yml build --no-cache`

View File

@@ -1,8 +1,7 @@
version: '3.8'
services:
postgres:
image: postgres:14-alpine
container_name: evrak-postgres
environment:
POSTGRES_USER: evrak_user
POSTGRES_PASSWORD: evrak_password
@@ -11,19 +10,22 @@ services:
- "5432:5432"
volumes:
- db_data:/var/lib/postgresql/data
- ../../backend/src/database/schema-local.sql:/docker-entrypoint-initdb.d/01-schema.sql
networks:
- evrak-net
deploy:
replicas: 1
restart_policy:
condition: on-failure
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -U evrak_user -d evrak"]
interval: 10s
timeout: 5s
retries: 5
backend:
# Note: 'docker stack deploy' ignores 'build'. You must run 'docker compose build' first.
build:
context: ../../backend
dockerfile: Dockerfile
image: evrak-backend:local
container_name: evrak-backend
environment:
DB_HOST: postgres
DB_PORT: 5432
@@ -34,35 +36,29 @@ services:
ports:
- "3000:3000"
depends_on:
- postgres
postgres:
condition: service_healthy
networks:
- evrak-net
deploy:
replicas: 1
restart_policy:
condition: on-failure
restart: unless-stopped
frontend:
build:
context: ../../frontend
dockerfile: Dockerfile
image: evrak-frontend:local
container_name: evrak-frontend
ports:
- "80:80"
depends_on:
- backend
networks:
- evrak-net
deploy:
replicas: 1
restart_policy:
condition: on-failure
restart: unless-stopped
volumes:
db_data:
networks:
evrak-net:
driver: overlay
attachable: true
driver: bridge