From ded2657800470c17bdc4a8b5e3e551729e1b4dbd Mon Sep 17 00:00:00 2001 From: Lab Rat Date: Sat, 26 Oct 2024 16:52:56 +0530 Subject: [PATCH] chore: arch diagram --- Makefile | 14 +++++- README.md | 16 +++---- cpast_api/README.md | 50 +++++++++++++++++++++ cpast_api/src/routes/api/v1/evaluate/mod.rs | 4 ++ 4 files changed, 74 insertions(+), 10 deletions(-) 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/README.md b/README.md index aeb9427..7df1d7f 100644 --- a/README.md +++ b/README.md @@ -74,14 +74,14 @@ We welcome you to the cpast mono-repo, where you can find all the tools and comp | Component | Description | Status | |--------------|-------------------------------------------------------------------------------------------------------|-----------------------| -| cpast_api | Backend for cpast, handles server-side operations and API requests. | 🚧 Work in Progress | -| cpast | CLI interface for cpast, used locally to run tests and generate inputs. | ✅ Active | -| ccode_runner | Runs arbitrary program code on local devices/server side, compiles/interprets code, and sends output. | 🔄 Needs Change | -| cpastord | Integration of cpast for Discord, allowing users to run cpast commands within Discord. | ❌ Abandoned | -| clex | Parser and generator for the clex language, generates random input for programs based on clex syntax. | ✅ Active | -| cscrapper | Scrapes question descriptions from competitive programming sites like Codeforces and CodeChef. | 🔄 Needs Improvement | -| clex_llm | Generates clex language from input format, constraints, and problem descriptions using LLM. | 🤔 Under Consideration| +| [cpast_api](./cpast_api/README.md) | Backend for cpast, handles server-side operations and API requests. | 🚧 Work in Progress | +| [cpast](./cpast/README.md) | CLI interface for cpast, used locally to run tests and generate inputs. | ✅ Active | +| [ccode_runner](./ccode_runner/README.md) | Runs arbitrary program code on local devices/server side, compiles/interprets code, and sends output. | 🔄 Needs Change | +| [cpastord](./cpastord/README.md) | Integration of cpast for Discord, allowing users to run cpast commands within Discord. | ❌ Abandoned | +| [clex](./clex/README.md) | Parser and generator for the clex language, generates random input for programs based on clex syntax. | ✅ Active | +| [cscrapper](./cscrapper/README.md) | Scrapes question descriptions from competitive programming sites like Codeforces and CodeChef. | 🔄 Needs Improvement | +| [clex_llm](./clex_llm/README.md) | Generates clex language from input format, constraints, and problem descriptions using LLM. | 🤔 Under Consideration| ## Meta -* [cpast\_llm](https://github.com/rootCircle/cpast_llm) +* Archived effort - [cpast\_llm](https://github.com/rootCircle/cpast_llm) 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(), }])))]