Skip to content

Commit c1c9014

Browse files
committed
Readme and better instructions to reproduce the current functionality are now added
1 parent 7889a2a commit c1c9014

File tree

3 files changed

+75
-45
lines changed

3 files changed

+75
-45
lines changed

README.md

+73-43
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,81 @@
1+
# QuCat Circuit Generator
12

2-
## Code Structure explanation
3-
```plaintext
4-
src/
5-
├── domain/ # Core business logic
6-
│ ├── aggregates/ # Aggregate roots
7-
│ │ └── Circuit.js # Circuit aggregate root
8-
│ ├── entities/ # Domain entities
9-
│ │ ├── Resistor.js # Resistor entity
10-
│ │ └── Capacitor.js # Capacitor entity
11-
│ ├── value-objects/ # Value objects
12-
│ │ ├── Position.js # Position value object
13-
│ │ ├── Resistance.js # Resistance value object
14-
│ │ └── Capacitance.js # Capacitance value object
15-
├── application/ # Application services
16-
│ └── CircuitAppService.js # Circuit application service
17-
├── infrastructure/ # Adapters and repositories
18-
│ ├── adapters/ # Adapters for external systems
19-
│ │ ├── CanvasAdapter.js # Adapter for canvas interactions
20-
│ │ └── CircuitExporter.js # Adapter for exporting circuits
21-
│ ├── repositories/ # Data persistence
22-
│ └── CircuitRepository.js# Circuit repository
23-
├── gui/ # Graphical user interface
24-
│ └── index.html # Main HTML file for the GUI
3+
A modular and testable project for generating and testing circuits. This application provides a user-friendly GUI to add and manipulate circuit elements like resistors and wires, along with robust testing for the core functionalities.
4+
5+
---
6+
7+
## **Features**
8+
- Add, delete, and connect circuit elements dynamically via the GUI.
9+
- Modular architecture with clear separation between UI, application logic, and domain layers.
10+
- Unit tests for ensuring functionality and maintainability.
11+
- Bundling with Rollup for optimized builds.
12+
13+
---
14+
15+
## **Setup and Usage**
16+
17+
### **1. Clone the Repository**
18+
```bash
19+
git clone https://github.com/your-repo/qucat-circuit-generator.git
20+
cd qucat-circuit-generator
21+
```
22+
23+
### **2. Install Dependencies**
24+
Install all required dependencies using npm:
25+
```bash
26+
npm install
27+
```
28+
29+
### **3. Build the Project**
30+
Bundle the project with Rollup:
31+
```bash
32+
npm run build
2533
```
34+
This will generate the bundled JavaScript files in the `dist` folder and copy the `gui.html` file there.
35+
36+
### **4. Open the Application**
37+
After bundling, open the `gui.html` file in the `dist` folder in your browser:
38+
```bash
39+
open dist/gui.html
40+
```
41+
42+
## **Testing**
43+
44+
### **1. Run All Tests**
45+
Run the provided test suite using Mocha:
46+
```bash
47+
npm test
48+
```
49+
50+
### **2. Test Coverage**
51+
- **GUIAdapter**: Tests UI bindings and integration with `CircuitService`.
52+
- **CircuitService**: Validates the addition, deletion, and connection of circuit elements.
53+
54+
---
55+
56+
## **Scripts**
2657

27-
### Domain Layer
28-
- **Aggregates**: Encapsulate entities and value objects, ensuring consistency within the aggregate.
29-
- `Circuit.js`
30-
- **Entities**: Represent core business objects with a distinct identity.
31-
- `Resistor.js`, `Capacitor.js`
32-
- **Value Objects**: Represent immutable concepts with no distinct identity.
33-
- `Position.js`, `Resistance.js`, `Capacitance.js`
58+
- **Build**: Bundles the project with Rollup and copies `gui.html` to the `dist` folder.
59+
```bash
60+
npm run build
61+
```
3462

35-
### Application Layer
36-
- **Application Services**: Manage use cases and orchestrate domain operations.
37-
- `CircuitAppService.js`
63+
- **Test**: Runs all tests in the `tests` folder using Mocha.
64+
```bash
65+
npm test
66+
```
3867

39-
### Infrastructure Layer
40-
- **Adapters**: Convert data between the domain and external systems.
41-
- `CanvasAdapter.js`, `CircuitExporter.js`
42-
- **Repositories**: Handle data persistence and retrieval.
43-
- `CircuitRepository.js`
68+
---
4469

45-
### GUI Layer
46-
- **GUI**: Interacts with the user and connects to the application layer through adapters.
47-
- `index.html`
70+
## **Configuration Details**
4871

49-
## Rationale
72+
### **Rollup Config**
73+
Rollup bundles the project into the `dist` folder for optimized performance. The configuration ensures all dependencies are correctly resolved and minified.
5074

51-
Hexagonal Architecture allows us to isolate the core business logic from external concerns, making the system more modular and easier to maintain. By organizing the code into distinct layers, we can ensure that changes in one part of the system do not affect other parts, promoting a clean separation of concerns and enhancing testability.
75+
### **Scripts in `package.json`**
76+
```json
77+
"scripts": {
78+
"test": "mocha 'tests/**/*.test.js'",
79+
"build": "rollup -c && cp gui.html dist/"
80+
}
81+
```

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "main.js",
66
"scripts": {
77
"test": "mocha 'tests/**/*.test.js'",
8-
"build": "rollup -c"
8+
"build": "rollup -c && cp src/gui/gui.html dist/"
99
},
1010
"type": "module",
1111
"author": "",

src/gui/gui.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ <h1>Circuit Designer</h1>
2121
<button id="addWire">Add Wire</button>
2222
</div>
2323
<canvas id="circuitCanvas" width="800" height="600"></canvas>
24-
<script src="../../dist/bundle.js"></script>
24+
<script src="./bundle.js"></script>
2525
</body>
2626
</html>

0 commit comments

Comments
 (0)