@startuml
title = Директ: взаимодействие с конструктором перформансов (смартов)

actor Client
boundary browser

box "Директ - серверсайд" #LightBlue
control "Direct-web-nginx" as direct_web_nginx
control "Директ - web" as direct_web
control "Директ - intapi" as direct_intapi_perl
control "Директ - скрипты" as direct_scripts
database "DB ppc" as db_ppc
end box

control "Конструктор смартов\n$BS_REST_API_URL" as constructor_performance
control "БК" as BS

'==========================================================================

== Создание смарт-группы ==

Client -> direct_web : cmd/addAdGroupsPerformance \nсоздание группы смарт-баннеров
Client -> browser : выбрать фид
Client -> browser : **+ Добавить баннер**
browser -> direct_web : cmd=searchCreatives
activate direct_web
direct_web -> db_ppc
direct_web -> browser : json
deactivate direct_web
browser -> Client : попап "Креативы"

== Открыть констуктор ==

Client -> browser : **+ Создать новые**

browser -> direct_web_nginx : /smart-designer/add \nlogin=kosmana
activate direct_web_nginx
direct_web_nginx --> constructor_performance : proxy_pass AD_DESIGNER_URL
activate constructor_performance

constructor_performance -> direct_intapi_perl : auth
activate direct_intapi_perl
direct_intapi_perl -> constructor_performance : OK
deactivate direct_intapi_perl
|||

constructor_performance -> direct_web_nginx
deactivate constructor_performance
direct_web_nginx --> browser : iframe\n"Новая группа креативов"
deactivate direct_web_nginx

Client -> browser : клик

browser -> direct_web_nginx 
activate direct_web_nginx
direct_web_nginx --> constructor_performance 
deactivate direct_web_nginx

Client -> browser : клик

browser -> direct_web_nginx 
activate direct_web_nginx
direct_web_nginx --> constructor_performance 
deactivate direct_web_nginx

Client -> browser : клик

== Сохранить креатив ==

Client -> browser : **Создать креативы** \n(кнопка в попапе) 

browser -> direct_web_nginx : /ad-designer/rest \n/creativeGroups/smart
activate direct_web_nginx

direct_web_nginx -->  constructor_performance : proxy_pass
activate constructor_performance

constructor_performance -> direct_intapi_perl : BsFront method=change_notify, ids=...
activate direct_intapi_perl

|||
direct_intapi_perl -> constructor_performance : banner_storage_call / GET creatives
activate constructor_performance
constructor_performance -> direct_intapi_perl : data
deactivate constructor_performance
|||
direct_intapi_perl ->o db_ppc : insert/update \nperf_creatives 

direct_intapi_perl -> constructor_performance : OK
deactivate direct_intapi_perl
constructor_performance -> direct_web_nginx : OK
deactivate constructor_performance

direct_web_nginx --> browser : OK
deactivate direct_web_nginx


browser -> direct_web_nginx : cmd=searchCreatives
activate direct_web_nginx
direct_web_nginx -> direct_web 
activate direct_web 
direct_web -> db_ppc : select 
direct_web -> direct_web_nginx
deactivate direct_web
direct_web_nginx -> browser
deactivate direct_web_nginx


== Модерация ==

...

direct_scripts -> constructor_performance : Модерируй
... 
constructor_performance -> direct_intapi_perl : Модерация OK

== Отправка в БК == 

...
direct_scripts -> BS : Показывай \nid креатива
...
constructor_performance -> BS : креатив \n(??? кто к кому ходит?)
|||
|||

== The End ==
note left of Client
  **2017-09**

  Участники
  ""lena-san@""
  ""aleran@""
  ""adubinkin@""
  ""gukserg@""
  ""kosmana@""
  ""zhur@""
  и другие 
end note


@enduml

