Metadata-Version: 2.4
Name: django-vista
Version: 0.1.0
Summary: Static Django model diagrams with live local updates
License-Expression: MIT
Project-URL: Homepage, https://github.com/Jamshid057/Django-Vista
Project-URL: Repository, https://github.com/Jamshid057/Django-Vista
Project-URL: Issues, https://github.com/Jamshid057/Django-Vista/issues
Keywords: django,models,diagram,er,developer-tools
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: Django
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: fastapi>=0.116
Requires-Dist: uvicorn>=0.35
Requires-Dist: watchdog>=6.0
Requires-Dist: pydantic>=2.11
Requires-Dist: websockets>=15.0
Provides-Extra: django
Requires-Dist: Django>=4.2; extra == "django"
Dynamic: license-file

# DjangoVista

A local, open-source Django model explorer. DjangoVista reads Python source with
AST, builds an interactive model diagram and refreshes it when source files change.
Diagram scanning does not import your Django project, run its code or connect to a database. The optional migration check runs Django explicitly.

Status: **0.1.0 alpha**. PyPI and editor marketplace releases are not published yet.
The distribution and CLI are named `django-vista`; the Python import is `django_vista`.

Source: [Jamshid057/Django-Vista](https://github.com/Jamshid057/Django-Vista).
Report bugs through [GitHub Issues](https://github.com/Jamshid057/Django-Vista/issues).

## Features

- Module-qualified model identities, import aliases and split model packages.
- Fields, primary/composite keys, nullability and uniqueness.
- ForeignKey, OneToOneField, ManyToManyField and explicit through models.
- Abstract/proxy models and concrete inheritance parent links.
- Partial graphs with actionable syntax and unresolved-reference diagnostics.
- Model cards, automatic ELK layout, search, app filtering, minimap and zoom.
- Debounced live snapshots over WebSocket, reconnect and preserved node positions.
- Python library, JSON export CLI and a local server with bundled release UI.

## Install from source

Python 3.12+ and Node 24+ are needed
for building from source. Released wheels include the UI and will not require Node.

```bash
git clone https://github.com/Jamshid057/Django-Vista.git
cd Django-Vista
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python scripts/build_release.py --bundle-only
python -m pip install .
django-vista serve /absolute/path/to/django-project
```

On Windows activate `.venv\Scripts\activate` instead. The server binds to
`127.0.0.1:8000`; use `--port 8001` to choose another port or `--no-browser` to avoid
opening a browser. The project path is local to the computer running the backend.

```bash
django-vista graph /path/to/project --output graph.json
```

Library use:

```python
from pathlib import Path
from django_vista import build_graph

graph = build_graph(Path("/path/to/project"))
print(graph.model_dump_json(indent=2))
```

## Open from manage.py

Install DjangoVista into your Django project's virtual environment:

```bash
python -m pip install /absolute/path/to/django-vista
```

Add `"django_vista"` to your project's `INSTALLED_APPS`:

```python
INSTALLED_APPS = [
    # Your existing apps ...
    "django_vista",
]
```

Then launch from the project terminal:

```bash
python manage.py showmodels
python manage.py showmodels --port 8001
python manage.py showmodels --no-browser
```

The command opens the diagram in your browser and serves it until Ctrl+C.
It uses the directory containing `manage.py`, falling back to `BASE_DIR` for
programmatic invocation. Use `--project /path/to/project` to override it.
Django loads your installed apps when invoking management commands; the diagram
scanner itself remains static. Command startup does not run migration checks.

## Development

Install the Python package in editable mode at the repository root:

```bash
python -m pip install -e .
python -m uvicorn django_vista.main:app --reload
```

In a second terminal:

```bash
cd frontend
npm ci
npm run dev
```

Open `http://localhost:5173` and enter the Django project directory. You can use the
absolute path to `examples/sample_project` for a source-only demonstration. Those
fixtures do not need Django installed and are not a runnable Django application.

The Vite UI uses `http://127.0.0.1:8000` by default; `frontend/.env.example` documents
`VITE_API_URL`. Bundled UI connects to its own server origin. Standard local Vite
origins are allowed for HTTP and WebSocket; production remote hosting is outside
this release's scope.

## Checks

```bash
PYTHONPATH=backend python -m unittest discover -s backend/tests -v
cd frontend
npm run build
npm run lint
npm run test
```

Backend tests cover parser behavior and in-process HTTP/WebSocket/watcher lifecycle.
See [validation results](docs/VALIDATION.md), [graph contract](docs/GRAPH_CONTRACT.md)
and [implementation plan](PLAN.md).

## Build a release

```bash
python -m pip install build
python scripts/build_release.py
python -m pip install dist/django_vista-0.1.0-py3-none-any.whl
```

The build script compiles the frontend, copies it into the Python package and
builds a wheel and source archive. Generated UI/build output is ignored by Git.
Use `--skip-install` when frontend dependencies are already installed.

Publishing to PyPI is a separate release action. No package or extension has been
published by this implementation.

## Static analysis limitations

Static analysis cannot reproduce arbitrary Django runtime behavior. Conditional
model definitions, dynamically generated fields, custom field behavior, wildcard
imports and model classes supplied only by unscanned dependencies are unsupported.
Known unresolved fields, relationships and bases produce diagnostics; no target is
guessed. Implicit IDs use a placeholder AutoField because project
`DEFAULT_AUTO_FIELD` is not evaluated. Abstract nodes are displayed for context;
concrete inherited storage is represented through parent links.

Live updates use filtered filesystem polling (1 second) and debounce (0.2
seconds), rescan the project and send full snapshots. Incremental
parsing should follow measured need. Source scanning excludes environments,
migrations, caches, build directories and symlinks.

## Open-source and editor integrations

The Python library and local API are the reusable core. VS Code and PyCharm
extensions can later start `django-vista serve --no-browser`, display the diagram in
an editor panel and reuse the same graph protocol. See the
[distribution roadmap](docs/DISTRIBUTION.md). Editor extensions are not implemented
in this alpha.

Contributions are welcome; see [CONTRIBUTING.md](CONTRIBUTING.md).
Licensed under [MIT](LICENSE).

## Diagram editing and migration status

Double-click a model to open the field editor. Add standard scalar fields or edit
`null`, `blank`, `unique`, and length/decimal parameters of declared fields.
Preview shows a unified source diff; Apply writes the model file. A file revision
check rejects stale previews. Existing methods, comments, imports, and unrelated
field arguments are preserved. Field renaming, deletion, type changes, relationship
editing, and model creation are not implemented yet.

Open **Migration status** in the sidebar and click **Check migrations**. This is an
explicit runtime feature: it runs the project's Django code and reads migration
history from the default database. Enter the project's absolute Python interpreter
path, or let DjangoVista detect `.venv`/`venv`; it falls back to the server Python.
The opened directory must contain `manage.py`.

The panel shows `makemigrations --dry-run --verbosity 3` output, checks for missing
migration files, and lists applied/pending migrations with `showmigrations --plan`.
It does not create migration files or apply migrations. Run the displayed
`makemigrations` and `migrate` commands in the project console, then check again.
Checks are manual; source updates mark the last result stale. Database errors are
shown as errors rather than an up-to-date status. Checks have a per-command timeout.

## Repository and package naming

| Surface | Name |
| --- | --- |
| Project | DjangoVista |
| Python distribution / repository | `django-vista` |
| Terminal command | `django-vista` |
| Python import / Django installed app | `django_vista` |

The source directory remains `backend/app/`; setuptools maps it to `django_vista`
when installed. Use `django_vista` in Python code, not the hyphenated package name.

See [contributing](CONTRIBUTING.md) for development checks and
[Git setup](docs/GIT_SETUP.md) for connecting this source tree to a remote.
