diff --git a/Makefile b/Makefile index b6d1a92..c8fd60a 100644 --- a/Makefile +++ b/Makefile @@ -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 \ @@ -28,7 +33,8 @@ eq = $(if $(or $(1),$(2)),$(and $(findstring $(1),$(2)),\ start \ stop \ rm \ - release + release \ + coverage init-repo: cargo install --version="~0.8" sqlx-cli --no-default-features --features rustls,postgres @@ -52,7 +58,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) @@ -98,4 +104,8 @@ prepare-check: # Usage : # make precommit +coverage: + cargo llvm-cov clean --workspace --html --output-dir=coverage + cargo llvm-cov --all-features --workspace --no-clean --html --output-dir=coverage --open + precommit : fmt clippy test prepare-check diff --git a/cpast_api/README.md b/cpast_api/README.md index 701aeed..ad0c941 100644 --- a/cpast_api/README.md +++ b/cpast_api/README.md @@ -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 +``` + diff --git a/cpast_api/src/routes/api/v1/evaluate/mod.rs b/cpast_api/src/routes/api/v1/evaluate/mod.rs index 0d6566b..6cb1296 100644 --- a/cpast_api/src/routes/api/v1/evaluate/mod.rs +++ b/cpast_api/src/routes/api/v1/evaluate/mod.rs @@ -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, @@ -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(), }])))]