Skip to content

Commit

Permalink
chore: arch diagram
Browse files Browse the repository at this point in the history
  • Loading branch information
rootCircle committed Oct 26, 2024
1 parent 846e4ee commit 26c1d5c
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ eq = $(if $(or $(1),$(2)),$(and $(findstring $(1),$(2)),\
#

.PHONY : \
init-repo \
migrate-run \
migrate-create \
prepare \
prepare-check \
doc \
fmt \
clippy \
Expand Down Expand Up @@ -52,7 +57,7 @@ doc :
ifeq ($(clean),yes)
@rm -rf target/doc/
endif
cargo doc --all-features --no-deps\
SQLX_OFFLINE=true cargo doc --all-features --no-deps\
$(if $(call eq,$(private),no),,--document-private-items) \
$(if $(call eq,$(open),no),,--open)

Expand Down
50 changes: 50 additions & 0 deletions cpast_api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,53 @@ Launch `cargo`:
```bash
cargo test
```

## Architecture

### Workflow

```mermaid
graph TD
A[User Interface] -->|Submits Code| B[API Layer]
B -->|Enqueues Task| D[Task Queue: RabbitMQ/Kafka]
D -->|Distributes Tasks| E[Worker Nodes]
E -->|Requests Compilation and Execution| C1[Code Runner]
subgraph Docker Container
C1[Code Runner]
C2[Family of Compilers]
end
C1 -->|Returns Output| E
C1 -->|Uses| C2
E -->|Sends Result via WebSocket| B
B -->|WebSocket Connection| A
subgraph Cache Layer
H[Redis] -->|Cached Response| B
end
C1 -->|Task Results| H
```

### High level architecture


```mermaid
architecture-beta
group api(cloud)[API]
group docker(cloud)[Docker container] in api
service redis(database)[Redis Cache] in api
service kafka(server)[Kafka or RabbitMQ] in api
service server(internet)[Server] in api
service code_runner(server)[Code Runner] in docker
service family_of_compilers(disk)[Family of Compilers] in docker
server:R -- L:redis
server:T -- B:kafka
kafka:R -- L:code_runner
code_runner:R -- L:family_of_compilers
code_runner:T -- B:redis
```

4 changes: 4 additions & 0 deletions cpast_api/src/routes/api/v1/evaluate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ pub(crate) struct EvaluateCodeApiv1;

#[derive(Serialize, ToSchema)]
struct EvaluateCodeInputDiff {
#[schema(example = "world")]
input: String,

#[schema(example = "Hello, world!")]
expected_output: String,

Expand All @@ -34,6 +37,7 @@ struct EvaluateCodeResponse {
has_output_matched: bool,

#[schema(example = json!(Vec::from([EvaluateCodeInputDiff {
input: "world".to_string(),
expected_output: "Hello, world!".to_string(),
actual_output: "Hello, worldd!".to_string(),
}])))]
Expand Down

0 comments on commit 26c1d5c

Please sign in to comment.