Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanix-Darker committed Jun 7, 2024
0 parents commit 1f6162d
Show file tree
Hide file tree
Showing 3 changed files with 194 additions and 0 deletions.
100 changes: 100 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# CUPID (Composable Unix Predictable Ideomatic Domain base)

## LEARN MAP

![map](./cupid.svg)

[CHECK THE INTERACTIVE MAP](https://sanix-darker.github.io/cupid_learn/cupid.html)

## CONCEPTS

## Introduction to CUPID
- What is CUPID?
- CUPID (Composable Unix Predictable Ideomatic Domain base) is a framework for building Unix-based systems with predictable behavior and composability.
- It emphasizes ideomatic design principles and domain-specific customization.

## Core Concepts of CUPID

- Composable Architecture
```python
import cupid

# Define reusable components
class DatabaseComponent(cupid.Component):
def setup(self):
print("Setting up database component.")

class WebServerComponent(cupid.Component):
def setup(self):
print("Setting up web server component.")

class LoggingComponent(cupid.Component):
def setup(self):
print("Setting up logging component.")

# Create a CUPID system
system = cupid.System()

# Add components to the system
system.add_component(DatabaseComponent())
system.add_component(WebServerComponent())
system.add_component(LoggingComponent())

# Start the system
system.start()
```

- Unix Philosophy
- Understanding the principles of Unix design, such as modularity, simplicity, and composability.
```python
# Example: Unix Philosophy
# Using pipes to compose Unix commands
import subprocess

output = subprocess.run(["ls", "-l"], capture_output=True)
print(output.stdout.decode())
```

- Predictable Behavior
- Ensuring consistent and deterministic behavior of CUPID-based systems under various conditions.
```python
# Example: Predictable Behavior
# Writing unit tests for a CUPID component
import unittest
import cupid

class TestPredictableBehavior(unittest.TestCase):
def test_addition(self):
calculator = cupid.Calculator()
result = calculator.add(2, 3)
self.assertEqual(result, 5)

if __name__ == '__main__':
unittest.main()
```

- Ideomatic Design
- Embracing standard practices and conventions in Unix system design for clarity and consistency.
```python
# Example: Ideomatic Design
# Following PEP 8 style guide in CUPID code
def greet(name):
"""
Greets the user by name.
"""
print(f"Hello, {name}!")

greet("Alice")
```

- Domain-specific Customization
- Tailoring CUPID-based systems to specific use cases and domains for optimal performance and flexibility.
```python
# Example: Domain-specific Customization
# Customizing a web server component in a CUPID system
import cupid

web_server = cupid.WebServer()
web_server.configure(port=8080, ssl=True)
web_server.start()
```
25 changes: 25 additions & 0 deletions cupid.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Markmap</title>
<style>
* {
margin: 0;
padding: 0;
}
#mindmap {
display: block;
width: 100vw;
height: 100vh;
}
</style>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/markmap-toolbar@0.17.0/dist/style.css">
</head>
<body>
<svg id="mindmap"></svg>
<script src="https://cdn.jsdelivr.net/npm/d3@7.8.5/dist/d3.min.js"></script><script src="https://cdn.jsdelivr.net/npm/markmap-view@0.17.0/dist/browser/index.js"></script><script src="https://cdn.jsdelivr.net/npm/markmap-toolbar@0.17.0/dist/index.js"></script><script>(()=>{setTimeout(()=>{const{markmap:O,mm:h}=window,M=new O.Toolbar;M.attach(h);const oe=M.render();oe.setAttribute("style","position:absolute;bottom:20px;right:20px"),document.body.append(oe)})})()</script><script>((i,L,f,r)=>{const w=i();window.mm=w.Markmap.create("svg#mindmap",(L||w.deriveOptions)(r),f)})(()=>window.markmap,null,{"content":"CUPID (Composable Unix Predictable Ideomatic Domain base)","children":[{"content":"Introduction to CUPID","children":[{"content":"What is CUPID?","children":[{"content":"CUPID (Composable Unix Predictable Ideomatic Domain base) is a framework for building Unix-based systems with predictable behavior and composability.","children":[],"payload":{"lines":"4,5"}},{"content":"It emphasizes ideomatic design principles and domain-specific customization.","children":[],"payload":{"lines":"5,7"}}],"payload":{"lines":"3,7"}}],"payload":{"lines":"2,3"}},{"content":"Core Concepts of CUPID","children":[{"content":"\n<p data-lines=\"9,10\">Composable Architecture</p>\n<pre><code class=\"language-python\"><span class=\"hljs-keyword\">import</span> cupid\n\n<span class=\"hljs-comment\"># Define reusable components</span>\n<span class=\"hljs-keyword\">class</span> <span class=\"hljs-title class_\">DatabaseComponent</span>(cupid.Component):\n <span class=\"hljs-keyword\">def</span> <span class=\"hljs-title function_\">setup</span>(<span class=\"hljs-params\">self</span>):\n <span class=\"hljs-built_in\">print</span>(<span class=\"hljs-string\">\"Setting up database component.\"</span>)\n\n<span class=\"hljs-keyword\">class</span> <span class=\"hljs-title class_\">WebServerComponent</span>(cupid.Component):\n <span class=\"hljs-keyword\">def</span> <span class=\"hljs-title function_\">setup</span>(<span class=\"hljs-params\">self</span>):\n <span class=\"hljs-built_in\">print</span>(<span class=\"hljs-string\">\"Setting up web server component.\"</span>)\n\n<span class=\"hljs-keyword\">class</span> <span class=\"hljs-title class_\">LoggingComponent</span>(cupid.Component):\n <span class=\"hljs-keyword\">def</span> <span class=\"hljs-title function_\">setup</span>(<span class=\"hljs-params\">self</span>):\n <span class=\"hljs-built_in\">print</span>(<span class=\"hljs-string\">\"Setting up logging component.\"</span>)\n\n<span class=\"hljs-comment\"># Create a CUPID system</span>\nsystem = cupid.System()\n\n<span class=\"hljs-comment\"># Add components to the system</span>\nsystem.add_component(DatabaseComponent())\nsystem.add_component(WebServerComponent())\nsystem.add_component(LoggingComponent())\n\n<span class=\"hljs-comment\"># Start the system</span>\nsystem.start()\n</code></pre>","children":[],"payload":{"lines":"9,38"}},{"content":"\n<p data-lines=\"38,39\">Unix Philosophy(Understanding the principles of Unix design, such as modularity, simplicity, and composability)</p>\n<pre><code class=\"language-python\"><span class=\"hljs-keyword\">import</span> subprocess\n\noutput = subprocess.run([<span class=\"hljs-string\">\"ls\"</span>, <span class=\"hljs-string\">\"-l\"</span>], capture_output=<span class=\"hljs-literal\">True</span>)\n<span class=\"hljs-built_in\">print</span>(output.stdout.decode())\n</code></pre>","children":[],"payload":{"lines":"38,46"}},{"content":"\n<p data-lines=\"46,47\">Predictable Behavior (Ensuring consistent and deterministic behavior of CUPID-based systems under various conditions).</p>\n<pre><code class=\"language-python\"><span class=\"hljs-comment\"># Example: Predictable Behavior</span>\n<span class=\"hljs-comment\"># Writing unit tests for a CUPID component</span>\n<span class=\"hljs-keyword\">import</span> unittest\n<span class=\"hljs-keyword\">import</span> cupid\n\n<span class=\"hljs-keyword\">class</span> <span class=\"hljs-title class_\">TestPredictableBehavior</span>(unittest.TestCase):\n <span class=\"hljs-keyword\">def</span> <span class=\"hljs-title function_\">test_addition</span>(<span class=\"hljs-params\">self</span>):\n calculator = cupid.Calculator()\n result = calculator.add(<span class=\"hljs-number\">2</span>, <span class=\"hljs-number\">3</span>)\n self.assertEqual(result, <span class=\"hljs-number\">5</span>)\n\n<span class=\"hljs-keyword\">if</span> __name__ == <span class=\"hljs-string\">'__main__'</span>:\n unittest.main()\n</code></pre>","children":[],"payload":{"lines":"46,63"}},{"content":"\n<p data-lines=\"63,64\">Ideomatic Design (Embracing standard practices and conventions in Unix system design for clarity and consistency).</p>\n<pre><code class=\"language-python\"><span class=\"hljs-comment\"># Example: Ideomatic Design</span>\n<span class=\"hljs-comment\"># Following PEP 8 style guide in CUPID code</span>\n <span class=\"hljs-keyword\">def</span> <span class=\"hljs-title function_\">greet</span>(<span class=\"hljs-params\">name</span>):\n <span class=\"hljs-string\">\"\"\"\n Greets the user by name.\n \"\"\"</span>\n <span class=\"hljs-built_in\">print</span>(<span class=\"hljs-string\">f\"Hello, <span class=\"hljs-subst\">{name}</span>!\"</span>)\n\n greet(<span class=\"hljs-string\">\"Alice\"</span>)\n</code></pre>","children":[],"payload":{"lines":"63,76"}},{"content":"\n<p data-lines=\"76,77\">Domain-specific Customization (Tailoring CUPID-based systems to specific use cases and domains for optimal performance and flexibility).</p>\n<pre><code class=\"language-python\"><span class=\"hljs-comment\"># Example: Domain-specific Customization</span>\n<span class=\"hljs-comment\"># Customizing a web server component in a CUPID system</span>\n<span class=\"hljs-keyword\">import</span> cupid\n\nweb_server = cupid.WebServer()\nweb_server.configure(port=<span class=\"hljs-number\">8080</span>, ssl=<span class=\"hljs-literal\">True</span>)\nweb_server.start()\n</code></pre>","children":[],"payload":{"lines":"76,87"}}],"payload":{"lines":"7,8"}}],"payload":{"lines":"0,1"}},{"colorFreezeLevel":2})</script>
</body>
</html>
Loading

0 comments on commit 1f6162d

Please sign in to comment.