Metadata-Version: 2.4
Name: pychitect
Version: 1.0.0
Summary: Blueprint-based Python architecture generator with UML export
Author: Finn Adler
License: MIT
Project-URL: Homepage, https://github.com/USERNAME/pychitect
Project-URL: Repository, https://github.com/USERNAME/pychitect
Project-URL: Issues, https://github.com/USERNAME/pychitect/issues
Keywords: blueprint,uml,plantuml,architecture,generator,python
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: plantuml
Dynamic: license-file

# PyChitect

Build Python project blueprints, generate class diagrams, and export clean project structures with minimal code.

## Features

* Create Python file blueprints
* Add imports and from-imports
* Define variables
* Define functions with parameters
* Define classes with methods and inheritance
* Generate runnable `.py` files
* Generate UML class diagrams
* Export diagrams as PNG
* Automatic overwrite detection
* Blueprint structure inspection

---

## Installation

```bash
pip install pychitect
```

### Optional

For UML diagram generation:

```bash
pip install plantuml
```

---

## Quick Start

```python
from pychitect import *

use_file("project.py", "override")

insert_import(["os", "json"])

insert_from(
    "datetime",
    ["datetime"]
)

create_variable(
    "VERSION",
    "1.0.0"
)

create_function(
    "main",
    ["args"]
)

create_class(
    "User",
    methods=[
        ("__init__", ["self", "name"]),
        ("save", ["self"])
    ]
)

create_entry("main")
```

Generated file:

```python
# imports
import os
import json
from datetime import datetime

# variables
VERSION = '1.0.0'

# classes
class User:

    def __init__(self, name):
        pass

    def save(self):
        pass

# functions
def main(args):
    pass

# entries
if __name__ == '__main__':
    main(args)
```

---

## Functions

### use_file

```python
use_file(file, mode)
```

Parameters:

| Name | Description                |
| ---- | -------------------------- |
| file | Target Python file         |
| mode | `"append"` or `"override"` |

Example:

```python
use_file("app.py", "override")
```

---

### insert_import

```python
insert_import(modules)
```

Example:

```python
insert_import([
    "os",
    "json",
    "sys"
])
```

Result:

```python
import os
import json
import sys
```

---

### insert_from

```python
insert_from(module, imports)
```

Example:

```python
insert_from(
    "datetime",
    ["datetime", "timedelta"]
)
```

Result:

```python
from datetime import datetime, timedelta
```

---

### create_variable

```python
create_variable(name, value)
```

Example:

```python
create_variable(
    "DEBUG",
    True
)
```

---

### create_function

```python
create_function(
    name,
    params=[]
)
```

Example:

```python
create_function(
    "login",
    [
        "username",
        "password"
    ]
)
```

Result:

```python
def login(username, password):
    pass
```

---

### create_class

```python
create_class(
    name,
    methods=[],
    parents=[]
)
```

Example:

```python
create_class(
    "User",
    methods=[
        ("__init__", ["self", "name"]),
        ("save", ["self"])
    ]
)
```

Result:

```python
class User:

    def __init__(self, name):
        pass

    def save(self):
        pass
```

Inheritance:

```python
create_class(
    "Admin",
    parents=["User"]
)
```

Result:

```python
class Admin(User):
    pass
```

---

### create_entry

```python
create_entry("main")
```

Result:

```python
if __name__ == '__main__':
    main()
```

---

### info

Display the current blueprint structure.

```python
info()
```

Example output:

```text
===== BLUEPRINT STRUCTURE =====

IMPORTS:
  - import os

VARIABLES:
  - DEBUG = True

CLASSES:
  Class: User
    Method: __init__(self, name)
    Method: save(self)

FUNCTIONS:
  Function: main(args)

ENTRYPOINT:
  - if __name__ == '__main__':

==============================
```

---

### show_logs

Display all collected logs.

```python
show_logs()
```

---

### create_class_diagram

Generate a UML class diagram.

```python
create_class_diagram()
```

Output:

```text
project.png
```

Keep generated `.puml` file:

```python
create_class_diagram(
    keep_puml=True
)
```

---

## Example

```python
from pychitect import *

use_file(
    "shop.py",
    "override"
)

insert_import([
    "json"
])

create_variable(
    "VERSION",
    "1.0.0"
)

create_class(
    "Product",
    methods=[
        ("__init__", ["self", "name", "price"]),
        ("save", ["self"])
    ]
)

create_function(
    "main"
)

create_entry(
    "main"
)

create_class_diagram()
```

Generated:

* `shop.py`
* `shop.png`

---

## License

MIT License
