Initial commit

This commit is contained in:
Albert
2025-12-11 02:36:03 +04:00
parent 16e825a0e7
commit 2bcdfc93d6
45 changed files with 9304 additions and 78 deletions
+74
View File
@@ -0,0 +1,74 @@
syntax = "proto3";
package auth;
option go_package = "pkg/api/auth";
service AuthService {
rpc SignUp(SignUpRequest) returns (SignUpResponse);
rpc SignIn(SignInRequest) returns (SignInResponse);
rpc GetMe(GetMeRequest) returns (GetMeResponse);
rpc GetUser(GetUserRequest) returns (GetUserResponse);
rpc GetMyStat(GetMyStatRequest) returns (GetMyStatResponse);
rpc GetLeaderboard(GetLeaderboardRequest) returns (GetLeaderboardResponse);
}
message SignUpRequest {
string email = 1;
string username = 2;
string password = 3;
}
message SignUpResponse {
string token = 1;
}
message SignInRequest {
string email = 1;
string password = 2;
}
message SignInResponse {
string token = 1;
}
message GetMeRequest {}
message GetMeResponse {
User user = 1;
}
message GetUserRequest {
string user_id = 1;
}
message GetUserResponse {
User user = 1;
}
message GetMyStatRequest {}
message GetMyStatResponse {
Stat stat = 1;
}
message GetLeaderboardRequest {}
message GetLeaderboardResponse {
repeated User users = 1;
}
message User {
optional string id = 1;
string email = 2;
string username = 3;
optional string avatar = 4;
string created_at = 5;
repeated UserAchievement achievements = 6;
}
message UserAchievement {
string name = 1;
string description = 2;
string icon = 3;
string received_at = 4;
}
message Stat {
int32 total_attempts = 1;
int32 solved_tasks = 2;
}
+52
View File
@@ -0,0 +1,52 @@
syntax = "proto3";
package competition;
option go_package = "pkg/api/competition";
service CompetitionService {
rpc GetCompetition(GetCompetitionRequest) returns (GetCompetitionResponse);
rpc ListCompetitions(ListCompetitionsRequest) returns (ListCompetitionsResponse);
rpc ChangeCompetitionState(ChangeCompetitionStateRequest) returns (ChangeCompetitionStateResponse);
}
message GetCompetitionRequest {
string competition_id = 1;
}
message GetCompetitionResponse {
Competition competition = 1;
}
message ListCompetitionsRequest {
bool is_participating = 1;
}
message ListCompetitionsResponse {
repeated Competition competitions = 1;
}
message ChangeCompetitionStateRequest {
string competition_id = 1;
CompetitionState state = 2;
}
message ChangeCompetitionStateResponse {
CompetitionState state = 1;
}
message Competition {
string id = 1;
CompetitionState state = 2;
string title = 3;
string description = 4;
optional string image_url = 5;
optional string end_date = 6;
optional string start_date = 7;
string type = 8;
string participation_type = 9;
}
enum CompetitionState {
COMPETITION_STATE_UNSPECIFIED = 0;
COMPETITION_STATE_NOT_STARTED = 1;
COMPETITION_STATE_STARTED = 2;
COMPETITION_STATE_FINISHED = 3;
}
+117
View File
@@ -0,0 +1,117 @@
syntax = "proto3";
package task;
option go_package = "pkg/api/task";
service TaskService {
rpc StartCompetition(StartCompetitionRequest) returns (StartCompetitionResponse);
rpc GetCompetitionTasks(GetCompetitionTasksRequest) returns (GetCompetitionTasksResponse);
rpc GetTask(GetTaskRequest) returns (GetTaskResponse);
rpc SubmitTask(SubmitTaskRequest) returns (SubmitTaskResponse);
rpc GetSubmissionsHistory(GetSubmissionsHistoryRequest) returns (GetSubmissionsHistoryResponse);
rpc GetTaskAttachments(GetTaskAttachmentsRequest) returns (GetTaskAttachmentsResponse);
rpc GetCompetitionResults(GetCompetitionResultsRequest) returns (GetCompetitionResultsResponse);
}
message StartCompetitionRequest {
string competition_id = 1;
}
message StartCompetitionResponse {
string status = 1;
}
message GetCompetitionTasksRequest {
string competition_id = 1;
}
message GetCompetitionTasksResponse {
repeated Task tasks = 1;
}
message GetTaskRequest {
string competition_id = 1;
string task_id = 2;
}
message GetTaskResponse {
Task task = 1;
}
message SubmitTaskRequest {
string competition_id = 1;
string task_id = 2;
bytes content = 3;
}
message SubmitTaskResponse {
string submission_id = 1;
}
message GetSubmissionsHistoryRequest {
string competition_id = 1;
string task_id = 2;
}
message GetSubmissionsHistoryResponse {
repeated HistorySubmission submissions = 1;
}
message GetTaskAttachmentsRequest {
string competition_id = 1;
string task_id = 2;
}
message GetTaskAttachmentsResponse {
repeated TaskAttachment attachments = 1;
}
message GetCompetitionResultsRequest {
string competition_id = 1;
}
message GetCompetitionResultsResponse {
repeated TaskStatus results = 1;
}
message Task {
optional string id = 1;
string competition = 2;
string title = 3;
string description = 4;
int32 in_competition_position = 5;
optional int32 points = 6;
optional int32 max_attempts = 7;
TaskType type = 8;
TaskStatusEnum status = 9;
}
enum TaskType {
TASK_TYPE_UNSPECIFIED = 0;
TASK_TYPE_INPUT = 1;
TASK_TYPE_CHECKER = 2;
TASK_TYPE_REVIEW = 3;
}
enum TaskStatusEnum {
TASK_STATUS_UNSPECIFIED = 0;
TASK_STATUS_NOT_SUBMITTED = 1;
TASK_STATUS_SENT = 2;
TASK_STATUS_CHECKING = 3;
TASK_STATUS_CHECKED = 4;
}
message HistorySubmission {
optional string id = 1;
TaskStatusEnum status = 2;
optional int32 earned_points = 3;
string timestamp = 4;
string content = 5;
}
message TaskAttachment {
optional string id = 1;
string file = 2;
bool public = 3;
}
message TaskStatus {
string task_name = 1;
int32 result = 2;
int32 max_points = 3;
int32 position = 4;
}