Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
67877bf
important commit
Feb 18, 2026
628c1fa
broken orc
Feb 18, 2026
2b3e5ee
versios
KarmoSaviauk Feb 18, 2026
bcf4b51
test
Feb 18, 2026
1dacd80
fix
Feb 18, 2026
2e884a0
added suggestions
Feb 25, 2026
59a5960
fixed suggestions
Feb 25, 2026
af02be9
transaction_verification
KarmoSaviauk Feb 25, 2026
504950a
transaction_verification merge
KarmoSaviauk Feb 25, 2026
453a7a6
test
Feb 25, 2026
0d389b3
Merge branch 'master' of https://github.com/Karmosav/ds-practice-2025
Feb 25, 2026
a45a75f
broken ai
Feb 25, 2026
4b7524d
AI suggestions
KarmoSaviauk Feb 25, 2026
b6c321c
Added AI suggestion based on selected books
Feb 25, 2026
6367171
comments and fixes
KarmoSaviauk Feb 26, 2026
c8570c1
broken ai
MatiasJurgenson Feb 26, 2026
6188b04
working fraud ai
Feb 26, 2026
c40c674
Delete .vscode settings directory
RainerKoiv Mar 1, 2026
80caec1
small fixes
Mar 1, 2026
e69eec1
small fixes
Mar 1, 2026
f846546
Update README to include system diagram
RainerKoiv Mar 1, 2026
48f173d
logging for suggested books
Mar 1, 2026
d6b3eef
logging for suggested books
Mar 1, 2026
7f857dc
Update README.md
Karmosav Mar 1, 2026
77988fa
broken flow
Mar 11, 2026
86688ed
new workflow dummy
KarmoSaviauk Mar 11, 2026
8598db9
added back AI logic + minor reliability fixes
Mar 11, 2026
e1b1db7
add comments
Mar 11, 2026
e336525
linux test
MatiasJurgenson Mar 13, 2026
1815d9b
add broadcast
Mar 15, 2026
e172291
changed event letters to descriptive names
Mar 17, 2026
3cacd2f
vector clock to 0 and remove increment from notify functions
Mar 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
__pycache__
__pycache__
.env
.vscode
65 changes: 55 additions & 10 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ services:
# Access the application at http://localhost:8080
- "8080:80"
volumes:
# Mount the frontend directory
- ./frontend/src:/usr/share/nginx/html
# Mount the frontend directory (exclusive relabel for this container)
- ./frontend/src:/usr/share/nginx/html:Z

orchestrator:
build:
# Use the current directory as the build context
Expand All @@ -31,10 +32,13 @@ services:
# Check app.py in the orchestrator directory to see how this is used
- PYTHONFILE=/app/orchestrator/src/app.py
volumes:
# Mount the utils directory in the current directory to the /app/utils directory in the container
- ./utils:/app/utils
# Mount the orchestrator/src directory in the current directory to the /app/orchestrator/src directory in the container
- ./orchestrator/src:/app/orchestrator/src
# Shared utils (allow multiple containers) — use :z
- ./utils:/app/utils:z
# Orchestrator source (exclusive)
- ./orchestrator/src:/app/orchestrator/src:Z
depends_on:
- fraud_detection
- suggestions
fraud_detection:
build:
# Use the current directory as the build context
Expand All @@ -53,7 +57,48 @@ services:
# Check app.py in the fraud_detection directory to see how this is used
- PYTHONFILE=/app/fraud_detection/src/app.py
volumes:
# Mount the utils directory in the current directory to the /app/utils directory in the container
- ./utils:/app/utils
# Mount the fraud_detection/src directory in the current directory to the /app/fraud_detection/src directory in the container
- ./fraud_detection/src:/app/fraud_detection/src
# Shared utils (allow multiple containers) — use :z
- ./utils:/app/utils:z
# Fraud source (exclusive)
- ./fraud_detection/src:/app/fraud_detection/src:Z
- ./fraud_detection/ai:/app/fraud_detection/ai:Z
suggestions:
build:
context: ./
dockerfile: ./suggestions/Dockerfile
ports:
- 50053:50053
env_file:
- ./.env
environment:
- PYTHONUNBUFFERED=TRUE
- PYTHONFILE=/app/suggestions/src/app.py
- GEMINI_API_KEY=${GEMINI_API_KEY}
volumes:
# Shared utils (allow multiple containers) — use :z
- ./utils:/app/utils:z
# Suggestions source (exclusive)
- ./suggestions/src:/app/suggestions/src:Z

transaction_verification:
build:
# Use the current directory as the build context
# This allows us to access the files in the current directory inside the Dockerfile
context: ./
# Use the Dockerfile in the transaction_verification directory
dockerfile: ./transaction_verification/Dockerfile
ports:
# Expose port 50052 on the host, and map port 50052 of the container to port 50052 on the host
- 50052:50052
environment:
# Pass the environment variables to the container
# The PYTHONUNBUFFERED environment variable ensures that the output from the application is logged to the console
- PYTHONUNBUFFERED=TRUE
# The PYTHONFILE environment variable specifies the absolute entry point of the application
# Check app.py in the transaction_verification directory to see how this is used
- PYTHONFILE=/app/transaction_verification/src/app.py
volumes:
# Shared utils (allow multiple containers) — use :z
- ./utils:/app/utils:z
# Transaction verification source (exclusive)
- ./transaction_verification/src:/app/transaction_verification/src:Z
15 changes: 15 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# Documentation

This folder should contain your documentation, explaining the structure and content of your project. It should also contain your diagrams, explaining the architecture. The recommended writing format is Markdown.

If you want to rund on local computer run:
pip install grpcio==1.70.0 grpcio-tools==1.70.0 protobuf==5.29.6 watchdog==6.0.0


## System Diagram

<img width="8192" height="3581" alt="image" src="https://github.com/user-attachments/assets/0acd86b9-2655-4524-8ffb-06b62690c1c5" />



## Architecture diagram

<img width="1527" height="347" alt="image" src="https://github.com/user-attachments/assets/8de78f86-4f65-4843-a721-fcdd4b3c092c" />

3 changes: 3 additions & 0 deletions fraud_detection/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ COPY ./fraud_detection/requirements.txt .
# Install the Python dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Ensure Python can import from /app (project root)
ENV PYTHONPATH=/app

# Set the command to run the application
CMD python utils/other/hotreload.py "fraud_detection/src/app.py"
39 changes: 39 additions & 0 deletions fraud_detection/ai/data_gen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import pandas as pd
import numpy as np
import random

np.random.seed(42)
random.seed(42)

n_samples = 1000

data = []

for _ in range(n_samples):
price = round(np.random.uniform(10, 2000), 2)

# Random credit card number (some intentionally start with 999)
if np.random.rand() < 0.05:
credit_card = "999" + "".join([str(np.random.randint(0, 10)) for _ in range(13)])
else:
credit_card = "".join([str(np.random.randint(0, 10)) for _ in range(16)])

# Fraud rule
is_fraud = 1 if (price > 1000 or credit_card.startswith("999")) else 0

data.append([
price,
credit_card,
is_fraud
])

df = pd.DataFrame(data, columns=[
"price",
"credit_card",
"is_fraud"
])

df.to_csv("./fraud_detection/ai/transactions.csv", index=False)

print("transactions.csv created successfully.")
print(df.head())
Binary file added fraud_detection/ai/fraud_model.joblib
Binary file not shown.
49 changes: 49 additions & 0 deletions fraud_detection/ai/train.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.metrics import classification_report, roc_auc_score
from sklearn.ensemble import RandomForestClassifier
from sklearn.utils.class_weight import compute_class_weight

import joblib

# Load dataset (example: credit card transactions)
df = pd.read_csv("./fraud_detection/ai/transactions.csv")

# Features and label
X = df.drop("is_fraud", axis=1)
y = df["is_fraud"]

# Train/test split (stratified for imbalance)
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.2, stratify=y, random_state=42
)

# Handle class imbalance via class weights
class_weights = compute_class_weight(
class_weight="balanced",
classes=np.unique(y_train),
y=y_train
)
weights = {0: class_weights[0], 1: class_weights[1]}

# Model
model = RandomForestClassifier(
n_estimators=200,
max_depth=10,
class_weight=weights,
random_state=42,
n_jobs=-1
)

model.fit(X_train, y_train)

# Predictions
y_pred = model.predict(X_test)
y_proba = model.predict_proba(X_test)[:, 1]

print(classification_report(y_test, y_pred))
print("ROC-AUC:", roc_auc_score(y_test, y_proba))

joblib.dump(model, "./fraud_detection/ai/fraud_model.joblib")

Loading