Skip to content
Draft
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
503 changes: 503 additions & 0 deletions api/proto/API.md

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions api/proto/hackathon/entities/answer.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
syntax = "proto3";

package hackathon.entities;

import "buf/validate/validate.proto";
import "hackathon/entities/question.proto";

option go_package = "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/entities";

message Answer {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

fix: Answer needs a user_id since the user_id is optional in ListParticipantsAnswers, otherwise it will unclear who answered the question. You can add the the user_id either here or in the ListParticpiantAnswersResponse.

string question_id = 1;
string value = 2;
QuestionType type = 3 [(buf.validate.field).enum.defined_only = true];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

suggestion: remove the answer type here as it can be derived from the question?

}
22 changes: 22 additions & 0 deletions api/proto/hackathon/entities/question.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
syntax = "proto3";

package hackathon.entities;

import "buf/validate/validate.proto";

option go_package = "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/entities";

enum QuestionType {
QUESTION_TYPE_UNSPECIFIED = 0;
QUESTION_TYPE_TEXT = 1;
QUESTION_TYPE_BOOL = 2;
}

message Question {
string id = 1;
string key = 2 [(buf.validate.field).string.pattern = "^[a-z][a-z0-9_]*$"];
string label = 3;
QuestionType type = 4 [(buf.validate.field).enum.defined_only = true];
bool mandatory = 5;
int32 order = 6;
}
20 changes: 20 additions & 0 deletions api/proto/hackathon/hackathon_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,36 @@ import "hackathon/messages/hackathon_svc/add_owner_request.proto";
import "hackathon/messages/hackathon_svc/add_owner_response.proto";
import "hackathon/messages/hackathon_svc/approve_participant_request.proto";
import "hackathon/messages/hackathon_svc/approve_participant_response.proto";
import "hackathon/messages/hackathon_svc/create_question_request.proto";
import "hackathon/messages/hackathon_svc/create_question_response.proto";
import "hackathon/messages/hackathon_svc/create_request.proto";
import "hackathon/messages/hackathon_svc/create_response.proto";
import "hackathon/messages/hackathon_svc/edit_question_request.proto";
import "hackathon/messages/hackathon_svc/edit_question_response.proto";
import "hackathon/messages/hackathon_svc/edit_request.proto";
import "hackathon/messages/hackathon_svc/edit_response.proto";
import "hackathon/messages/hackathon_svc/get_request.proto";
import "hackathon/messages/hackathon_svc/get_response.proto";
import "hackathon/messages/hackathon_svc/join_request.proto";
import "hackathon/messages/hackathon_svc/join_response.proto";
import "hackathon/messages/hackathon_svc/list_participant_answers_request.proto";
import "hackathon/messages/hackathon_svc/list_participant_answers_response.proto";
import "hackathon/messages/hackathon_svc/list_questions_request.proto";
import "hackathon/messages/hackathon_svc/list_questions_response.proto";
import "hackathon/messages/hackathon_svc/list_request.proto";
import "hackathon/messages/hackathon_svc/list_response.proto";
import "hackathon/messages/hackathon_svc/remove_owner_request.proto";
import "hackathon/messages/hackathon_svc/remove_owner_response.proto";
import "hackathon/messages/hackathon_svc/remove_participant_request.proto";
import "hackathon/messages/hackathon_svc/remove_participant_response.proto";
import "hackathon/messages/hackathon_svc/remove_question_request.proto";
import "hackathon/messages/hackathon_svc/remove_question_response.proto";
import "hackathon/messages/hackathon_svc/set_capabilities_request.proto";
import "hackathon/messages/hackathon_svc/set_capabilities_response.proto";
import "hackathon/messages/hackathon_svc/set_current_phase_request.proto";
import "hackathon/messages/hackathon_svc/set_current_phase_response.proto";
import "hackathon/messages/hackathon_svc/submit_answers_request.proto";
import "hackathon/messages/hackathon_svc/submit_answers_response.proto";

option go_package = "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon";

Expand All @@ -39,4 +51,12 @@ service HackathonService {
rpc RemoveParticipant(hackathon.messages.hackathon_svc.RemoveParticipantRequest) returns (hackathon.messages.hackathon_svc.RemoveParticipantResponse);
rpc AddOwner(hackathon.messages.hackathon_svc.AddOwnerRequest) returns (hackathon.messages.hackathon_svc.AddOwnerResponse);
rpc RemoveOwner(hackathon.messages.hackathon_svc.RemoveOwnerRequest) returns (hackathon.messages.hackathon_svc.RemoveOwnerResponse);
// Registration questions
rpc CreateQuestion(hackathon.messages.hackathon_svc.CreateQuestionRequest) returns (hackathon.messages.hackathon_svc.CreateQuestionResponse);
rpc EditQuestion(hackathon.messages.hackathon_svc.EditQuestionRequest) returns (hackathon.messages.hackathon_svc.EditQuestionResponse);
rpc RemoveQuestion(hackathon.messages.hackathon_svc.RemoveQuestionRequest) returns (hackathon.messages.hackathon_svc.RemoveQuestionResponse);
rpc ListQuestions(hackathon.messages.hackathon_svc.ListQuestionsRequest) returns (hackathon.messages.hackathon_svc.ListQuestionsResponse);
rpc SubmitAnswers(hackathon.messages.hackathon_svc.SubmitAnswersRequest) returns (hackathon.messages.hackathon_svc.SubmitAnswersResponse);
// Participant answers (admin)
rpc ListParticipantAnswers(hackathon.messages.hackathon_svc.ListParticipantAnswersRequest) returns (hackathon.messages.hackathon_svc.ListParticipantAnswersResponse);
Comment on lines +60 to +61

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

fix: The comment suggest that this service is admin only, but a participant should also have access to read his answers. Also waitlisted participants should be able to read what they answered.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yes, that's what's intended, the comment is wrong.

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
syntax = "proto3";

package hackathon.messages.hackathon_svc;

import "buf/validate/validate.proto";
import "hackathon/entities/question.proto";

option go_package = "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svc";

message CreateQuestionRequest {
string hackathon_id = 1 [(buf.validate.field).string.uuid = true];
string key = 2 [
(buf.validate.field).string.min_len = 1,
(buf.validate.field).string.max_len = 64,
(buf.validate.field).string.pattern = "^[a-z][a-z0-9_]*$"
];
string label = 3 [
(buf.validate.field).string.min_len = 1,
(buf.validate.field).string.max_len = 255
];
hackathon.entities.QuestionType type = 4 [(buf.validate.field).enum.defined_only = true];
bool mandatory = 5;
int32 order = 6;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
syntax = "proto3";

package hackathon.messages.hackathon_svc;

option go_package = "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svc";

message CreateQuestionResponse {
string question_id = 1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
syntax = "proto3";

package hackathon.messages.hackathon_svc;

import "buf/validate/validate.proto";
import "hackathon/entities/question.proto";

option go_package = "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svc";

message EditQuestionRequest {
string hackathon_id = 1 [(buf.validate.field).string.uuid = true];
string question_id = 2 [(buf.validate.field).string.uuid = true];
optional string label = 3 [
(buf.validate.field).string.min_len = 1,
(buf.validate.field).string.max_len = 255
];
optional hackathon.entities.QuestionType type = 4;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

suggestion: refuse a type change once an answer exists for a question.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yes, that is planned.

optional bool mandatory = 5;
optional int32 order = 6;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
syntax = "proto3";

package hackathon.messages.hackathon_svc;

option go_package = "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svc";

message EditQuestionResponse {}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ syntax = "proto3";

package hackathon.messages.hackathon_svc;

import "buf/validate/validate.proto";
import "hackathon/entities/answer.proto";

option go_package = "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svc";

message JoinRequest {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

question: what happens to the answers on a second join call? Or can it only be issued once? Did we consider this in the backend?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

second join call overwrites the first.

string hackathon_id = 1;
string hackathon_id = 1 [(buf.validate.field).string.uuid = true];
repeated hackathon.entities.Answer answers = 2;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
syntax = "proto3";

package hackathon.messages.hackathon_svc;

import "buf/validate/validate.proto";

option go_package = "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svc";

message ListParticipantAnswersRequest {
string hackathon_id = 1 [(buf.validate.field).string.uuid = true];
optional string user_id = 2 [(buf.validate.field).string.uuid = true];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
syntax = "proto3";

package hackathon.messages.hackathon_svc;

import "hackathon/entities/answer.proto";

option go_package = "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svc";

message ListParticipantAnswersResponse {
repeated hackathon.entities.Answer answers = 1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
syntax = "proto3";

package hackathon.messages.hackathon_svc;

import "buf/validate/validate.proto";

option go_package = "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svc";

message ListQuestionsRequest {
string hackathon_id = 1 [(buf.validate.field).string.uuid = true];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
syntax = "proto3";

package hackathon.messages.hackathon_svc;

import "hackathon/entities/question.proto";

option go_package = "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svc";

message ListQuestionsResponse {
repeated hackathon.entities.Question questions = 1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
syntax = "proto3";

package hackathon.messages.hackathon_svc;

import "buf/validate/validate.proto";

option go_package = "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svc";

message RemoveQuestionRequest {
string hackathon_id = 1 [(buf.validate.field).string.uuid = true];
string question_id = 2 [(buf.validate.field).string.uuid = true];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
syntax = "proto3";

package hackathon.messages.hackathon_svc;

option go_package = "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svc";

message RemoveQuestionResponse {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
syntax = "proto3";

package hackathon.messages.hackathon_svc;

import "buf/validate/validate.proto";
import "hackathon/entities/answer.proto";

option go_package = "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svc";

message SubmitAnswersRequest {
string hackathon_id = 1 [(buf.validate.field).string.uuid = true];
repeated hackathon.entities.Answer answers = 2;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

question: does this overwrite all previous answers or only the ones returned?

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
syntax = "proto3";

package hackathon.messages.hackathon_svc;

option go_package = "github.com/swissdatasciencecenter/hackagon/components/backend/internal/proto/hackathon/messages/hackathon_svc";

message SubmitAnswersResponse {}
61 changes: 61 additions & 0 deletions components/backend/Schema.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# Database Schema

## Answer

A participant's answer to a registration question. One answer per user per question.

### Fields

| Column | Type | Required | Unique | Immutable | Default | Description |
|--------|------|----------|--------|-----------|---------|-------------|
| `question_id` | uuid.UUID | yes | no | no | no | The question this answer belongs to. |
| `user_id` | uuid.UUID | yes | no | no | no | The user who submitted this answer. |
| `value` | string | yes | no | no | no | The answer value. For bool questions, stored as "true" or "false". |
| `type` | enum(text, bool) | yes | no | no | no | The type of the question (for readability when reading answers). |
| `created_at` | time.Time | yes | no | yes | yes | Timestamp when the answer was first submitted. |
| `updated_at` | time.Time | yes | no | no | yes | Timestamp of the last update. |

### Relationships

| Edge | Target | Relation | Inverse | Required | Description |
|------|--------|----------|---------|----------|-------------|
| `question` | Question | M2O | yes | yes | The question this answer belongs to. |
| `user` | User | M2O | yes | yes | The user who submitted this answer. |

### Indexes

- `question_id, user_id` *(unique)*

## Hackathon

A hackathon event containing tracks, projects, phases, and participants.
Expand Down Expand Up @@ -28,6 +54,7 @@ A hackathon event containing tracks, projects, phases, and participants.
| `phases` | Phase | O2M | no | no | Temporal phases (e.g. ideation, hacking, judging). |
| `state` | HackathonState | O2O | no | no | Configuration state for this hackathon. |
| `vote_categories` | VoteCategory | O2M | no | no | Voting categories scoped to this hackathon. |
| `questions` | Question | O2M | no | no | Registration questions configured for this hackathon. |
| `owners` | User | M2M | no | no | Users who are owners of this hackathon (in addition to the creator). |
| `creator` | User | M2O | yes | yes | The user who created this hackathon. |
| `modifier` | User | M2O | yes | yes | The user who last modified this hackathon. |
Expand Down Expand Up @@ -184,6 +211,37 @@ A project proposal within a hackathon track.
- `title`
- `status`

## Question

A registration question configured by a hackathon owner.

### Fields

| Column | Type | Required | Unique | Immutable | Default | Description |
|--------|------|----------|--------|-----------|---------|-------------|
| `hackathon_id` | uuid.UUID | yes | no | no | no | The hackathon this question belongs to. |
| `key` | string | yes | no | no | no | Unique identifier for the question within the hackathon. |
| `label` | string | yes | no | no | no | Display label for the question. |
| `type` | enum(text, bool) | yes | no | no | no | The type of answer expected from participants. |
| `mandatory` | bool | yes | no | no | yes | Whether the participant must answer this question to join. |
| `order` | int | yes | no | no | yes | Display order; lower values appear first. |
| `created_at` | time.Time | yes | no | yes | yes | Timestamp when the question was created. |
| `modified_at` | time.Time | yes | no | no | yes | Timestamp of the last modification. |

### Relationships

| Edge | Target | Relation | Inverse | Required | Description |
|------|--------|----------|---------|----------|-------------|
| `hackathon` | Hackathon | M2O | yes | yes | The hackathon this question belongs to. |
| `creator` | User | M2O | yes | yes | The user who created the question. |
| `modifier` | User | M2O | yes | yes | The user who last modified the question. |
| `answers` | Answer | O2M | no | no | Answers submitted by participants for this question. |

### Indexes

- `key, hackathon_id` *(unique)*
- `order`

## Submission

A versioned submission from a team for a project.
Expand Down Expand Up @@ -317,6 +375,9 @@ An authenticated user, synced from Keycloak on first login.
| `modified_submissions` | Submission | O2M | no | no | Submissions this user last modified. |
| `created_tracks` | Track | O2M | no | no | Tracks this user created. |
| `modified_tracks` | Track | O2M | no | no | Tracks this user last modified. |
| `created_questions` | Question | O2M | no | no | Registration questions this user created. |
| `modified_questions` | Question | O2M | no | no | Registration questions this user last modified. |
| `created_answers` | Answer | O2M | no | no | Registration answers this user submitted. |
| `modified_states` | HackathonState | O2M | no | no | Hackathon settings this user last modified. |
| `preferred_projects` | Project | M2M | no | no | Projects this user has marked as preferred. |
| `votes` | Vote | O2M | no | no | Votes cast by this user. |
Expand Down
Loading
Loading