Test url : https://testapi.dennysora.com:8081 Test Data : https://hackmd.io/y9bGnuw9Qy-L4l6q-yFmOA
This Back-End Server use technology the following:
- Language
- Golang
- Web Framework
- Gin
- GrpahQL
- gqlgen
- For details, Please see my previous introduction.
- https://hackmd.io/YXl3rRGGRGCLp9uuD6kJXQ
- Database
- Microservice
- Websocket
- Golang
- PM:里冠樺
- Phone:0975-173-786
- Email: js07150715@gmail.com
- LINE:js07150715
- 負責、技術:李汶道
- Phone:0988-954-004
- Email:dennysora.main@gmail.com
digraph dfd2{
nodesep=1.0
subgraph cluster_level0{
label="Server"
Main[label="Main Start" fontsize=24 fillcolor=green fontcolor=Red style=filled]
Init[label="System Init"]
subgraph cluster_level1{
label="Token Model"
TokenFun[label="Token function"]
TokenPool[label="Token Pool"]
}
subgraph cluster_level2{
label="Controller Model"
BR[label="Base review"]
}
subgraph cluster_level3{
label="Database Model"
BM[label="Database base function"]
BT[label="Data struct convert"]
BL[label="Database main link"]
}
subgraph cluster_level4{
label="Socket Model"
SP[label="Socket Pool"]
SF[label="Socket function"]
}
subgraph cluster_level5{
label="Log Model"
log [label="Log Model"]
Trace[label="Resource Trace"]
pprof[label="Runtime Profiling Data"]
}
subgraph cluster_level6{
label="Gin(web framework)"
GQL[label="GraphQL Engine"]
GIN[label="Gin Engine"]
}
}
Main->Init->GIN,log,BL,SP,TokenPool[color=blue]
Main->Trace,pprof[color=green]
Main->GIN[color=red]
log->GIN,BM[color=green]
GIN->SF
GIN->GQL->BR
SF->SP->SF[color=red]
BR->BM
BM->BT->BM[color=red]
BL->BM,BT[color=green]
BR->TokenFun->TokenPool->TokenFun[color=red]
}
Start=>start: Start Main
Server=>end: Start Server
end=>end: Stop Server
Command=>subroutine: Command
InitLog=>subroutine: Init Log
InitDB=>subroutine: Init Database
InitToken=>subroutine: Init Token
cond=>condition: Success or Error
cond2=>condition: Success or Error
cond3=>condition: Success or Error
Start->Command
Command->InitLog->cond
cond(no)->end
cond(yes)->InitDB->cond2
cond2(no)->end
cond2(yes)->InitToken->cond3
cond3(no)->end
cond3(yes)->Server
:::success
- Defer recover.
- Initialization component.
- Stop signal.
- Get error.
- Create log file.
- Registered log function.
- Create database link.
- Get CarID token.
- Registered token function.
- Start monitor token invalid.
:::
server=>start: Start Server
end=>end: Monitor stop interrupt signal
ge=>subroutine: GraphQL Engine
se=>subroutine: Socket Engine
gin=>operation: Gin Default Init
rg=>operation: Gin Server registered
mw=>operation: Middleware registered
server->gin->mw->rg->ge->se->end
:::success
- Make deault gin.
- Registered CORS.
- Registered log.
- Registered pprof.
:::
server=>start: Sokcet Engine Start
end=>end: Monitor Message
LS=>operation: Link Socket
NS=>operation: Number Socket
Sc=>operation: Schedule
GM=>subroutine: Get Message
RM=>subroutine: Request Message
server->LS->Sc->GM->RM->end
:::success
- Verification link authority .
- Distribution link ID.
- Monitor Pool.
- Get link token from pool.
- Get link count from pool.
- Check socket token has group.
- Make socket monitor process.
- Monitor socket pass in message.
- Transfer message to channel.
- Monitor channel message.
- Transfer message to token group of every socket link.
:::
server=>start: GraphQL Engine Start
end=>end: Request
MR=>subroutine: Monitor request
GP=>subroutine: GraphQL playground
resolver1=>subroutine: Resolver Mutation
resolver2=>subroutine: Resolver Query
Controller=>subroutine: Controller Model
DB=>subroutine: Database Model
server->MR->GP->resolver1->resolver2->Controller->DB->end
:::success
- 99designs-gqlgen-GraphQL provide.
- Can test GraphQL API.
- 99designs-gqlgen provide.
- Registered function.
- Has the following function.
- UpdateUser.
- CreateAccount.
- ChangePassword.
- AddCarID.
- Has the following function.
- GetUser.
- LogIn.
- LogOut.
- CheckAccountHas.
- GetCarID.
- GetTemporarilyToken.
- Review input information legality.
- Review token.
- Review account.
- Token convert account ID.
- Query data to MongoDB.
- Insart data to MongoDB.
- Update data to MongoDB.
:::
:::info
- Input parameter
- AccountIDPW
- AccountID
- Password
- User
- Name
- Gender
- CountryNumber
- PhoneNumber
- AccountIDPW
- Output parameter
- Status
- StatusCode
- Description
- AccountID :::
- Status
:::info
- Input parameter
- AccountID
- Password
- Information
- Type
- Device
- Output parameter
- Status
- StatusCode
- Description
- GetTimes
- AccountID
- AccountToken :::
- Status
:::info
- Input parameter
- Token
- Information
- Type
- Device
- Output parameter
- Status
- StatusCode
- Description :::
- Status
:::info
- Input parameter
- Token
- OldPW
- NewPW
- Output parameter
- Status
- StatusCode
- Description
- AccountID :::
- Status
:::info
- Input parameter
- AccountID
- Output parameter
- Status
- StatusCode
- Description
- Has :::
- Status
:::info
- Input parameter
- Token
- Output parameter
- Status
- StatusCode
- Description
- CarID
- CarName
- CreateTime
- RefreshTime :::
- Status
:::info
- Input parameter
- Token
- Output parameter
- Status
- StatusCode
- Description
- Token
- GetTimes :::
- Status
:::info
- Input parameter
- AccountID
- CarName
- TemporarilyToken
- Output parameter
- Status
- StatusCode
- Description
- AccountID
- CarToken :::
- Status
:::info
- Input parameter
- Token
- User
- Name
- Gender
- CountryNumber
- PhoneNumbe
- Output parameter
- Status
- StatusCode
- Description
- AccountID :::
- Status
:::info
- Input parameter
- Token
- GetHistorysNumber
- Output parameter
- Status
- StatusCode
- Description
- Car
- Status
- StatusCode
- Description
- CarID
- CarName
- RefreshTime
- CreateTime
- Status
- Profile
- Name
- Gender
- Phone
- PhoneNumber
- CountryNumber
- Accesse
- Certification
- PermitTime
- Level
- Permit_log
- Level
- Times
- Authority
- SiginHistory
- Times
- UseToken
- Types
- Device
- LogoutHistory
- Times
- UseToken
- Types
- Device :::
- Status
digraph dfd2{
nodesep=1.0
RF[label="Socket close"
fontcolor=Red,
fontsize=24,
shape=octagon]
subgraph Outside{
RQ
[label="Requset Link Socket"];
TokenVerification
[label="Token Verification"]
Schedule
[label="Schedule"]
NS
[label="Number Socket"]
}
subgraph cluster_level1{
label="Message Process Queue";
Link [label="{
<f0> Link Pool Queue|
<f1> UUID Group \n\n}"
shape=Mrecord];
RequestMessage
[label="Request Message function"];
GetMessage
[label="Get Message function."];
VLE
[label="Verification link effective."]
}
NS->Link
[label="Monitor Link Pool."]
Link->VLE
[label="Verification link effective.",
color=red,
fontcolor=red]
VLE->Link
[label="Is effective."
color=green]
VLE->RF
[label="Is invalid."
color=red]
RQ -> TokenVerification
TokenVerification -> Schedule
[label="Token effective"]
TokenVerification -> RF
[label="Token invalid" fontcolor=red]
Schedule -> Link
[label="Add Link In Pool." color=green]
Schedule -> RequestMessage
[label="If link group is Null.\nThen make requset process." color=green]
Schedule -> GetMessage
[label="Make GetMessage process." color=green]
GetMessage,RequestMessage -> Link
[label="Monitor Process."
color=red]
}
digraph dfd2{
nodesep=1.0
subgraph cluster_level1{
label="Link Pool Queue"
PaRM [label="Part A Request Message"]
PaGM1 [label="Part A client 1 Get Message"]
PaGM2 [label="Part A client 2 Get Message"]
PbRM [label="Part B Request Message"]
PbGM1 [label="Part B client 1 Get Message"]
PbGM2 [label="Part B client 2 Get Message"]
PbGM3 [label="Part B client 3 Get Message"]
Pa [label="{
<f0> Part A token group|
{<d1>|<f1> client 1|<l1>}|
{<d2>|<f2> client 2|<l2>}
}"
shape=Mrecord]
Pb [label="{
<f0> Part B token group|
{<d1>|<f1> client 1|<l1>}|
{<d2>|<f2> client 2|<l2>}|
{<d3>|<f3> client 3|<l3>}
}"
shape=Mrecord]
}
PaRM->Pa:d1,Pa:d2
[label="send Message to all client" color=green]
Pa:l1->PaGM1->PaRM
[label="Has Massage" color=red]
Pa:l2->PaGM2
[label="Has Massage" color=brown]
PaGM2,PaGM1->PaRM
[label="Push Massage To Queue" color=red]
PbRM->Pb:d1,Pb:d2,Pb:d3 [color=green]
Pb:l1->PbGM1->PbRM [color=red]
PbGM1->PbRM
Pb:l2->PbGM2->PbRM [color=brown]
PbGM2->PbRM
Pb:l3->PbGM3->PbRM [color=orange]
PbGM3->PbRM
}
digraph dfd2{
nodesep=1.0
}
digraph dfd2{
nodesep=1.0
subgraph cluster_level1{
label="Token Struct"
TP [label="{
<f0> Token Set Table|
<f1> Account|
<f2> Account Token|
<f3> Car Token|
<f4> Certification Token}"
shape=Mrecord];
TN [label="{
{<f0> map |<f1> Account Information }|
<f2> Account Number |
<f3> Car Number|
<f4> Certification Number}"
shape=Mrecord];
AT [label="{
{<d0> map|<f0> Token Struct}|
<f1> Get Time|
<f2> Invalid Time|
<f3> Account ID
}"
shape=Mrecord]
}
subgraph cluster_level3{
label="Token Tool"
CalculationTokenNumber []
SwitchToken []
}
subgraph cluster_level2{
label="Token Function"
GetToken []
EqualToekn []
EqualToeknGetAccount[]
RemoveToken[]
RemoveTokenAll[]
}
subgraph cluster_level4{
label="Monitor"
monitorTokenInvalid []
checkTokenInvalid []
}
TP:f1->TN:f0
[color=red]
TP:f2,TP:f3,TP:f4->AT:d0
[color=red]
CalculationTokenNumber->TP:f1->TN:f2,TN:f3,TN:f4
[color=green]
TP:f2,TP:f3,TP:f4->SwitchToken
[color=blue]
monitorTokenInvalid->checkTokenInvalid->RemoveToken
AT:f1,AT:f2,AT:f3->checkTokenInvalid
RemoveToken->SwitchToken->RemoveToken->CalculationTokenNumber
[color=orange]
}
:::danger
-
StatusCode: -1
- Description: Required fields can not be blank.
-
StatusCode: -2
- Description: Account exists.
-
StatusCode: -3
- Description: Account need Email.
-
StatusCode: -4
- Description: Login failed.
-
StatusCode: -5
- Description: Not found Account.
-
StatusCode: -6
- Description: Token Invalid.
-
StatusCode: -7
- Description: Add failure.
-
StatusCode: -8
- Description: Token remove error.
-
StatusCode: -9
- Description: Token Limit.
-
StatusCode: -10
- Description: Strong Password Not Good.
-
StatusCode: -11
- Description: Password is error.
-
StatusCode: -12
- Description: Password is same.
-
StatusCode: 0
- Description: Internal error :::
:::success
-
StatusCode:
- Description: Success Create Account.
-
StatusCode:
- Description: Success LogIn.
-
StatusCode:
- Description: Success Get Temporarily Token.
-
StatusCode:
- Description: Success Add Car ID to User.
-
StatusCode:
- Description: Success Get User Data.
-
StatusCode:
- Description: Success Return AccountHas.
-
StatusCode:
- Description: Success Get Car ID.
-
StatusCode:
- Description: Success Update User.
-
StatusCode:
- Description: Success Log Out.
:::
:::info
CPU | CPU平台 | Main Memory | OS |
---|---|---|---|
g1-small vCPU 1 core | Skylake | 1.7GB | CentOS 7 |
:::
https://docs.google.com/spreadsheets/d/1M9j7oy62Fs07Jb1v8tfRBY6pEuGoOqYFR7i1onzjrws/edit#gid=0
https://gitlab.com/denny0258/ntut_special_topic_2018_server.git