Skip to content

Commit aed15f9

Browse files
authored
Hints (#8)
* refactor 1 * refactor 2 * refactor * logging * add identifieres from rules * bug fix * api update * checking for correct trees * sea-orm-generation * add missing rules * tipps * hints done * format & prints * changed to drawer * no static frontend anymore
1 parent 51e3602 commit aed15f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2860
-2419
lines changed

.github/workflows/publish.yaml

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,34 @@ jobs:
2626
username: ${{ github.actor }}
2727
password: ${{ secrets.GITHUB_TOKEN }}
2828

29-
- name: Extract metadata from event
29+
- name: Extract metadata for frontend
30+
id: meta-frontend
3031
uses: docker/metadata-action@v5
31-
id: meta
3232
with:
33-
images: ghcr.io/${{ github.repository }}
33+
images: ghcr.io/${{ github.repository }}/frontend
3434

35-
- name: Build and push
35+
- name: Extract metadata for backend
36+
id: meta-backend
37+
uses: docker/metadata-action@v5
38+
with:
39+
images: ghcr.io/${{ github.repository }}/backend
40+
41+
- name: Build and push frontend image
42+
uses: docker/build-push-action@v6
43+
with:
44+
context: frontend
45+
file: frontend/Dockerfile
46+
push: true
47+
tags: ${{ steps.meta-frontend.outputs.tags }}
48+
labels: ${{ steps.meta-frontend.outputs.labels }}
49+
secrets: |
50+
API_URL=${{secrets.NEXT_PUBLIC_API_URL}}
51+
52+
- name: Build and push backend image
3653
uses: docker/build-push-action@v6
3754
with:
38-
context: .
55+
context: backend
56+
file: backend/Dockerfile
3957
push: true
40-
tags: ${{ steps.meta.outputs.tags }}
41-
labels: ${{ steps.meta.outputs.labels }}
58+
tags: ${{ steps.meta-backend.outputs.tags }}
59+
labels: ${{ steps.meta-backend.outputs.labels }}

Dockerfile

Lines changed: 0 additions & 47 deletions
This file was deleted.

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@ This project consists of three parts: Frontend, Backend and Database.
2222
- Run ```npm run dev```
2323

2424
### Database Migration
25-
If you change the database schema you need to manually push the file again to the database. Additionally, in the backend run
26-
25+
If you change the database schema you need to manually push the file again to the database.
2726
```shell
2827
npx prisma db push --schema ../db/schema.prisma --database-url ...
2928
```
30-
to update the rust crate with the new database structure.
29+
Additionally, in the backend run to update the rust crate with the new database structure.
30+
```shell
31+
sea-orm-cli generate entity -o ./src/db/ --database-url ...
32+
```
33+
You may need to install ```sea-orm-cli```.
3134

3235
### API changes
3336
To be able to use new or changed endpoints in the frontend the following steps must be done:

backend/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ utoipauto = "=0.3.0-alpha.1"
2727
tower = { version = "0.5.2", optional = true }
2828
log = "0.4.26"
2929
env_logger = "0.11.6"
30+
tracing = "0.1.41"
3031

3132
[features]
3233
static = ["tower-http/fs", "tower"]

backend/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM rust:alpine3.19 AS api-builder
2+
3+
WORKDIR /app
4+
RUN apk add --no-cache musl-dev z3 cmake g++ make python3 curl clang16-libclang z3-dev
5+
6+
COPY backend .
7+
ENV RUSTFLAGS='-C target-feature=-crt-static'
8+
# RUN cargo build --release --features static
9+
RUN cargo build --release
10+
11+
12+
FROM alpine:3.19 AS backend
13+
14+
WORKDIR /app
15+
COPY --from=api-builder /app/target/release/naturalDeduction ./server
16+
RUN apk add --no-cache z3 z3-dev
17+
18+
EXPOSE 8000
19+
20+
CMD [ "./server" ]

backend/src/api/exercise_models.rs

Lines changed: 0 additions & 37 deletions
This file was deleted.

backend/src/api/formula_models.rs

Lines changed: 0 additions & 108 deletions
This file was deleted.

backend/src/api/mod.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
pub mod exercise_models;
2-
pub mod formula_models;
31
pub mod models;
4-
pub mod normalize;
52
pub mod routes;
6-
pub mod rule_models;
7-
pub mod utils;
83

94
use axum::routing::{get, post};
105
use axum::Router;
@@ -20,6 +15,8 @@ pub fn get_router(state: &AppState) -> Router {
2015
.route("/parse", post(routes::parse))
2116
.route("/rules", get(routes::all_rules))
2217
.route("/check", post(routes::check))
18+
.route("/statement/hint", post(routes::get_tipp))
19+
.route("/add_tree", post(routes::add_tree))
2320
.route("/exercise/{id}/feedback", post(routes::post_feedback))
2421
// .route("/tree", post(routes::add_tree))
2522
.with_state(state.clone())

backend/src/api/models.rs

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,40 @@
11
use serde::{Deserialize, Serialize};
2-
use utoipa::{IntoParams, ToSchema};
2+
use utoipa::ToSchema;
3+
use uuid::Uuid;
34

4-
use super::{
5-
formula_models::{Formula, Statement},
6-
rule_models::Rules,
7-
};
5+
use utoipa::IntoParams;
6+
7+
use crate::lib::derivation::{formula::Formula, statement::Statement};
8+
use crate::lib::rule::Rules;
9+
10+
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, PartialEq, Eq, PartialOrd, Ord)]
11+
pub struct CreateExerciseRequest {
12+
pub lhs: Vec<Formula>,
13+
pub rhs: Formula,
14+
}
15+
16+
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
17+
pub struct Exercise {
18+
pub id: Uuid,
19+
pub exercise: Statement,
20+
pub likes: i32,
21+
pub dislikes: i32,
22+
pub difficulty: f64,
23+
}
24+
25+
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
26+
pub struct Node {
27+
pub name: Uuid,
28+
pub statement: Statement,
29+
pub rule: Rules,
30+
pub premisses: Vec<Uuid>,
31+
}
32+
33+
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
34+
pub struct CreateTreeRequest {
35+
pub nodes: Vec<Node>,
36+
pub root_id: Uuid,
37+
}
838

939
#[derive(Serialize, Deserialize, Debug, Clone, ToSchema, IntoParams)]
1040
pub struct FormulaMapping {
@@ -31,3 +61,14 @@ pub struct Feedback {
3161
pub like: bool,
3262
pub difficulty: Option<u32>,
3363
}
64+
65+
#[derive(Serialize, Deserialize, Debug, Clone, ToSchema, IntoParams)]
66+
pub struct ParseParams {
67+
pub formula: String,
68+
}
69+
70+
#[derive(Serialize, Deserialize, Debug, Clone, ToSchema, IntoParams)]
71+
pub struct Tipp {
72+
pub rule: Rules,
73+
pub premisses: Vec<Statement>,
74+
}

0 commit comments

Comments
 (0)