diff --git a/compose.test.yml b/compose.test.yml
new file mode 100644
index 0000000..6ad8203
--- /dev/null
+++ b/compose.test.yml
@@ -0,0 +1,90 @@
+services:
+ db:
+ image: postgres:16.1
+ container_name: postgres
+ ports:
+ - "5445:5432"
+ volumes:
+ - ./volumes/shareit:/var/lib/postgresql/data/
+ environment:
+ - SPRING_PROFILES_ACTIVE=dev
+ - POSTGRES_DB=shareit
+ - POSTGRES_USER=dbuser
+ - POSTGRES_PASSWORD=12345
+ healthcheck:
+ test: pg_isready -q -d $$POSTGRES_DB -U $$POSTGRES_USER
+ timeout: 5s
+ interval: 5s
+ retries: 10
+
+ db-init:
+ image: postgres:16.1
+ container_name: db-init-test
+ depends_on:
+ db:
+ condition: service_healthy
+ entrypoint:
+ - bash
+ - -c
+ - |
+ set -e
+ psql postgresql://dbuser:12345@db:5432/shareit -v ON_ERROR_STOP=1 <<-EOSQL
+ drop table IF EXISTS users CASCADE;
+ drop table IF EXISTS items CASCADE;
+ drop table IF EXISTS bookings CASCADE;
+ drop table IF EXISTS requests CASCADE;
+ drop table IF EXISTS comments CASCADE;
+
+ create TABLE IF NOT EXISTS users (
+ id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL,
+ name VARCHAR(255) NOT NULL,
+ email VARCHAR(512) NOT NULL,
+ CONSTRAINT pk_user PRIMARY KEY (id),
+ CONSTRAINT UQ_USER_EMAIL UNIQUE (email)
+ );
+
+ create TABLE IF NOT EXISTS requests (
+ id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL,
+ description VARCHAR(2000),
+ requestor_id BIGINT NOT NULL,
+ created TIMESTAMP WITHOUT TIME ZONE NOT NULL,
+ CONSTRAINT pk_request PRIMARY KEY (id),
+ CONSTRAINT fk_request_requestor FOREIGN KEY (requestor_id) REFERENCES users(id)
+ );
+
+ create TABLE IF NOT EXISTS items (
+ id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL,
+ name VARCHAR(255) NOT NULL,
+ description VARCHAR(2000),
+ available BOOLEAN DEFAULT TRUE,
+ owner_id BIGINT NOT NULL,
+ item_request_id BIGINT,
+ CONSTRAINT pk_item PRIMARY KEY (id),
+ CONSTRAINT fk_item_owner FOREIGN KEY (owner_id) REFERENCES users(id),
+ CONSTRAINT fk_item_item_request FOREIGN KEY (item_request_id) REFERENCES requests(id)
+ );
+
+ create TABLE IF NOT EXISTS bookings (
+ id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL,
+ start_date TIMESTAMP WITHOUT TIME ZONE NOT NULL,
+ end_date TIMESTAMP WITHOUT TIME ZONE NOT NULL,
+ item_id BIGINT NOT NULL,
+ booker_id BIGINT NOT NULL,
+ status VARCHAR(50),
+ CONSTRAINT pk_booking PRIMARY KEY (id),
+ CONSTRAINT fk_booking_item FOREIGN KEY (item_id) REFERENCES items(id),
+ CONSTRAINT fk_booking_booker FOREIGN KEY (booker_id) REFERENCES users(id)
+ );
+
+ create TABLE IF NOT EXISTS comments (
+ id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL,
+ text VARCHAR(2000),
+ item_id BIGINT NOT NULL,
+ author_id BIGINT NOT NULL,
+ created TIMESTAMP WITHOUT TIME ZONE NOT NULL,
+ CONSTRAINT pk_comment PRIMARY KEY (id),
+ CONSTRAINT fk_comment_item FOREIGN KEY (item_id) REFERENCES items(id),
+ CONSTRAINT fk_comment_author FOREIGN KEY (author_id) REFERENCES users(id)
+ );
+ EOSQL
+
diff --git a/compose.yaml b/compose.yaml
deleted file mode 100644
index 35ebf89..0000000
--- a/compose.yaml
+++ /dev/null
@@ -1,17 +0,0 @@
-services:
- db:
- image: postgres:16.1
- container_name: postgres5
- ports:
- - "5438:5432"
- volumes:
- - ./volumes/postgres:/var/lib/postgresql/data/
- environment:
- - POSTGRES_DB=shareitdb
- - POSTGRES_USER=dbuser
- - POSTGRES_PASSWORD=12345
- healthcheck:
- test: pg_isready -q -d $$POSTGRES_DB -U $$POSTGRES_USER
- timeout: 5s
- interval: 5s
- retries: 10
\ No newline at end of file
diff --git a/compose.yml b/compose.yml
new file mode 100644
index 0000000..ae83854
--- /dev/null
+++ b/compose.yml
@@ -0,0 +1,40 @@
+services:
+ gateway:
+ build: gateway
+ image: shareit-gateway
+ container_name: shareit-gateway
+ ports:
+ - "8080:8080"
+ depends_on:
+ - server
+ environment:
+ - SHAREIT_SERVER_URL=http://server:9090
+
+ server:
+ build: server
+ image: shareit-server
+ container_name: shareit-server
+ ports:
+ - "9090:9090"
+ depends_on:
+ - db
+ environment:
+ - SPRING_PROFILES_ACTIVE=dev
+ - SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/shareit
+ - SPRING_DATASOURCE_USERNAME=dbuser
+ - SPRING_DATASOURCE_PASSWORD=12345
+
+ db:
+ image: postgres:16.1
+ container_name: postgres
+ ports:
+ - "6541:5432"
+ environment:
+ - POSTGRES_PASSWORD=12345
+ - POSTGRES_USER=dbuser
+ - POSTGRES_DB=shareit
+ healthcheck:
+ test: pg_isready -q -d $$POSTGRES_DB -U $$POSTGRES_USER
+ timeout: 5s
+ interval: 5s
+ retries: 10
\ No newline at end of file
diff --git a/gateway/Dockerfile b/gateway/Dockerfile
new file mode 100644
index 0000000..0ff1817
--- /dev/null
+++ b/gateway/Dockerfile
@@ -0,0 +1,5 @@
+FROM eclipse-temurin:21-jre-jammy
+VOLUME /tmp
+ARG JAR_FILE=target/*.jar
+COPY ${JAR_FILE} app.jar
+ENTRYPOINT ["sh", "-c", "java ${JAVA_OPTS} -jar /app.jar"]
\ No newline at end of file
diff --git a/gateway/pom.xml b/gateway/pom.xml
new file mode 100644
index 0000000..f3394c1
--- /dev/null
+++ b/gateway/pom.xml
@@ -0,0 +1,70 @@
+
+
+ 4.0.0
+
+ ru.practicum
+ shareit
+ 0.0.1-SNAPSHOT
+
+
+ shareit-gateway
+ 0.0.1-SNAPSHOT
+
+ ShareIt Gateway
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.springframework.boot
+ spring-boot-starter-validation
+
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
+
+ org.hibernate.validator
+ hibernate-validator
+
+
+
+ org.apache.httpcomponents.client5
+ httpclient5
+
+
+
+ org.springframework.boot
+ spring-boot-configuration-processor
+ true
+
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
\ No newline at end of file
diff --git a/gateway/src/main/java/ru/practicum/shareit/ShareItGateway.java b/gateway/src/main/java/ru/practicum/shareit/ShareItGateway.java
new file mode 100644
index 0000000..e659d11
--- /dev/null
+++ b/gateway/src/main/java/ru/practicum/shareit/ShareItGateway.java
@@ -0,0 +1,12 @@
+package ru.practicum.shareit;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class ShareItGateway {
+ public static void main(String[] args) {
+ SpringApplication.run(ShareItGateway.class, args);
+ }
+
+}
diff --git a/gateway/src/main/java/ru/practicum/shareit/booking/client/BookingClient.java b/gateway/src/main/java/ru/practicum/shareit/booking/client/BookingClient.java
new file mode 100644
index 0000000..887e62e
--- /dev/null
+++ b/gateway/src/main/java/ru/practicum/shareit/booking/client/BookingClient.java
@@ -0,0 +1,55 @@
+package ru.practicum.shareit.booking.client;
+
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.web.client.RestTemplateBuilder;
+import org.springframework.http.ResponseEntity;
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
+import org.springframework.stereotype.Service;
+import org.springframework.web.util.DefaultUriBuilderFactory;
+
+import ru.practicum.shareit.booking.dto.BookingRequestDto;
+import ru.practicum.shareit.client.BaseClient;
+
+@Service
+public class BookingClient extends BaseClient {
+ private static final String API_PREFIX = "/bookings";
+
+ @Autowired
+ public BookingClient(@Value("${shareit-server.url}") String serverUrl, RestTemplateBuilder builder) {
+ super(
+ builder
+ .uriTemplateHandler(new DefaultUriBuilderFactory(serverUrl + API_PREFIX))
+ .requestFactory(() -> new HttpComponentsClientHttpRequestFactory())
+ .build()
+ );
+ }
+
+ public ResponseEntity