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.