Skip to content

Commit 1bfe52e

Browse files
committed
refactor: Implement feature-sliced architecture for workflows, centralize application constants, and enhance developer setup script.
1 parent 04a2ef3 commit 1bfe52e

18 files changed

Lines changed: 539 additions & 319 deletions

backend/jest.config.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
module.exports = {
22
testEnvironment: "node",
3-
setupFilesAfterEnv: ["<rootDir>/src/tests/setup.ts"],
43
transform: {
54
"^.+\\.(t|j)sx?$": ["@swc/jest"],
65
},
76
moduleNameMapper: {
87
"^@/(.*)$": "<rootDir>/src/$1",
9-
"^@/(.*)$": "<rootDir>/src/$1",
108
},
119
testMatch: ["**/*.test.ts"],
1210
verbose: true,

backend/src/tests/setup.ts

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

dev.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,44 @@
11
#!/bin/bash
2+
3+
# Function to handle initialization
4+
init() {
5+
echo "🚀 Initializing development environment..."
6+
7+
# Copy .env files if they don't exist
8+
if [ -f "backend/.env.example" ]; then
9+
if [ ! -f "backend/.env" ]; then
10+
echo "📝 Creating backend/.env from .env.example..."
11+
cp backend/.env.example backend/.env
12+
else
13+
echo "ℹ️ backend/.env already exists, skipping copy."
14+
fi
15+
fi
16+
17+
if [ -f "frontend/.env.example" ]; then
18+
if [ ! -f "frontend/.env" ]; then
19+
echo "📝 Creating frontend/.env from .env.example..."
20+
cp frontend/.env.example frontend/.env
21+
else
22+
echo "ℹ️ frontend/.env already exists, skipping copy."
23+
fi
24+
fi
25+
26+
# Install dependencies
27+
echo "📦 Installing backend dependencies..."
28+
(cd backend && npm install)
29+
30+
echo "📦 Installing frontend dependencies..."
31+
(cd frontend && npm install)
32+
33+
echo "✅ Initialization complete!"
34+
}
35+
36+
# Check for --init flag
37+
if [[ "$1" == "--init" ]]; then
38+
init
39+
exit 0
40+
fi
41+
242
echo "Starting local development..."
343

444
if ! docker info > /dev/null 2>&1; then
@@ -13,3 +53,4 @@ fi
1353
(cd backend && npm run dev) &
1454
(cd frontend && npm run dev) &
1555
wait
56+

frontend/jest.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ const config = {
1010
moduleNameMapper: {
1111
"^@/(.*)$": "<rootDir>/src/$1",
1212
},
13-
testMatch: ["**/__tests__/**/*.test.tsx", "**/__tests__/**/*.test.ts"],
13+
testMatch: [
14+
"**/__tests__/**/*.test.tsx",
15+
"**/__tests__/**/*.test.ts",
16+
"**/*.test.tsx",
17+
"**/*.test.ts",
18+
],
1419
};
1520

1621
module.exports = createJestConfig(config);

frontend/src/app/page.tsx

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
"use client";
22

33
import { useState } from "react";
4-
import WorkflowList from "@/components/WorkflowList";
5-
import WorkflowEditor from "@/components/WorkflowEditor";
4+
import WorkflowList from "@/features/workflows/components/WorkflowList";
5+
import WorkflowEditor from "@/features/workflows/components/WorkflowEditor";
66
import ThemeToggle from "@/components/ThemeToggle";
77
import { Plus, CircuitBoard } from "lucide-react";
88
import styles from "./page.module.css";
9-
import { Workflow } from "@/lib/types";
10-
import { fetchWorkflow } from "@/lib/api";
9+
import { Workflow } from "@/features/workflows/types";
10+
import { fetchWorkflow } from "@/features/workflows/api";
1111
import { handleError } from "@/lib/error-handler";
12+
import { MESSAGES, LABELS } from "@/lib/constants";
1213

1314
export default function Home() {
1415
const [isEditorOpen, setIsEditorOpen] = useState(false);
@@ -25,7 +26,7 @@ export default function Home() {
2526
setEditingWorkflow(workflow);
2627
setIsEditorOpen(true);
2728
} catch (error) {
28-
handleError(error, "Failed to load workflow for editing");
29+
handleError(error, MESSAGES.LOAD_FOR_EDIT_ERROR);
2930
}
3031
};
3132

@@ -38,25 +39,34 @@ export default function Home() {
3839
<main className={styles.main}>
3940
<header className={styles.header}>
4041
<div className={styles.logo}>
41-
<CircuitBoard size={24} color="var(--primary)" />
42-
<h1>WorkFlowEngine</h1>
42+
<CircuitBoard size={24} color="var(--primary)" aria-hidden="true" />
43+
<h1>{LABELS.APP_NAME}</h1>
4344
</div>
4445
<div className={styles.headerActions}>
4546
<ThemeToggle />
4647
</div>
4748
</header>
4849

4950
<div className={styles.content}>
50-
<div className={styles.pageHeader}>
51+
<section
52+
className={styles.pageHeader}
53+
aria-labelledby="workflows-title"
54+
>
5155
<div>
52-
<h2 className={styles.pageTitle}>Workflows</h2>
53-
<p className={styles.pageSubtitle}>Manage your automation tasks.</p>
56+
<h2 id="workflows-title" className={styles.pageTitle}>
57+
{LABELS.WORKFLOWS}
58+
</h2>
59+
<p className={styles.pageSubtitle}>{LABELS.MANAGE_TASKS}</p>
5460
</div>
55-
<button onClick={handleCreate} className={styles.createBtn}>
56-
<Plus size={18} />
57-
Create Workflow
61+
<button
62+
onClick={handleCreate}
63+
className={styles.createBtn}
64+
aria-label={LABELS.CREATE_WORKFLOW}
65+
>
66+
<Plus size={18} aria-hidden="true" />
67+
{LABELS.CREATE_WORKFLOW}
5868
</button>
59-
</div>
69+
</section>
6070

6171
<WorkflowList onEdit={handleEdit} />
6272
</div>

frontend/src/components/ThemeToggle.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { useTheme } from "@/providers/ThemeProvider";
44
import { Sun, Moon } from "lucide-react";
55
import styles from "./ThemeToggle.module.css";
6+
import { LABELS } from "@/lib/constants";
67

78
export default function ThemeToggle() {
89
const { theme, toggleTheme } = useTheme();
@@ -11,7 +12,7 @@ export default function ThemeToggle() {
1112
<button
1213
onClick={toggleTheme}
1314
className={styles.toggle}
14-
aria-label="Toggle theme"
15+
aria-label={LABELS.TOGGLE_THEME}
1516
>
1617
{theme === "light" ? <Moon size={20} /> : <Sun size={20} />}
1718
</button>

frontend/src/components/WorkflowEditor.tsx

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

0 commit comments

Comments
 (0)