Metadata-Version: 2.4
Name: gtikz
Version: 0.1.0
Summary: A visual, drawio-style editor for building diagrams and generating matching TikZ/LaTeX code.
Author: gx1
License: MIT License
        
        Copyright (c) 2026 gx1
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/giper45/gtikz
Project-URL: Changelog, https://github.com/giper45/gtikz/blob/main/CHANGELOG.md
Keywords: tikz,latex,diagram,editor,drawio
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Text Processing :: Markup :: LaTeX
Classifier: Topic :: Multimedia :: Graphics :: Editors :: Vector-Based
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: fastapi==0.115.0
Requires-Dist: uvicorn[standard]==0.30.6
Requires-Dist: pydantic==2.9.2
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Dynamic: license-file

# gtikz

A visual, drawio-style editor for building diagrams and generating the
matching **TikZ** LaTeX code with one click.

![version](https://img.shields.io/badge/version-0.1.0-blue)
![license](https://img.shields.io/badge/license-MIT-green)

## Features

- Drag-and-drop canvas: rectangles, ellipses, diamonds, connectors.
- Resize handles, multi-select, grouping with a labeled dashed box.
- Properties panel: font size, fill/stroke color, bold/italic, rounded
  corners, arrow head style, line style (solid/dashed/dotted), straight or
  orthogonal routing.
- One-click **Generate TikZ code**, with copy-to-clipboard and `.tex` download.
- Built-in snippet library (preamble, rating-star icon, figure wrapper).
- Save/load diagrams as JSON.

## Requirements

- Python 3.10+

## Getting started

### As a CLI tool (pip / pipx)

```bash
pipx install gtikz   # or: pip install gtikz
gtikz start
```

Then open **http://127.0.0.1:18888**. `gtikz stop` shuts it back down.
`pipx` is recommended — it installs `gtikz` in its own isolated
environment, so it won't clash with any other project's dependencies.

Saved diagrams and server logs live under `~/.gtikz/` (override with the
`GTIKZ_DATA_DIR` environment variable). Other commands:

| Command         | Description                                         |
|-----------------|------------------------------------------------------|
| `gtikz start`   | Start the server in the background (`--host`, `--port`, `--reload`) |
| `gtikz stop`    | Stop it                                               |
| `gtikz restart` | Restart it                                            |
| `gtikz status`  | Show whether it's running                             |
| `gtikz logs`    | Show the server log (`-f` to follow, `-n` for line count) |
| `gtikz --version` | Print the installed version                         |

### From a checkout (development)

```bash
git clone git@github.com:giper45/gtikz.git
cd gtikz
make install
make start
```

Then open **http://127.0.0.1:18888**. This runs uvicorn with `--reload`
straight out of the checkout instead of an installed package — see
[Makefile targets](#makefile-targets) below.

Without `make`:

```bash
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn gtikz.main:app --reload --port 18888
```

## Usage

- Pick a tool from the top bar (`V` select, `R` rectangle, `E` ellipse,
  `D` diamond, `C` connector), then click the canvas to place a shape, or
  click two nodes in sequence to connect them.
- Drag a node to move it; with a single node selected, drag its handles to
  resize it.
- Edit the selected element's style from the right-hand **Properties** panel.
- Shift+click to multi-select, then **Group** (or press `G`) to wrap the
  selection in a labeled box.
- **Generate TikZ code** opens the generated code with options for the
  `figure` wrapper, caption, label, preamble and `\resizebox`.
- **Snippets** gives you ready-to-copy fragments (preamble, rating icon, etc.).
- **Save** / **Load** store diagrams as JSON under `~/.gtikz/diagrams/`
  (or `$GTIKZ_DATA_DIR/diagrams/` if that's set).

## Makefile targets

These drive the checkout workflow (`.venv` + uvicorn). Once installed via
pip/pipx, use the `gtikz` command instead (see above).

| Command             | Description                                       |
|---------------------|-----------------------------------------------------|
| `make install`      | Create the virtualenv and install dependencies    |
| `make start`        | Start the server in the background                |
| `make stop`         | Stop the server                                    |
| `make restart`      | Restart the server                                 |
| `make status`       | Show whether the server is running                 |
| `make logs`         | Follow the server log                              |
| `make test`         | Run the test suite                                 |
| `make build`        | Build the sdist + wheel into `dist/`               |
| `make publish-test` | Upload `dist/*` to TestPyPI                        |
| `make publish`      | Upload `dist/*` to PyPI                            |
| `make clean`        | Remove the venv, caches, pid/log/build files       |

## Project structure

```
gtikz/                Python package (installable, ships on PyPI)
├── main.py            App entrypoint, serves the API and the static frontend
├── cli.py              `gtikz start/stop/status/restart/logs` command
├── config.py            Paths: static/examples (in-package), user data (~/.gtikz)
├── models.py            Pydantic schema for a diagram (nodes/edges/groups)
├── storage.py            Save/load diagrams as JSON
├── api/routes.py        REST endpoints
├── tikz/                  Diagram -> TikZ code generation
├── static/               Frontend (vanilla JS + SVG, no build step)
│   ├── index.html
│   ├── css/style.css
│   └── js/                 One module per concern (state, canvas, properties, ...)
└── examples/              Sample diagrams (JSON)

tests/                 pytest suite
```

## Testing

```bash
make test
```

## Publishing

Maintainer-only; requires a [trusted publisher](https://docs.pypi.org/trusted-publishers/)
set up once on the PyPI project pointing at `.github/workflows/publish.yml`
(see the comment at the top of that file). To ship a release: bump
[VERSION](VERSION) and [CHANGELOG.md](CHANGELOG.md), tag it and push the
tag, then publish a GitHub Release from that tag — the workflow builds and
uploads to PyPI automatically. To do it by hand instead: `make build` then
`make publish` (or `make publish-test` for TestPyPI first).

## Versioning

This project follows [Semantic Versioning](https://semver.org/). See
[VERSION](VERSION) for the current version and [CHANGELOG.md](CHANGELOG.md)
for release notes.

## License

[MIT](LICENSE)
