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 27, 2024
1 parent 846e4ee commit ded2657
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 10 deletions.
14 changes: 12 additions & 2 deletions 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 All @@ -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
Expand All @@ -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)

Expand Down Expand Up @@ -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
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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 ded2657

Please sign in to comment.