django-vista 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. django_vista-0.1.0/CONTRIBUTING.md +81 -0
  2. django_vista-0.1.0/LICENSE +21 -0
  3. django_vista-0.1.0/MANIFEST.in +13 -0
  4. django_vista-0.1.0/PKG-INFO +229 -0
  5. django_vista-0.1.0/PLAN.md +121 -0
  6. django_vista-0.1.0/README.md +205 -0
  7. django_vista-0.1.0/backend/app/__init__.py +6 -0
  8. django_vista-0.1.0/backend/app/apps.py +7 -0
  9. django_vista-0.1.0/backend/app/cli.py +52 -0
  10. django_vista-0.1.0/backend/app/editor.py +139 -0
  11. django_vista-0.1.0/backend/app/graph.py +182 -0
  12. django_vista-0.1.0/backend/app/main.py +105 -0
  13. django_vista-0.1.0/backend/app/management/__init__.py +1 -0
  14. django_vista-0.1.0/backend/app/management/commands/__init__.py +1 -0
  15. django_vista-0.1.0/backend/app/management/commands/showmodels.py +35 -0
  16. django_vista-0.1.0/backend/app/migrations.py +41 -0
  17. django_vista-0.1.0/backend/app/parser.py +140 -0
  18. django_vista-0.1.0/backend/app/scanner.py +20 -0
  19. django_vista-0.1.0/backend/app/schemas.py +49 -0
  20. django_vista-0.1.0/backend/app/static/assets/elk.bundled-CHu_vuKB.js +24 -0
  21. django_vista-0.1.0/backend/app/static/assets/index-CFhIuoIF.js +24 -0
  22. django_vista-0.1.0/backend/app/static/assets/index-T58dGoVp.css +1 -0
  23. django_vista-0.1.0/backend/app/static/favicon.svg +1 -0
  24. django_vista-0.1.0/backend/app/static/icons.svg +24 -0
  25. django_vista-0.1.0/backend/app/static/index.html +15 -0
  26. django_vista-0.1.0/backend/app/watcher.py +128 -0
  27. django_vista-0.1.0/backend/app/websocket.py +49 -0
  28. django_vista-0.1.0/backend/tests/test_cli.py +38 -0
  29. django_vista-0.1.0/backend/tests/test_editor.py +60 -0
  30. django_vista-0.1.0/backend/tests/test_graph.py +195 -0
  31. django_vista-0.1.0/backend/tests/test_live.py +244 -0
  32. django_vista-0.1.0/backend/tests/test_migrations.py +45 -0
  33. django_vista-0.1.0/backend/tests/test_showmodels.py +62 -0
  34. django_vista-0.1.0/backend/tests/test_special_fields.py +53 -0
  35. django_vista-0.1.0/django_vista.egg-info/PKG-INFO +229 -0
  36. django_vista-0.1.0/django_vista.egg-info/SOURCES.txt +80 -0
  37. django_vista-0.1.0/django_vista.egg-info/dependency_links.txt +1 -0
  38. django_vista-0.1.0/django_vista.egg-info/entry_points.txt +2 -0
  39. django_vista-0.1.0/django_vista.egg-info/requires.txt +8 -0
  40. django_vista-0.1.0/django_vista.egg-info/top_level.txt +1 -0
  41. django_vista-0.1.0/docs/DISTRIBUTION.md +37 -0
  42. django_vista-0.1.0/docs/GIT_SETUP.md +47 -0
  43. django_vista-0.1.0/docs/GRAPH_CONTRACT.md +54 -0
  44. django_vista-0.1.0/docs/VALIDATION.md +73 -0
  45. django_vista-0.1.0/docs/ai/architecture.md +66 -0
  46. django_vista-0.1.0/docs/ai/database.md +50 -0
  47. django_vista-0.1.0/docs/ai/decisions.md +30 -0
  48. django_vista-0.1.0/docs/ai/overview.md +17 -0
  49. django_vista-0.1.0/docs/ai/progress.md +69 -0
  50. django_vista-0.1.0/examples/sample_project/README.md +8 -0
  51. django_vista-0.1.0/examples/sample_project/accounts/models.py +20 -0
  52. django_vista-0.1.0/examples/sample_project/catalog/models/__init__.py +1 -0
  53. django_vista-0.1.0/examples/sample_project/catalog/models/products.py +19 -0
  54. django_vista-0.1.0/examples/sample_project/orders/models.py +13 -0
  55. django_vista-0.1.0/frontend/.env.example +1 -0
  56. django_vista-0.1.0/frontend/README.md +23 -0
  57. django_vista-0.1.0/frontend/index.html +14 -0
  58. django_vista-0.1.0/frontend/package-lock.json +2026 -0
  59. django_vista-0.1.0/frontend/package.json +32 -0
  60. django_vista-0.1.0/frontend/public/favicon.svg +1 -0
  61. django_vista-0.1.0/frontend/public/icons.svg +24 -0
  62. django_vista-0.1.0/frontend/src/app/App.tsx +37 -0
  63. django_vista-0.1.0/frontend/src/components/diagram/Diagram.tsx +103 -0
  64. django_vista-0.1.0/frontend/src/components/diagram/FieldEditor.tsx +45 -0
  65. django_vista-0.1.0/frontend/src/components/diagram/MigrationPanel.tsx +31 -0
  66. django_vista-0.1.0/frontend/src/components/diagram/ModelNode.tsx +21 -0
  67. django_vista-0.1.0/frontend/src/hooks/useGraph.ts +57 -0
  68. django_vista-0.1.0/frontend/src/index.css +18 -0
  69. django_vista-0.1.0/frontend/src/main.tsx +12 -0
  70. django_vista-0.1.0/frontend/src/services/api.ts +9 -0
  71. django_vista-0.1.0/frontend/src/services/graph.ts +6 -0
  72. django_vista-0.1.0/frontend/src/services/session.ts +13 -0
  73. django_vista-0.1.0/frontend/src/types/graph.ts +42 -0
  74. django_vista-0.1.0/frontend/tests/session.test.ts +32 -0
  75. django_vista-0.1.0/frontend/tsconfig.app.json +26 -0
  76. django_vista-0.1.0/frontend/tsconfig.json +7 -0
  77. django_vista-0.1.0/frontend/tsconfig.node.json +23 -0
  78. django_vista-0.1.0/frontend/vite.config.ts +8 -0
  79. django_vista-0.1.0/pyproject.toml +41 -0
  80. django_vista-0.1.0/scripts/build_release.py +25 -0
  81. django_vista-0.1.0/scripts/check_install.py +44 -0
  82. django_vista-0.1.0/setup.cfg +4 -0
@@ -0,0 +1,81 @@
1
+ # Contributing to DjangoVista
2
+
3
+ DjangoVista is a local Django model explorer built with Python, FastAPI, React,
4
+ and TypeScript. Bug reports, documentation improvements, and focused pull
5
+ requests are welcome. All user-facing text and project documentation use English.
6
+
7
+ ## Development setup
8
+
9
+ Use Python 3.12+ and Node 24+. From the repository root:
10
+
11
+ ```bash
12
+ python3 -m venv .venv
13
+ source .venv/bin/activate
14
+ python -m pip install -e . build
15
+ python -m uvicorn django_vista.main:app --reload
16
+ ```
17
+
18
+ In a second terminal:
19
+
20
+ ```bash
21
+ cd frontend
22
+ npm ci
23
+ npm run dev
24
+ ```
25
+
26
+ On Windows, activate the environment with `.venv\Scripts\activate`.
27
+ See [README.md](README.md) for usage, optional Django integration, and limitations.
28
+
29
+ ## Checks
30
+
31
+ Run backend checks from the root with the virtual environment activated:
32
+
33
+ ```bash
34
+ PYTHONPATH=backend python -m unittest discover -s backend/tests -v
35
+ ```
36
+
37
+ Run frontend checks from `frontend/`:
38
+
39
+ ```bash
40
+ npm run test
41
+ npm run build
42
+ npm run lint
43
+ ```
44
+
45
+ For changes to packaging, names, entry points, or bundled assets, also run from
46
+ the root:
47
+
48
+ ```bash
49
+ python scripts/build_release.py --skip-install
50
+ python -m pip install --force-reinstall --no-deps dist/django_vista-0.1.0-py3-none-any.whl
51
+ django-vista --version
52
+ django-vista graph examples/sample_project --output /tmp/django-vista-graph.json
53
+ python scripts/check_install.py
54
+ ```
55
+
56
+ GitHub Actions performs these checks on Python 3.12 and Node 24. Local validation
57
+ on another supported version does not replace that CI run.
58
+
59
+ ## Implementation boundaries
60
+
61
+ Keep project analysis static: never import or execute scanned project code.
62
+ Explicit migration checks and Django management-command startup have documented
63
+ runtime behavior. Add small source fixtures for parser changes, testing resolved
64
+ edges and diagnostics. Preserve source formatting and comments during field edits.
65
+
66
+ Discuss graph-contract changes before changing its shape. Keep the backend schema,
67
+ frontend types, and [graph contract](docs/GRAPH_CONTRACT.md) aligned. Keep generated
68
+ frontend assets out of commits; `scripts/build_release.py` bundles them into releases.
69
+
70
+ ## Reports and pull requests
71
+
72
+ For a bug report, include Python/Node versions, operating system, the command,
73
+ expected and actual behavior, and a minimal anonymized model snippet. Do not post
74
+ proprietary source, environment files, or credentials.
75
+
76
+ Pull requests should explain the behavior change and relevant validation. Keep
77
+ changes focused and update affected documentation. Package and marketplace
78
+ publishing happen separately from feature development.
79
+
80
+ For initial repository connection and push instructions, see
81
+ [Git setup](docs/GIT_SETUP.md).
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DjangoVista contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,13 @@
1
+ include LICENSE README.md
2
+ recursive-include backend/app/static *
3
+ include CONTRIBUTING.md PLAN.md
4
+ recursive-include docs *.md
5
+ recursive-include examples *.py *.md
6
+ recursive-include backend/tests *.py
7
+ recursive-include scripts *.py
8
+ recursive-include frontend/src *.ts *.tsx *.css
9
+ recursive-include frontend/public *.svg
10
+ recursive-include frontend/tests *.ts
11
+ include frontend/README.md
12
+ include frontend/package.json frontend/package-lock.json frontend/tsconfig*.json
13
+ include frontend/vite.config.ts frontend/index.html frontend/.env.example
@@ -0,0 +1,229 @@
1
+ Metadata-Version: 2.4
2
+ Name: django-vista
3
+ Version: 0.1.0
4
+ Summary: Static Django model diagrams with live local updates
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://github.com/Jamshid057/Django-Vista
7
+ Project-URL: Repository, https://github.com/Jamshid057/Django-Vista
8
+ Project-URL: Issues, https://github.com/Jamshid057/Django-Vista/issues
9
+ Keywords: django,models,diagram,er,developer-tools
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Framework :: Django
12
+ Classifier: Programming Language :: Python :: 3
13
+ Requires-Python: >=3.12
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: fastapi>=0.116
17
+ Requires-Dist: uvicorn>=0.35
18
+ Requires-Dist: watchdog>=6.0
19
+ Requires-Dist: pydantic>=2.11
20
+ Requires-Dist: websockets>=15.0
21
+ Provides-Extra: django
22
+ Requires-Dist: Django>=4.2; extra == "django"
23
+ Dynamic: license-file
24
+
25
+ # DjangoVista
26
+
27
+ A local, open-source Django model explorer. DjangoVista reads Python source with
28
+ AST, builds an interactive model diagram and refreshes it when source files change.
29
+ Diagram scanning does not import your Django project, run its code or connect to a database. The optional migration check runs Django explicitly.
30
+
31
+ Status: **0.1.0 alpha**. PyPI and editor marketplace releases are not published yet.
32
+ The distribution and CLI are named `django-vista`; the Python import is `django_vista`.
33
+
34
+ Source: [Jamshid057/Django-Vista](https://github.com/Jamshid057/Django-Vista).
35
+ Report bugs through [GitHub Issues](https://github.com/Jamshid057/Django-Vista/issues).
36
+
37
+ ## Features
38
+
39
+ - Module-qualified model identities, import aliases and split model packages.
40
+ - Fields, primary/composite keys, nullability and uniqueness.
41
+ - ForeignKey, OneToOneField, ManyToManyField and explicit through models.
42
+ - Abstract/proxy models and concrete inheritance parent links.
43
+ - Partial graphs with actionable syntax and unresolved-reference diagnostics.
44
+ - Model cards, automatic ELK layout, search, app filtering, minimap and zoom.
45
+ - Debounced live snapshots over WebSocket, reconnect and preserved node positions.
46
+ - Python library, JSON export CLI and a local server with bundled release UI.
47
+
48
+ ## Install from source
49
+
50
+ Python 3.12+ and Node 24+ are needed
51
+ for building from source. Released wheels include the UI and will not require Node.
52
+
53
+ ```bash
54
+ git clone https://github.com/Jamshid057/Django-Vista.git
55
+ cd Django-Vista
56
+ python3 -m venv .venv
57
+ source .venv/bin/activate
58
+ python -m pip install --upgrade pip
59
+ python scripts/build_release.py --bundle-only
60
+ python -m pip install .
61
+ django-vista serve /absolute/path/to/django-project
62
+ ```
63
+
64
+ On Windows activate `.venv\Scripts\activate` instead. The server binds to
65
+ `127.0.0.1:8000`; use `--port 8001` to choose another port or `--no-browser` to avoid
66
+ opening a browser. The project path is local to the computer running the backend.
67
+
68
+ ```bash
69
+ django-vista graph /path/to/project --output graph.json
70
+ ```
71
+
72
+ Library use:
73
+
74
+ ```python
75
+ from pathlib import Path
76
+ from django_vista import build_graph
77
+
78
+ graph = build_graph(Path("/path/to/project"))
79
+ print(graph.model_dump_json(indent=2))
80
+ ```
81
+
82
+ ## Open from manage.py
83
+
84
+ Install DjangoVista into your Django project's virtual environment:
85
+
86
+ ```bash
87
+ python -m pip install /absolute/path/to/django-vista
88
+ ```
89
+
90
+ Add `"django_vista"` to your project's `INSTALLED_APPS`:
91
+
92
+ ```python
93
+ INSTALLED_APPS = [
94
+ # Your existing apps ...
95
+ "django_vista",
96
+ ]
97
+ ```
98
+
99
+ Then launch from the project terminal:
100
+
101
+ ```bash
102
+ python manage.py showmodels
103
+ python manage.py showmodels --port 8001
104
+ python manage.py showmodels --no-browser
105
+ ```
106
+
107
+ The command opens the diagram in your browser and serves it until Ctrl+C.
108
+ It uses the directory containing `manage.py`, falling back to `BASE_DIR` for
109
+ programmatic invocation. Use `--project /path/to/project` to override it.
110
+ Django loads your installed apps when invoking management commands; the diagram
111
+ scanner itself remains static. Command startup does not run migration checks.
112
+
113
+ ## Development
114
+
115
+ Install the Python package in editable mode at the repository root:
116
+
117
+ ```bash
118
+ python -m pip install -e .
119
+ python -m uvicorn django_vista.main:app --reload
120
+ ```
121
+
122
+ In a second terminal:
123
+
124
+ ```bash
125
+ cd frontend
126
+ npm ci
127
+ npm run dev
128
+ ```
129
+
130
+ Open `http://localhost:5173` and enter the Django project directory. You can use the
131
+ absolute path to `examples/sample_project` for a source-only demonstration. Those
132
+ fixtures do not need Django installed and are not a runnable Django application.
133
+
134
+ The Vite UI uses `http://127.0.0.1:8000` by default; `frontend/.env.example` documents
135
+ `VITE_API_URL`. Bundled UI connects to its own server origin. Standard local Vite
136
+ origins are allowed for HTTP and WebSocket; production remote hosting is outside
137
+ this release's scope.
138
+
139
+ ## Checks
140
+
141
+ ```bash
142
+ PYTHONPATH=backend python -m unittest discover -s backend/tests -v
143
+ cd frontend
144
+ npm run build
145
+ npm run lint
146
+ npm run test
147
+ ```
148
+
149
+ Backend tests cover parser behavior and in-process HTTP/WebSocket/watcher lifecycle.
150
+ See [validation results](docs/VALIDATION.md), [graph contract](docs/GRAPH_CONTRACT.md)
151
+ and [implementation plan](PLAN.md).
152
+
153
+ ## Build a release
154
+
155
+ ```bash
156
+ python -m pip install build
157
+ python scripts/build_release.py
158
+ python -m pip install dist/django_vista-0.1.0-py3-none-any.whl
159
+ ```
160
+
161
+ The build script compiles the frontend, copies it into the Python package and
162
+ builds a wheel and source archive. Generated UI/build output is ignored by Git.
163
+ Use `--skip-install` when frontend dependencies are already installed.
164
+
165
+ Publishing to PyPI is a separate release action. No package or extension has been
166
+ published by this implementation.
167
+
168
+ ## Static analysis limitations
169
+
170
+ Static analysis cannot reproduce arbitrary Django runtime behavior. Conditional
171
+ model definitions, dynamically generated fields, custom field behavior, wildcard
172
+ imports and model classes supplied only by unscanned dependencies are unsupported.
173
+ Known unresolved fields, relationships and bases produce diagnostics; no target is
174
+ guessed. Implicit IDs use a placeholder AutoField because project
175
+ `DEFAULT_AUTO_FIELD` is not evaluated. Abstract nodes are displayed for context;
176
+ concrete inherited storage is represented through parent links.
177
+
178
+ Live updates use filtered filesystem polling (1 second) and debounce (0.2
179
+ seconds), rescan the project and send full snapshots. Incremental
180
+ parsing should follow measured need. Source scanning excludes environments,
181
+ migrations, caches, build directories and symlinks.
182
+
183
+ ## Open-source and editor integrations
184
+
185
+ The Python library and local API are the reusable core. VS Code and PyCharm
186
+ extensions can later start `django-vista serve --no-browser`, display the diagram in
187
+ an editor panel and reuse the same graph protocol. See the
188
+ [distribution roadmap](docs/DISTRIBUTION.md). Editor extensions are not implemented
189
+ in this alpha.
190
+
191
+ Contributions are welcome; see [CONTRIBUTING.md](CONTRIBUTING.md).
192
+ Licensed under [MIT](LICENSE).
193
+
194
+ ## Diagram editing and migration status
195
+
196
+ Double-click a model to open the field editor. Add standard scalar fields or edit
197
+ `null`, `blank`, `unique`, and length/decimal parameters of declared fields.
198
+ Preview shows a unified source diff; Apply writes the model file. A file revision
199
+ check rejects stale previews. Existing methods, comments, imports, and unrelated
200
+ field arguments are preserved. Field renaming, deletion, type changes, relationship
201
+ editing, and model creation are not implemented yet.
202
+
203
+ Open **Migration status** in the sidebar and click **Check migrations**. This is an
204
+ explicit runtime feature: it runs the project's Django code and reads migration
205
+ history from the default database. Enter the project's absolute Python interpreter
206
+ path, or let DjangoVista detect `.venv`/`venv`; it falls back to the server Python.
207
+ The opened directory must contain `manage.py`.
208
+
209
+ The panel shows `makemigrations --dry-run --verbosity 3` output, checks for missing
210
+ migration files, and lists applied/pending migrations with `showmigrations --plan`.
211
+ It does not create migration files or apply migrations. Run the displayed
212
+ `makemigrations` and `migrate` commands in the project console, then check again.
213
+ Checks are manual; source updates mark the last result stale. Database errors are
214
+ shown as errors rather than an up-to-date status. Checks have a per-command timeout.
215
+
216
+ ## Repository and package naming
217
+
218
+ | Surface | Name |
219
+ | --- | --- |
220
+ | Project | DjangoVista |
221
+ | Python distribution / repository | `django-vista` |
222
+ | Terminal command | `django-vista` |
223
+ | Python import / Django installed app | `django_vista` |
224
+
225
+ The source directory remains `backend/app/`; setuptools maps it to `django_vista`
226
+ when installed. Use `django_vista` in Python code, not the hyphenated package name.
227
+
228
+ See [contributing](CONTRIBUTING.md) for development checks and
229
+ [Git setup](docs/GIT_SETUP.md) for connecting this source tree to a remote.
@@ -0,0 +1,121 @@
1
+ # DjangoVista implementation workflow
2
+
3
+ Status: MVP implemented and automated checks passed. Browser acceptance,
4
+ clean online dependency installation and cross-platform release validation remain.
5
+ See docs/VALIDATION.md for measured results and environment limits.
6
+
7
+ ## Target
8
+
9
+ Deliver a local development tool that reads a selected Django project without
10
+ executing its code, renders its models and relationships, and updates the diagram
11
+ after source changes. Unsupported constructs must produce diagnostics rather than
12
+ silently incorrect results. Remote hosting and editor integrations are outside MVP.
13
+
14
+ ## Orchestration
15
+
16
+ - Lead agent: architecture, API contract, task dependencies, integration and final review.
17
+ - Backend agent: scanner, registry, import resolution, fields and graph generation.
18
+ - Frontend agent: typed API client, project selection, model nodes and layout.
19
+ - Validation agent: independent fixture coverage and acceptance review.
20
+
21
+ At most four agents run together, including the lead. Assign separate file
22
+ ownership before parallel edits. Freeze the graph contract before backend and
23
+ frontend implementation. Integration and dependent steps run sequentially.
24
+ Every handoff includes changed files, validation results and remaining limitations.
25
+
26
+ ## 1. Baseline and contract
27
+
28
+ - Fix frontend TypeScript build errors and type API responses.
29
+ - Align README installation with the root pip package and release build.
30
+ - Define stable model IDs, field IDs, relationship IDs and graph diagnostics.
31
+ - Include model app/module/name, field metadata, relationship kind and endpoints.
32
+ - Define HTTP validation errors and WebSocket snapshot/revision messages.
33
+ - Establish focused Django-source fixtures and reproducible local commands.
34
+
35
+ Acceptance: frontend build and lint pass; contract is documented and backend
36
+ responses are validated by Pydantic; a minimal fixture renders end to end.
37
+
38
+ ## 2. Scanner and registry
39
+
40
+ - Validate project roots and restrict scanning to the selected project.
41
+ - Exclude environments, caches, migrations and generated directories.
42
+ - Support models.py and models packages with deterministic discovery.
43
+ - Use module-qualified class identities; preserve app labels when discoverable.
44
+ - Resolve imports and aliases without importing or executing project code.
45
+ - Detect inheritance cycles and distinguish Django Model from unrelated classes.
46
+ - Collect per-file read/syntax diagnostics without losing valid files.
47
+
48
+ Acceptance: same-name models in different apps coexist; Model aliases and local
49
+ inheritance resolve; cycles and invalid files produce diagnostics; missing paths
50
+ produce actionable errors. External unresolved imports are explicitly reported.
51
+
52
+ ## 3. Fields and relationships
53
+
54
+ - Parse assigned and annotated Django field declarations and common options.
55
+ - Resolve ForeignKey, OneToOneField and ManyToManyField targets, including
56
+ class references, self, ModelName and app_label.ModelName strings.
57
+ - Handle abstract inheritance, proxy models, implicit primary keys and concrete
58
+ parent links with documented representation rules.
59
+ - Represent explicit through models and on_delete/related_name metadata.
60
+ - Preserve unresolved relationships as diagnostics; do not guess targets.
61
+ - Implement graph construction separately from HTTP handlers.
62
+
63
+ Acceptance: fixture graphs cover each relation kind, inheritance and name
64
+ collisions; stable IDs persist across rescans; API output matches the contract.
65
+
66
+ ## 4. Diagram UI
67
+
68
+ - Replace the hardcoded project path with a local project-path input.
69
+ - Add loading, error, empty and partial-result states with diagnostics.
70
+ - Render model cards with field types, keys and relationship handles.
71
+ - Apply ELK layout; support drag, pan, zoom, minimap and fit view.
72
+ - Add model search and app filtering.
73
+ - Handle request cancellation and stale responses; configure backend URL.
74
+
75
+ Acceptance: a project can be opened without source edits; populated cards and
76
+ correct edges render; failed requests are visible; rapid project switches never
77
+ display an older project's result.
78
+
79
+ ## 5. Live synchronization
80
+
81
+ - Manage watchdog observers through application lifecycle.
82
+ - Debounce bursts of create, update, delete and rename events.
83
+ - Rescan and publish revisioned full graph snapshots first.
84
+ - Reconnect WebSocket clients and fetch a current snapshot after reconnect.
85
+ - Retain node positions and selection for models that still exist.
86
+ - Clean up observers and connections on project changes and shutdown.
87
+
88
+ Acceptance: editing, renaming and deleting fixture files updates the UI without
89
+ reload; transient syntax errors appear as diagnostics; reconnect restores current
90
+ state; switching projects stops old subscriptions.
91
+
92
+ ## 6. Validation and delivery
93
+
94
+ - Run focused backend fixture tests, frontend build and lint.
95
+ - Verify selection -> scan -> graph -> edit -> live update -> reconnect end to end.
96
+ - Measure initial scan, layout and update latency on a documented larger fixture.
97
+ - Fix reproducible issues and document unsupported dynamic Django constructs.
98
+ - Update README with actual features, installation, limitations and usage.
99
+
100
+ Acceptance: checks pass, acceptance scenarios are verified, performance results
101
+ are recorded and documented setup works from a clean dependency installation.
102
+
103
+ ## Dependency order
104
+
105
+ 1 -> 2 -> 3 -> 5 -> 6. Frontend step 4 can run alongside 2 and 3 once the contract
106
+ from step 1 is fixed. Validation fixtures can be developed alongside implementation
107
+ without editing implementation-owned files.
108
+
109
+ ## After MVP
110
+
111
+ Incremental parsing based on measured bottlenecks, image export, saved layouts,
112
+ editor integrations and Django Admin integration. Schedule these after MVP
113
+ acceptance rather than making them prerequisites.
114
+
115
+ ## Distribution work added to scope
116
+
117
+ Implemented root setuptools packaging, public Python API, graph JSON CLI, local
118
+ server CLI, bundled release UI, MIT license, contribution guide and validation CI.
119
+ The built wheel and source archive are in dist/. PyPI and editor marketplace
120
+ publishing remain separate; VS Code/PyCharm integration design is documented in
121
+ docs/DISTRIBUTION.md, with no extensions advertised as implemented.
@@ -0,0 +1,205 @@
1
+ # DjangoVista
2
+
3
+ A local, open-source Django model explorer. DjangoVista reads Python source with
4
+ AST, builds an interactive model diagram and refreshes it when source files change.
5
+ Diagram scanning does not import your Django project, run its code or connect to a database. The optional migration check runs Django explicitly.
6
+
7
+ Status: **0.1.0 alpha**. PyPI and editor marketplace releases are not published yet.
8
+ The distribution and CLI are named `django-vista`; the Python import is `django_vista`.
9
+
10
+ Source: [Jamshid057/Django-Vista](https://github.com/Jamshid057/Django-Vista).
11
+ Report bugs through [GitHub Issues](https://github.com/Jamshid057/Django-Vista/issues).
12
+
13
+ ## Features
14
+
15
+ - Module-qualified model identities, import aliases and split model packages.
16
+ - Fields, primary/composite keys, nullability and uniqueness.
17
+ - ForeignKey, OneToOneField, ManyToManyField and explicit through models.
18
+ - Abstract/proxy models and concrete inheritance parent links.
19
+ - Partial graphs with actionable syntax and unresolved-reference diagnostics.
20
+ - Model cards, automatic ELK layout, search, app filtering, minimap and zoom.
21
+ - Debounced live snapshots over WebSocket, reconnect and preserved node positions.
22
+ - Python library, JSON export CLI and a local server with bundled release UI.
23
+
24
+ ## Install from source
25
+
26
+ Python 3.12+ and Node 24+ are needed
27
+ for building from source. Released wheels include the UI and will not require Node.
28
+
29
+ ```bash
30
+ git clone https://github.com/Jamshid057/Django-Vista.git
31
+ cd Django-Vista
32
+ python3 -m venv .venv
33
+ source .venv/bin/activate
34
+ python -m pip install --upgrade pip
35
+ python scripts/build_release.py --bundle-only
36
+ python -m pip install .
37
+ django-vista serve /absolute/path/to/django-project
38
+ ```
39
+
40
+ On Windows activate `.venv\Scripts\activate` instead. The server binds to
41
+ `127.0.0.1:8000`; use `--port 8001` to choose another port or `--no-browser` to avoid
42
+ opening a browser. The project path is local to the computer running the backend.
43
+
44
+ ```bash
45
+ django-vista graph /path/to/project --output graph.json
46
+ ```
47
+
48
+ Library use:
49
+
50
+ ```python
51
+ from pathlib import Path
52
+ from django_vista import build_graph
53
+
54
+ graph = build_graph(Path("/path/to/project"))
55
+ print(graph.model_dump_json(indent=2))
56
+ ```
57
+
58
+ ## Open from manage.py
59
+
60
+ Install DjangoVista into your Django project's virtual environment:
61
+
62
+ ```bash
63
+ python -m pip install /absolute/path/to/django-vista
64
+ ```
65
+
66
+ Add `"django_vista"` to your project's `INSTALLED_APPS`:
67
+
68
+ ```python
69
+ INSTALLED_APPS = [
70
+ # Your existing apps ...
71
+ "django_vista",
72
+ ]
73
+ ```
74
+
75
+ Then launch from the project terminal:
76
+
77
+ ```bash
78
+ python manage.py showmodels
79
+ python manage.py showmodels --port 8001
80
+ python manage.py showmodels --no-browser
81
+ ```
82
+
83
+ The command opens the diagram in your browser and serves it until Ctrl+C.
84
+ It uses the directory containing `manage.py`, falling back to `BASE_DIR` for
85
+ programmatic invocation. Use `--project /path/to/project` to override it.
86
+ Django loads your installed apps when invoking management commands; the diagram
87
+ scanner itself remains static. Command startup does not run migration checks.
88
+
89
+ ## Development
90
+
91
+ Install the Python package in editable mode at the repository root:
92
+
93
+ ```bash
94
+ python -m pip install -e .
95
+ python -m uvicorn django_vista.main:app --reload
96
+ ```
97
+
98
+ In a second terminal:
99
+
100
+ ```bash
101
+ cd frontend
102
+ npm ci
103
+ npm run dev
104
+ ```
105
+
106
+ Open `http://localhost:5173` and enter the Django project directory. You can use the
107
+ absolute path to `examples/sample_project` for a source-only demonstration. Those
108
+ fixtures do not need Django installed and are not a runnable Django application.
109
+
110
+ The Vite UI uses `http://127.0.0.1:8000` by default; `frontend/.env.example` documents
111
+ `VITE_API_URL`. Bundled UI connects to its own server origin. Standard local Vite
112
+ origins are allowed for HTTP and WebSocket; production remote hosting is outside
113
+ this release's scope.
114
+
115
+ ## Checks
116
+
117
+ ```bash
118
+ PYTHONPATH=backend python -m unittest discover -s backend/tests -v
119
+ cd frontend
120
+ npm run build
121
+ npm run lint
122
+ npm run test
123
+ ```
124
+
125
+ Backend tests cover parser behavior and in-process HTTP/WebSocket/watcher lifecycle.
126
+ See [validation results](docs/VALIDATION.md), [graph contract](docs/GRAPH_CONTRACT.md)
127
+ and [implementation plan](PLAN.md).
128
+
129
+ ## Build a release
130
+
131
+ ```bash
132
+ python -m pip install build
133
+ python scripts/build_release.py
134
+ python -m pip install dist/django_vista-0.1.0-py3-none-any.whl
135
+ ```
136
+
137
+ The build script compiles the frontend, copies it into the Python package and
138
+ builds a wheel and source archive. Generated UI/build output is ignored by Git.
139
+ Use `--skip-install` when frontend dependencies are already installed.
140
+
141
+ Publishing to PyPI is a separate release action. No package or extension has been
142
+ published by this implementation.
143
+
144
+ ## Static analysis limitations
145
+
146
+ Static analysis cannot reproduce arbitrary Django runtime behavior. Conditional
147
+ model definitions, dynamically generated fields, custom field behavior, wildcard
148
+ imports and model classes supplied only by unscanned dependencies are unsupported.
149
+ Known unresolved fields, relationships and bases produce diagnostics; no target is
150
+ guessed. Implicit IDs use a placeholder AutoField because project
151
+ `DEFAULT_AUTO_FIELD` is not evaluated. Abstract nodes are displayed for context;
152
+ concrete inherited storage is represented through parent links.
153
+
154
+ Live updates use filtered filesystem polling (1 second) and debounce (0.2
155
+ seconds), rescan the project and send full snapshots. Incremental
156
+ parsing should follow measured need. Source scanning excludes environments,
157
+ migrations, caches, build directories and symlinks.
158
+
159
+ ## Open-source and editor integrations
160
+
161
+ The Python library and local API are the reusable core. VS Code and PyCharm
162
+ extensions can later start `django-vista serve --no-browser`, display the diagram in
163
+ an editor panel and reuse the same graph protocol. See the
164
+ [distribution roadmap](docs/DISTRIBUTION.md). Editor extensions are not implemented
165
+ in this alpha.
166
+
167
+ Contributions are welcome; see [CONTRIBUTING.md](CONTRIBUTING.md).
168
+ Licensed under [MIT](LICENSE).
169
+
170
+ ## Diagram editing and migration status
171
+
172
+ Double-click a model to open the field editor. Add standard scalar fields or edit
173
+ `null`, `blank`, `unique`, and length/decimal parameters of declared fields.
174
+ Preview shows a unified source diff; Apply writes the model file. A file revision
175
+ check rejects stale previews. Existing methods, comments, imports, and unrelated
176
+ field arguments are preserved. Field renaming, deletion, type changes, relationship
177
+ editing, and model creation are not implemented yet.
178
+
179
+ Open **Migration status** in the sidebar and click **Check migrations**. This is an
180
+ explicit runtime feature: it runs the project's Django code and reads migration
181
+ history from the default database. Enter the project's absolute Python interpreter
182
+ path, or let DjangoVista detect `.venv`/`venv`; it falls back to the server Python.
183
+ The opened directory must contain `manage.py`.
184
+
185
+ The panel shows `makemigrations --dry-run --verbosity 3` output, checks for missing
186
+ migration files, and lists applied/pending migrations with `showmigrations --plan`.
187
+ It does not create migration files or apply migrations. Run the displayed
188
+ `makemigrations` and `migrate` commands in the project console, then check again.
189
+ Checks are manual; source updates mark the last result stale. Database errors are
190
+ shown as errors rather than an up-to-date status. Checks have a per-command timeout.
191
+
192
+ ## Repository and package naming
193
+
194
+ | Surface | Name |
195
+ | --- | --- |
196
+ | Project | DjangoVista |
197
+ | Python distribution / repository | `django-vista` |
198
+ | Terminal command | `django-vista` |
199
+ | Python import / Django installed app | `django_vista` |
200
+
201
+ The source directory remains `backend/app/`; setuptools maps it to `django_vista`
202
+ when installed. Use `django_vista` in Python code, not the hyphenated package name.
203
+
204
+ See [contributing](CONTRIBUTING.md) for development checks and
205
+ [Git setup](docs/GIT_SETUP.md) for connecting this source tree to a remote.
@@ -0,0 +1,6 @@
1
+ """Public static analysis API for DjangoVista."""
2
+ from .graph import build_graph
3
+ from .schemas import GraphSchema
4
+
5
+ __version__ = '0.1.0'
6
+ __all__ = ['build_graph', 'GraphSchema', '__version__']
@@ -0,0 +1,7 @@
1
+ from django.apps import AppConfig
2
+
3
+
4
+ class DjangoVistaConfig(AppConfig):
5
+ name = 'django_vista'
6
+ verbose_name = 'DjangoVista'
7
+ default_auto_field = 'django.db.models.BigAutoField'