Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 58 additions & 7 deletions backend/Makefile → Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ endif
# Paths
# =====================
ROOT := $(CURDIR)
OUT_PATH := $(ROOT)/pkg
LOCAL_BIN := $(ROOT)/bin
VENDOR := $(ROOT)/vendor.protogen
BACKEND_PATH := $(ROOT)/backend
OUT_PATH := $(BACKEND_PATH)/pkg
LOCAL_BIN := $(BACKEND_PATH)/bin
VENDOR := $(BACKEND_PATH)/vendor.protogen

PROTOC := protoc
PROTOC_GEN_GO := $(LOCAL_BIN)/protoc-gen-go$(EXE)
Expand All @@ -51,17 +52,44 @@ docker-up:
docker-down:
docker compose down

docker-build:
docker compose build

docker-logs:
docker compose logs -f

# =====================
# Backend services
# =====================
backend-run:
cd $(BACKEND_PATH) && go run cmd/server/main.go

backend-build:
cd $(BACKEND_PATH) && go build -o bin/server cmd/server/main.go

Comment on lines +67 to +69

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Backend-build missing mkdir 🐞 Bug ⛯ Reliability

make backend-build outputs to backend/bin/server but the target never creates backend/bin (and
it’s gitignored), so a fresh checkout will likely fail with a “no such file or directory” when
writing the binary.
Agent Prompt
## Issue description
`backend-build` writes the binary to `backend/bin/server` but doesn’t ensure `backend/bin` exists. Because `backend/bin/` is gitignored, it won’t exist on a clean checkout and the build can fail.

## Issue Context
- `backend-build` is intended as a convenient top-level build target.
- `bin-deps` already creates `$(LOCAL_BIN)` but `backend-build` does not depend on it.

## Fix Focus Areas
- Makefile[64-69]
- Makefile[97-99]
- .gitignore[29-36]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

# =====================
# Frontend services
# =====================
frontend-install:
cd $(ROOT)/wb_front && npm install

frontend-run:
cd $(ROOT)/wb_front && npm run dev

frontend-build:
cd $(ROOT)/wb_front && npm run build

# =====================
# Migrations
# =====================
migrations-up:
goose -dir ./migrations postgres "postgres://postgres:postgres@localhost:5442/seller_promotions?sslmode=disable" up
cd $(BACKEND_PATH) && goose -dir ./migrations postgres "postgres://postgres:postgres@localhost:5442/seller_promotions?sslmode=disable" up

migrations-down:
goose -dir ./migrations postgres "postgres://postgres:postgres@localhost:5442/seller_promotions?sslmode=disable" down
cd $(BACKEND_PATH) && goose -dir ./migrations postgres "postgres://postgres:postgres@localhost:5442/seller_promotions?sslmode=disable" down

migrations-new:
goose create -dir ./migrations rename sql
cd $(BACKEND_PATH) && goose create -dir ./migrations rename sql
Comment on lines 85 to +92

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

2. Migrations not self-contained 🐞 Bug ⛯ Reliability

The Makefile exposes migrations-* targets that directly call goose, but they don’t depend on
bin-deps, and bin-deps installs goose only on Windows. On macOS/Linux, make migrations-up may
fail unless goose is manually installed.
Agent Prompt
## Issue description
`migrations-up/down/new` call `goose`, but the Makefile doesn’t guarantee `goose` exists on macOS/Linux and the migrations targets don’t depend on any tool-installation target.

## Issue Context
- Windows `bin-deps` installs goose, but non-Windows does not.
- The Makefile now advertises migrations targets via `help`, so they should work reliably.

## Fix Focus Areas
- Makefile[82-92]
- Makefile[97-112]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


# =====================
# Binary deps (idempotent)
Expand Down Expand Up @@ -104,7 +132,7 @@ generate: bin-deps vendor-proto
$(call gen,common)

define gen
$(PROTOC) \
cd $(BACKEND_PATH) && $(PROTOC) \
--proto_path=api/proto \
--proto_path=$(VENDOR) \
--plugin=protoc-gen-go=$(PROTOC_GEN_GO) \
Expand Down Expand Up @@ -177,3 +205,26 @@ else
rm -rf tmp-validate ; \
fi
endif

# =====================
# Help
# =====================
help:
@echo "Available commands:"
@echo " docker-up - Start all containers"
@echo " docker-down - Stop all containers"
@echo " docker-build - Build all containers"
@echo " docker-logs - Follow logs"
@echo " backend-run - Run backend locally"
@echo " backend-build - Build backend binary"
@echo " frontend-install - Install frontend dependencies"
@echo " frontend-run - Run frontend locally"
@echo " frontend-build - Build frontend"
@echo " migrations-up - Run migrations"
@echo " migrations-down - Rollback migrations"
@echo " migrations-new - Create new migration"
@echo " generate - Generate protobuf files"
@echo " bin-deps - Install binary dependencies"
@echo " vendor-proto - Vendor proto files"

.PHONY: docker-up docker-down docker-build docker-logs backend-run backend-build frontend-install frontend-run frontend-build migrations-up migrations-down migrations-new generate bin-deps vendor-proto help
54 changes: 48 additions & 6 deletions backend/api/proto/admin.proto
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ message CreatePromotionResponse {
}

// GET /admin/promotions/
message GetPromotionRequest {}
message GetPromotionsRequest {}

message GetPromotionResponse {
message GetPromotionsResponse {
repeated SinglePromotion promotions = 1;
}

Expand Down Expand Up @@ -110,7 +110,9 @@ message UpdatePromotionRequest {
optional string pricing_model = 8;
optional int32 slot_count = 9;
optional int32 discount = 10;
repeated string stop_factors = 11;
optional int64 minPrice = 11;
optional int64 bidStep = 12;
repeated string stop_factors = 13;
}

message UpdatePromotionResponse {}
Expand All @@ -122,6 +124,24 @@ message DeletePromotionRequest {

message DeletePromotionResponse {}

// GET /admin/promotions/{id}
message GetPromotionRequest {
int64 id = 1;
}

// GET /admin/promotions/{id}/auction-params
message GetAuctionParamsRequest {
int64 id = 1;
}

message GetAuctionParamsResponse {
int64 id = 1;
int64 minPrice = 2;
int64 bidStep = 3;
string DateFrom = 4;
string DateTo = 5;
}

// PUT /admin/promotions/{id}/fixed-prices
message SetFixedPricesRequest {
int64 promotion_id = 1;
Expand Down Expand Up @@ -294,15 +314,15 @@ service PromotionAdminService {
operation_id: "CreatePromotion";
};
}
rpc GetPromotions(GetPromotionRequest) returns (GetPromotionResponse) {
rpc GetPromotions(GetPromotionsRequest) returns (GetPromotionsResponse) {
option (google.api.http) = {
get: "/admin/promotions"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "Получить информацию об акции";
summary: "Получить информацию об акциях";
description: "Получает информацию об акциях";
tags: "Promotions";
operation_id: "GetPromotion";
operation_id: "GetPromotions";
};
}
rpc UpdatePromotion(UpdatePromotionRequest) returns (UpdatePromotionResponse) {
Expand All @@ -317,6 +337,17 @@ service PromotionAdminService {
operation_id: "UpdatePromotion";
};
}
rpc GetPromotion(GetPromotionRequest) returns (SinglePromotion) {
option (google.api.http) = {
get: "/admin/promotions/{id}"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "Получить информацию об акции";
description: "Получает информацию об акции по ID";
tags: "Promotions";
operation_id: "GetPromotion";
};
}
rpc DeletePromotion(DeletePromotionRequest) returns (DeletePromotionResponse) {
option (google.api.http) = {
delete: "/admin/promotions/{id}"
Expand All @@ -328,6 +359,17 @@ service PromotionAdminService {
operation_id: "DeletePromotion";
};
}
rpc GetAuctionParams(GetAuctionParamsRequest) returns (GetAuctionParamsResponse) {
option (google.api.http) = {
get: "/admin/promotions/{id}/auction-params"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "Получить параметры аукциона акции";
description: "Получает параметры аукциона акции по ID";
tags: "Promotions";
operation_id: "GetAuctionParams";
};
}
rpc SetFixedPrices(SetFixedPricesRequest) returns (SetFixedPricesResponse) {
option (google.api.http) = {
put: "/admin/promotions/{promotion_id}/fixed-prices"
Expand Down
15 changes: 7 additions & 8 deletions backend/cmd/server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,22 @@ FROM golang:1.24.12-alpine AS builder

WORKDIR /app

COPY ../../go.mod ../../go.sum ./

COPY go.mod go.sum ./
RUN go mod download

COPY ../../. .

WORKDIR /app/cmd/server
COPY . .

RUN go build -o server
RUN go build -o server ./cmd/server

FROM alpine:latest

WORKDIR /root/

COPY --from=builder /app/cmd/server/server .
COPY config.yaml .
COPY --from=builder /app/server .
COPY --from=builder /app/config.yaml .

RUN chmod +x server

EXPOSE 7001 7002 8080

ENTRYPOINT ["./server"]
51 changes: 0 additions & 51 deletions backend/docker-compose.yml

This file was deleted.

Loading