ses-intelligence 1.0.0b1__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 (66) hide show
  1. ses_intelligence-1.0.0b1/PKG-INFO +1054 -0
  2. ses_intelligence-1.0.0b1/README.md +1006 -0
  3. ses_intelligence-1.0.0b1/pyproject.toml +108 -0
  4. ses_intelligence-1.0.0b1/ses_intelligence/__init__.py +73 -0
  5. ses_intelligence-1.0.0b1/ses_intelligence/architecture_health/__init__.py +0 -0
  6. ses_intelligence-1.0.0b1/ses_intelligence/architecture_health/confidence.py +242 -0
  7. ses_intelligence-1.0.0b1/ses_intelligence/architecture_health/degradation.py +173 -0
  8. ses_intelligence-1.0.0b1/ses_intelligence/architecture_health/engine.py +225 -0
  9. ses_intelligence-1.0.0b1/ses_intelligence/architecture_health/escalation.py +120 -0
  10. ses_intelligence-1.0.0b1/ses_intelligence/architecture_health/forecasting.py +340 -0
  11. ses_intelligence-1.0.0b1/ses_intelligence/architecture_health/health_score.py +86 -0
  12. ses_intelligence-1.0.0b1/ses_intelligence/architecture_health/history.py +146 -0
  13. ses_intelligence-1.0.0b1/ses_intelligence/architecture_health/impact.py +85 -0
  14. ses_intelligence-1.0.0b1/ses_intelligence/architecture_health/risk_labels.py +73 -0
  15. ses_intelligence-1.0.0b1/ses_intelligence/architecture_health/stability_index.py +95 -0
  16. ses_intelligence-1.0.0b1/ses_intelligence/architecture_health/trend.py +70 -0
  17. ses_intelligence-1.0.0b1/ses_intelligence/behavior_change/__init__.py +0 -0
  18. ses_intelligence-1.0.0b1/ses_intelligence/behavior_change/analysis.py +65 -0
  19. ses_intelligence-1.0.0b1/ses_intelligence/behavior_change/causal.py +36 -0
  20. ses_intelligence-1.0.0b1/ses_intelligence/behavior_change/change_model.py +26 -0
  21. ses_intelligence-1.0.0b1/ses_intelligence/behavior_change/diff.py +48 -0
  22. ses_intelligence-1.0.0b1/ses_intelligence/behavior_change/explain.py +27 -0
  23. ses_intelligence-1.0.0b1/ses_intelligence/behavior_change/history.py +244 -0
  24. ses_intelligence-1.0.0b1/ses_intelligence/behavior_change/snapshot.py +50 -0
  25. ses_intelligence-1.0.0b1/ses_intelligence/behavior_change/store.py +12 -0
  26. ses_intelligence-1.0.0b1/ses_intelligence/behavior_graph.py +36 -0
  27. ses_intelligence-1.0.0b1/ses_intelligence/cli.py +307 -0
  28. ses_intelligence-1.0.0b1/ses_intelligence/config.py +260 -0
  29. ses_intelligence-1.0.0b1/ses_intelligence/llm/__init__.py +16 -0
  30. ses_intelligence-1.0.0b1/ses_intelligence/llm/prompts.py +158 -0
  31. ses_intelligence-1.0.0b1/ses_intelligence/llm/service.py +281 -0
  32. ses_intelligence-1.0.0b1/ses_intelligence/middleware.py +26 -0
  33. ses_intelligence-1.0.0b1/ses_intelligence/ml/__init__.py +0 -0
  34. ses_intelligence-1.0.0b1/ses_intelligence/ml/anomaly.py +73 -0
  35. ses_intelligence-1.0.0b1/ses_intelligence/ml/features.py +151 -0
  36. ses_intelligence-1.0.0b1/ses_intelligence/ml/intelligence_pipeline.py +89 -0
  37. ses_intelligence-1.0.0b1/ses_intelligence/ml/pipeline.py +314 -0
  38. ses_intelligence-1.0.0b1/ses_intelligence/narrative/__init__.py +0 -0
  39. ses_intelligence-1.0.0b1/ses_intelligence/narrative/drivers.py +40 -0
  40. ses_intelligence-1.0.0b1/ses_intelligence/narrative/engine.py +74 -0
  41. ses_intelligence-1.0.0b1/ses_intelligence/narrative/executive.py +24 -0
  42. ses_intelligence-1.0.0b1/ses_intelligence/narrative/explanation.py +345 -0
  43. ses_intelligence-1.0.0b1/ses_intelligence/narrative/forecast_summary.py +43 -0
  44. ses_intelligence-1.0.0b1/ses_intelligence/narrative/refiner.py +101 -0
  45. ses_intelligence-1.0.0b1/ses_intelligence/narrative/synthesizer.py +46 -0
  46. ses_intelligence-1.0.0b1/ses_intelligence/project_storage.py +181 -0
  47. ses_intelligence-1.0.0b1/ses_intelligence/runtime_state.py +180 -0
  48. ses_intelligence-1.0.0b1/ses_intelligence/tracing.py +109 -0
  49. ses_intelligence-1.0.0b1/ses_intelligence/web/__init__.py +7 -0
  50. ses_intelligence-1.0.0b1/ses_intelligence/web/server.py +77 -0
  51. ses_intelligence-1.0.0b1/ses_intelligence/web/settings.py +165 -0
  52. ses_intelligence-1.0.0b1/ses_intelligence/web/static/assets/index-3AgqyxZQ.js +52 -0
  53. ses_intelligence-1.0.0b1/ses_intelligence/web/static/assets/index-DCpCRI0K.css +1 -0
  54. ses_intelligence-1.0.0b1/ses_intelligence/web/static/index.html +34 -0
  55. ses_intelligence-1.0.0b1/ses_intelligence/web/static/vite.svg +1 -0
  56. ses_intelligence-1.0.0b1/ses_intelligence/web/urls.py +41 -0
  57. ses_intelligence-1.0.0b1/ses_intelligence/web/views.py +611 -0
  58. ses_intelligence-1.0.0b1/ses_intelligence/web/wsgi.py +13 -0
  59. ses_intelligence-1.0.0b1/ses_intelligence.egg-info/PKG-INFO +1054 -0
  60. ses_intelligence-1.0.0b1/ses_intelligence.egg-info/SOURCES.txt +64 -0
  61. ses_intelligence-1.0.0b1/ses_intelligence.egg-info/dependency_links.txt +1 -0
  62. ses_intelligence-1.0.0b1/ses_intelligence.egg-info/entry_points.txt +2 -0
  63. ses_intelligence-1.0.0b1/ses_intelligence.egg-info/requires.txt +31 -0
  64. ses_intelligence-1.0.0b1/ses_intelligence.egg-info/top_level.txt +1 -0
  65. ses_intelligence-1.0.0b1/setup.cfg +4 -0
  66. ses_intelligence-1.0.0b1/tests/test_stress.py +323 -0
@@ -0,0 +1,1054 @@
1
+ Metadata-Version: 2.4
2
+ Name: ses-intelligence
3
+ Version: 1.0.0b1
4
+ Summary: Runtime intelligence platform that monitors, analyzes, and explains software behavior changes in real-time
5
+ Author-email: SES Team <team@ses.dev>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/dummy-pranjal29/self-explaining-software
8
+ Project-URL: Documentation, https://ses-intelligence.readthedocs.io
9
+ Project-URL: Repository, https://github.com/dummy-pranjal29/self-explaining-software
10
+ Project-URL: Issues, https://github.com/dummy-pranjal29/self-explaining-software/issues
11
+ Keywords: software-intelligence,runtime-monitoring,behavior-analysis,architecture-health,forecasting,ml,observability
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
22
+ Classifier: Topic :: System :: Monitoring
23
+ Description-Content-Type: text/markdown
24
+ Requires-Dist: networkx>=3.0
25
+ Requires-Dist: numpy>=1.24.0
26
+ Requires-Dist: django>=4.0
27
+ Requires-Dist: djangorestframework>=3.14.0
28
+ Requires-Dist: whitenoise>=6.0
29
+ Provides-Extra: ml
30
+ Requires-Dist: scikit-learn>=1.3.0; extra == "ml"
31
+ Provides-Extra: llm
32
+ Requires-Dist: openai>=1.0.0; extra == "llm"
33
+ Provides-Extra: django
34
+ Requires-Dist: django>=4.0; extra == "django"
35
+ Provides-Extra: fastapi
36
+ Requires-Dist: fastapi>=0.100.0; extra == "fastapi"
37
+ Requires-Dist: uvicorn>=0.23.0; extra == "fastapi"
38
+ Provides-Extra: flask
39
+ Requires-Dist: flask>=2.3.0; extra == "flask"
40
+ Provides-Extra: all
41
+ Requires-Dist: ses-intelligence[django,fastapi,flask,llm,ml]; extra == "all"
42
+ Provides-Extra: dev
43
+ Requires-Dist: pytest>=7.4.0; extra == "dev"
44
+ Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
45
+ Requires-Dist: black>=23.0.0; extra == "dev"
46
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
47
+ Requires-Dist: mypy>=1.5.0; extra == "dev"
48
+
49
+ # SES Intelligence - Self-Evolving Software Platform
50
+
51
+ <p align="center">
52
+ <a href="https://pypi.org/project/ses-intelligence/">
53
+ <img src="https://img.shields.io/pypi/v/ses-intelligence.svg" alt="PyPI Version">
54
+ </a>
55
+ <a href="https://pypi.org/project/ses-intelligence/">
56
+ <img src="https://img.shields.io/pypi/pyversions/ses-intelligence.svg" alt="Python Versions">
57
+ </a>
58
+ <a href="https://opensource.org/licenses/MIT">
59
+ <img src="https://img.shields.io/pypi/l/ses-intelligence.svg" alt="License: MIT">
60
+ </a>
61
+ <a href="https://github.com/dummy-pranjal29/self-explaining-software/actions">
62
+ <img src="https://github.com/dummy-pranjal29/self-explaining-software/actions/workflows/test.yml/badge.svg" alt="Tests">
63
+ </a>
64
+ </p>
65
+
66
+ **SES Intelligence** is a comprehensive runtime intelligence platform that monitors, analyzes, and explains software behavior changes in real-time. It automatically builds architecture graphs from function calls, computes health scores, forecasts potential issues, and provides an interactive dashboard for visualization.
67
+
68
+ ## What is SES?
69
+
70
+ SES (Self-Evolving Software) Intelligence is a full-stack platform consisting of:
71
+
72
+ | Component | Description |
73
+ | ------------- | ------------------------------------------------------ |
74
+ | **SDK** | Framework-agnostic Python library for behavior tracing |
75
+ | **API** | Django REST API for data persistence and management |
76
+ | **Dashboard** | React-based UI for real-time visualization |
77
+
78
+ ### Core Features
79
+
80
+ - **Behavior Tracing**: Automatically captures function call relationships to build dynamic architecture graphs
81
+ - **Health Scoring**: Computes architecture health scores based on complexity, stability, and risk factors
82
+ - **Forecasting**: Predicts future health trends using historical data analysis
83
+ - **Narrative Generation**: Generates human-readable explanations of architecture changes (with LLM)
84
+ - **Interactive Dashboard**: Real-time visualization with live metrics, health gauges, and forecast timelines
85
+
86
+ ---
87
+
88
+ ## Table of Contents
89
+
90
+ 1. [Installation](#installation)
91
+ 2. [Quick Start](#quick-start)
92
+ 3. [SDK Usage](#sdk-usage)
93
+ 4. [API Server](#api-server)
94
+ 5. [Dashboard](#dashboard)
95
+ 6. [Configuration](#configuration)
96
+ 7. [CLI Commands](#cli-commands)
97
+ 8. [API Endpoints](#api-endpoints)
98
+ 9. [Examples](#examples)
99
+ 10. [Troubleshooting](#troubleshooting)
100
+ 11. [When to Expect Changes](#when-to-expect-changes)
101
+ 12. [When NOT to Expect Changes](#when-not-to-expect-changes)
102
+
103
+ ---
104
+
105
+ ## Installation
106
+
107
+ ### Prerequisites
108
+
109
+ | Requirement | Version |
110
+ | ----------- | ------------------- |
111
+ | Python | 3.8+ |
112
+ | Node.js | 18+ (for dashboard) |
113
+ | pip | 21.0+ |
114
+
115
+ ### Install SDK (Python Package)
116
+
117
+ ```bash
118
+ # Install core package (minimal dependencies)
119
+ pip install ses-intelligence
120
+
121
+ # Or with extras for specific features
122
+ pip install ses-intelligence[ml] # ML features for anomaly detection
123
+ pip install ses-intelligence[llm] # LLM-powered explanations
124
+ pip install ses-intelligence[flask] # Flask integration
125
+ pip install ses-intelligence[fastapi] # FastAPI integration
126
+ pip install ses-intelligence[django] # Django integration
127
+
128
+ # Install ALL features
129
+ pip install ses-intelligence[all]
130
+ ```
131
+
132
+ ### Install from Source
133
+
134
+ ```bash
135
+ # Clone the repository
136
+ git clone https://github.com/dummy-pranjal29/self-explaining-software.git
137
+ cd self-explaining-software
138
+
139
+ # Install SDK in development mode
140
+ pip install -e .
141
+
142
+ # Or with all dependencies
143
+ pip install -e ".[all]"
144
+ ```
145
+
146
+ ### Install Dashboard Dependencies
147
+
148
+ ```bash
149
+ # Navigate to dashboard directory
150
+ cd ses-dashboard
151
+
152
+ # Install Node.js dependencies
153
+ npm install
154
+
155
+ # Build for production
156
+ npm run build
157
+ ```
158
+
159
+ ---
160
+
161
+ ## Quick Start
162
+
163
+ ### Option 1: Standalone SDK (5 minutes)
164
+
165
+ Use the SDK directly in your Python application without the API or dashboard.
166
+
167
+ ```python
168
+ from ses_intelligence import initialize, trace_behavior
169
+ from ses_intelligence.architecture_health.engine import ArchitectureHealthEngine
170
+
171
+ # Step 1: Initialize the engine
172
+ initialize(project_id="my-app")
173
+
174
+ # Step 2: Instrument your functions
175
+ @trace_behavior
176
+ def save_user(user_data):
177
+ validate_email(user_data)
178
+ store_in_database(user_data)
179
+ send_welcome_email(user_data)
180
+ return {"status": "success"}
181
+
182
+ @trace_behavior
183
+ def validate_email(user_data):
184
+ if "@" not in user_data.get("email", ""):
185
+ raise ValueError("Invalid email")
186
+ return True
187
+
188
+ @trace_behavior
189
+ def store_in_database(user_data):
190
+ pass # Your DB logic
191
+
192
+ @trace_behavior
193
+ def send_welcome_email(user_data):
194
+ pass # Your email logic
195
+
196
+ # Step 3: Run your code - the engine automatically traces calls
197
+ result = save_user({"name": "John", "email": "john@example.com"})
198
+
199
+ # Step 4: Get health score
200
+ health = ArchitectureHealthEngine().compute()
201
+ print(f"Health: {health['overall_score']}/100")
202
+ print(f"Stability: {health['stability_index']}")
203
+ print(f"Risk Level: {health['risk_level']}")
204
+ ```
205
+
206
+ Run it:
207
+
208
+ ```bash
209
+ python examples/plain_python/example.py
210
+ ```
211
+
212
+ ### Option 2: Full Platform (15 minutes)
213
+
214
+ Run the complete platform: SDK + API + Dashboard.
215
+
216
+ ```bash
217
+ # Step 1: Start the Django API server
218
+ cd /path/to/project
219
+ python manage.py runserver 0.0.0.0:8000
220
+
221
+ # Step 2: In another terminal, start the React dashboard
222
+ cd ses-dashboard
223
+ npm run dev
224
+
225
+ # Step 3: Open your browser
226
+ # - Dashboard: http://localhost:5173
227
+ # - API: http://localhost:8000/api/
228
+ ```
229
+
230
+ ---
231
+
232
+ ## SDK Usage
233
+
234
+ ### Basic Usage
235
+
236
+ ```python
237
+ from ses_intelligence import initialize, trace_behavior, get_runtime_snapshots
238
+ from ses_intelligence.architecture_health.engine import ArchitectureHealthEngine
239
+ from ses_intelligence.architecture_health.forecasting import ArchitectureHealthForecaster
240
+
241
+ # Initialize with project ID
242
+ initialize(
243
+ project_id="my-production-app",
244
+ enable_forecasting=True,
245
+ enable_narratives=True,
246
+ )
247
+
248
+ # Instrument any function
249
+ @trace_behavior
250
+ def process_payment(order_id: int, amount: float):
251
+ authorize_payment(order_id, amount)
252
+ capture_payment(order_id, amount)
253
+ send_receipt(order_id)
254
+ return {"status": "completed"}
255
+
256
+ @trace_behavior
257
+ def authorize_payment(order_id, amount):
258
+ # Payment authorization
259
+ pass
260
+
261
+ @trace_behavior
262
+ def capture_payment(order_id, amount):
263
+ # Payment capture
264
+ pass
265
+
266
+ @trace_behavior
267
+ def send_receipt(order_id):
268
+ # Send receipt email
269
+ pass
270
+
271
+ # Run your application code
272
+ for order in orders:
273
+ process_payment(order["id"], order["amount"])
274
+
275
+ # Get snapshots for analysis
276
+ snapshots = get_runtime_snapshots()
277
+
278
+ # Compute health
279
+ health = ArchitectureHealthEngine(snapshots=snapshots).compute()
280
+
281
+ # Forecast future health
282
+ forecast = ArchitectureHealthForecaster().forecast(steps_ahead=5)
283
+ ```
284
+
285
+ ### Framework-Specific Usage
286
+
287
+ #### Flask
288
+
289
+ ```python
290
+ from flask import Flask, request, jsonify
291
+ from ses_intelligence import initialize, trace_behavior
292
+
293
+ initialize(project_id="flask-app")
294
+
295
+ app = Flask(__name__)
296
+
297
+ @trace_behavior
298
+ def process_request(data):
299
+ validate(data)
300
+ save(data)
301
+ return {"status": "ok"}
302
+
303
+ @trace_behavior
304
+ def validate(data):
305
+ pass
306
+
307
+ @trace_behavior
308
+ def save(data):
309
+ pass
310
+
311
+ @app.route("/api/data", methods=["POST"])
312
+ def handle_data():
313
+ result = process_request(request.json)
314
+ return jsonify(result)
315
+
316
+ if __name__ == "__main__":
317
+ app.run(debug=True, port=5000)
318
+ ```
319
+
320
+ Run:
321
+
322
+ ```bash
323
+ pip install ses-intelligence[flask]
324
+ python examples/flask_app/app.py
325
+ ```
326
+
327
+ #### FastAPI
328
+
329
+ ```python
330
+ from fastapi import FastAPI
331
+ from pydantic import BaseModel
332
+ from ses_intelligence import initialize, trace_behavior
333
+
334
+ initialize(project_id="fastapi-app")
335
+
336
+ app = FastAPI()
337
+
338
+ class Item(BaseModel):
339
+ name: str
340
+ price: float
341
+
342
+ @trace_behavior
343
+ def create_item(item: Item):
344
+ validate_item(item)
345
+ save_item(item)
346
+ return {"id": 1, **item.dict()}
347
+
348
+ @trace_behavior
349
+ def validate_item(item):
350
+ pass
351
+
352
+ @trace_behavior
353
+ def save_item(item):
354
+ pass
355
+
356
+ @app.post("/items/")
357
+ async def post_item(item: Item):
358
+ return create_item(item)
359
+
360
+ if __name__ == "__main__":
361
+ import uvicorn
362
+ uvicorn.run(app, host="0.0.0.0", port=8000)
363
+ ```
364
+
365
+ Run:
366
+
367
+ ```bash
368
+ pip install ses-intelligence[fastapi]
369
+ python examples/fastapi_app/app.py
370
+ ```
371
+
372
+ #### Django
373
+
374
+ Add to your `settings.py`:
375
+
376
+ ```python
377
+ # settings.py
378
+
379
+ INSTALLED_APPS = [
380
+ # ... your apps
381
+ 'ses_intelligence',
382
+ ]
383
+
384
+ MIDDLEWARE = [
385
+ # ... other middleware
386
+ 'ses_intelligence.middleware.SESMiddleware',
387
+ ]
388
+
389
+ # SES Configuration
390
+ SES_CONFIG = {
391
+ 'project_id': 'my-django-app',
392
+ 'enable_forecasting': True,
393
+ 'enable_narratives': True,
394
+ }
395
+ ```
396
+
397
+ In your views:
398
+
399
+ ```python
400
+ # views.py
401
+ from ses_intelligence import trace_behavior
402
+ from django.http import JsonResponse
403
+
404
+ @trace_behavior
405
+ def my_view(request):
406
+ # Your view logic
407
+ process_data(request)
408
+ return JsonResponse({"status": "ok"})
409
+
410
+ @trace_behavior
411
+ def process_data(request):
412
+ # Business logic
413
+ pass
414
+ ```
415
+
416
+ Run:
417
+
418
+ ```bash
419
+ pip install ses-intelligence[django]
420
+ python manage.py runserver
421
+ ```
422
+
423
+ ---
424
+
425
+ ## API Server
426
+
427
+ ### Starting the API Server
428
+
429
+ ```bash
430
+ # Ensure Django dependencies are installed
431
+ pip install django>=4.0
432
+
433
+ # Run migrations
434
+ python manage.py migrate
435
+
436
+ # Start the server
437
+ python manage.py runserver 0.0.0.0:8000
438
+ ```
439
+
440
+ ### API Server Endpoints
441
+
442
+ | Endpoint | Method | Description |
443
+ | ------------------------ | -------------- | ------------------------------ |
444
+ | `/api/v1/health/` | GET | Get architecture health score |
445
+ | `/api/v1/forecast/` | GET | Get health forecast |
446
+ | `/api/v1/graph/` | GET | Get runtime architecture graph |
447
+ | `/api/v1/impact/` | GET | Get impact analysis |
448
+ | `/api/v1/executive/` | GET | Get executive summary |
449
+ | `/api/v1/projects/` | GET/POST | List/create projects |
450
+ | `/api/v1/projects/<id>/` | GET/PUT/DELETE | Project CRUD |
451
+ | `/api/v1/chat/` | POST | LLM-powered Q&A |
452
+
453
+ ### Example API Calls
454
+
455
+ ```bash
456
+ # Get health score
457
+ curl "http://localhost:8000/api/v1/health/?project=my-app"
458
+
459
+ # Get forecast
460
+ curl "http://localhost:8000/api/v1/forecast/?project=my-app&horizon=5"
461
+
462
+ # Get architecture graph
463
+ curl "http://localhost:8000/api/v1/graph/?project=my-app"
464
+
465
+ # List all projects
466
+ curl "http://localhost:8000/api/v1/projects/"
467
+
468
+ # Get executive summary
469
+ curl "http://localhost:8000/api/v1/executive/?project=my-app"
470
+ ```
471
+
472
+ ---
473
+
474
+ ## Dashboard
475
+
476
+ ### Setup
477
+
478
+ ```bash
479
+ # Navigate to dashboard directory
480
+ cd ses-dashboard
481
+
482
+ # Install dependencies
483
+ npm install
484
+
485
+ # Start development server
486
+ npm run dev
487
+ ```
488
+
489
+ The dashboard will be available at `http://localhost:5173`
490
+
491
+ ### Building for Production
492
+
493
+ ```bash
494
+ # Build the dashboard
495
+ npm run build
496
+
497
+ # The built files will be in dist/
498
+ ```
499
+
500
+ ### Dashboard Features
501
+
502
+ | Feature | Description |
503
+ | ---------------------- | ------------------------------------------------- |
504
+ | **Health Gauge** | Real-time health score visualization (0-100) |
505
+ | **Architecture Graph** | Live visualization of function call relationships |
506
+ | **Forecast Timeline** | Historical and predicted health trends |
507
+ | **Executive Panel** | High-level summary for stakeholders |
508
+ | **AI Chat** | LLM-powered Q&A about your architecture |
509
+
510
+ ### Dashboard Screenshots
511
+
512
+ Here's what the SES Intelligence Dashboard looks like:
513
+
514
+ #### Main Dashboard View
515
+
516
+ ![SES Intelligence Dashboard](./images/dashboard-main.png)
517
+
518
+ The main dashboard provides a comprehensive overview of your application's architecture health with real-time metrics, interactive charts, and quick access to all features.
519
+
520
+ #### Architecture Graph
521
+
522
+ ![Architecture Graph](./images/architecture-graph.png)
523
+
524
+ Visualize function call relationships as an interactive graph. Nodes represent functions, edges show call relationships, and colors indicate health status.
525
+
526
+ #### Health Gauge
527
+
528
+ ![Health Gauge](./images/health-gauge.png)
529
+
530
+ The health gauge displays your overall architecture health score (0-100) with trend indicators showing if health is improving, stable, or degrading.
531
+
532
+ #### Forecast Timeline
533
+
534
+ ![Forecast Timeline](./images/forecast-timeline.png)
535
+
536
+ View historical health data alongside AI-powered predictions. Confidence intervals show the reliability of forecasts.
537
+
538
+ #### Executive Panel
539
+
540
+ ![Executive Panel](./images/executive-panel.png)
541
+
542
+ A high-level summary designed for stakeholders, showing key metrics and recommendations at a glance.
543
+
544
+ > **Note**: Replace the placeholder images in the `images/` folder with actual screenshots from your running dashboard. Recommended image sizes:
545
+ >
546
+ > - Main dashboard: 1200x800px
547
+ > - Architecture graph: 800x600px
548
+ > - Health gauge: 400x400px
549
+ > - Forecast timeline: 800x400px
550
+ > - Executive panel: 800x600px
551
+ > - AI Chat: 800x600px
552
+
553
+ #### AI Chat
554
+
555
+ ![AI Chat](./images/ai-chat.png)
556
+
557
+ The AI Chat feature allows you to ask questions in natural language about your application's architecture. Powered by LLMs, it can explain health scores, suggest improvements, and help you understand complex architectural patterns.
558
+
559
+ ---
560
+
561
+ ## Configuration
562
+
563
+ ### Environment Variables
564
+
565
+ | Variable | Description | Default |
566
+ | ----------------------- | --------------------------------- | ------------------- |
567
+ | `SES_PROJECT_ID` | Default project ID | `"default"` |
568
+ | `SES_DATA_DIR` | Data storage directory | `"./behavior_data"` |
569
+ | `OPENAI_API_KEY` | OpenAI API key for LLM features | `None` |
570
+ | `CELERY_BROKER_URL` | Celery broker URL for async tasks | `None` |
571
+ | `CELERY_RESULT_BACKEND` | Celery result backend | `None` |
572
+ | `DATABASE_URL` | Database connection string | SQLite (local) |
573
+
574
+ ### SDK Configuration Options
575
+
576
+ ```python
577
+ from ses_intelligence import initialize
578
+
579
+ config = initialize(
580
+ # Project Configuration
581
+ project_id="my-app", # Required: unique project identifier
582
+ project_name="My Application", # Optional: human-readable name
583
+ storage_path="/data/ses", # Optional: custom storage path
584
+
585
+ # Engine Configuration
586
+ enable_background_tasks=False, # Enable async task processing
587
+ enable_health_tracking=True, # Enable health score tracking
588
+ enable_forecasting=True, # Enable health forecasting
589
+ enable_narratives=True, # Enable narrative generation
590
+
591
+ # Forecasting Configuration
592
+ forecast_window_size=10, # Window size for forecasting
593
+ forecast_confidence_floor=0.70, # Minimum confidence threshold
594
+
595
+ # Storage Configuration
596
+ data_retention_days=90, # Days to retain historical data
597
+ snapshot_retention_count=100, # Max snapshots to retain
598
+
599
+ # LLM Configuration
600
+ llm_api_key="sk-...", # OpenAI API key
601
+ llm_model="gpt-4o-mini", # LLM model to use
602
+
603
+ # Django Configuration (if using Django)
604
+ django_settings={}, # Django settings dict
605
+ )
606
+ ```
607
+
608
+ ### Django Settings
609
+
610
+ ```python
611
+ # settings.py
612
+
613
+ # SES-specific settings
614
+ SES_CONFIG = {
615
+ 'DEFAULT_PROJECT_ID': 'my-production-app',
616
+ 'ENABLE_FORECASTING': True,
617
+ 'ENABLE_NARRATIVES': True,
618
+ 'FORECAST_WINDOW_SIZE': 10,
619
+ 'DATA_RETENTION_DAYS': 90,
620
+ 'LLM_MODEL': 'gpt-4o-mini',
621
+ }
622
+
623
+ # Database (PostgreSQL recommended for production)
624
+ DATABASES = {
625
+ 'default': {
626
+ 'ENGINE': 'django.db.backends.postgresql',
627
+ 'NAME': 'ses_db',
628
+ 'USER': 'ses_user',
629
+ 'PASSWORD': 'your-password',
630
+ 'HOST': 'localhost',
631
+ 'PORT': '5432',
632
+ }
633
+ }
634
+ ```
635
+
636
+ ---
637
+
638
+ ## CLI Commands
639
+
640
+ The SDK includes a CLI tool for quick operations:
641
+
642
+ ```bash
643
+ # Initialize a project
644
+ ses init --project-id my-app
645
+
646
+ # Check status
647
+ ses status
648
+
649
+ # Run diagnostics
650
+ ses doctor
651
+
652
+ # Take a snapshot
653
+ ses snapshot
654
+
655
+ # Check health
656
+ ses health
657
+
658
+ # Run forecast
659
+ ses forecast --horizon 5
660
+ ```
661
+
662
+ ### Example `ses doctor` Output
663
+
664
+ ```
665
+ ==================================================
666
+ SES Intelligence - Diagnostic Report
667
+ ==================================================
668
+
669
+ 📦 SDK Version: 1.0.0b0
670
+ 📁 Project ID: my-app
671
+ 📸 Snapshot Count: 3
672
+ 💚 Latest Health Score: 85.4/100
673
+ 🔮 Forecast Direction: stable
674
+ 💾 Storage Mode: default
675
+ 🤖 LLM Enabled: No
676
+
677
+ ==================================================
678
+ ```
679
+
680
+ ---
681
+
682
+ ## API Endpoints
683
+
684
+ ### Health Endpoint
685
+
686
+ ```
687
+ GET /api/v1/health/?project=<project_id>
688
+
689
+ Response:
690
+ {
691
+ "overall_score": 85.4,
692
+ "stability_index": 0.92,
693
+ "risk_level": "low",
694
+ "recommendations": ["Consider reducing function complexity"],
695
+ "components": {
696
+ "complexity": 78.2,
697
+ "stability": 92.1,
698
+ "risk": 88.5
699
+ }
700
+ }
701
+ ```
702
+
703
+ ### Forecast Endpoint
704
+
705
+ ```
706
+ GET /api/v1/forecast/?project=<project_id>&horizon=5
707
+
708
+ Response:
709
+ {
710
+ "direction": "stable",
711
+ "forecast": [
712
+ {"step": 1, "health_score": 84.2, "confidence": 0.85},
713
+ {"step": 2, "health_score": 83.8, "confidence": 0.82},
714
+ {"step": 3, "health_score": 83.1, "confidence": 0.78},
715
+ {"step": 4, "health_score": 82.5, "confidence": 0.75},
716
+ {"step": 5, "health_score": 82.0, "confidence": 0.71}
717
+ ]
718
+ }
719
+ ```
720
+
721
+ ### Graph Endpoint
722
+
723
+ ```
724
+ GET /api/v1/graph/?project=<project_id>
725
+
726
+ Response:
727
+ {
728
+ "nodes": [
729
+ {"id": "process_order", "type": "function"},
730
+ {"id": "validate_order", "type": "function"},
731
+ {"id": "charge_customer", "type": "function"}
732
+ ],
733
+ "edges": [
734
+ {"source": "process_order", "target": "validate_order", "call_count": 150},
735
+ {"source": "process_order", "target": "charge_customer", "call_count": 145}
736
+ ]
737
+ }
738
+ ```
739
+
740
+ ### Chat Endpoint (LLM)
741
+
742
+ ```
743
+ POST /api/v1/chat/
744
+
745
+ Request:
746
+ {
747
+ "project": "my-app",
748
+ "question": "What is causing the health score to decrease?"
749
+ }
750
+
751
+ Response:
752
+ {
753
+ "answer": "The health score is decreasing due to increasing complexity...",
754
+ "sources": ["snapshot_123", "health_record_456"]
755
+ }
756
+ ```
757
+
758
+ ---
759
+
760
+ ## Examples
761
+
762
+ ### Example Projects
763
+
764
+ The repository includes ready-to-run examples:
765
+
766
+ | Example | Path | Framework |
767
+ | ------------ | ---------------------------------- | --------- |
768
+ | Plain Python | `examples/plain_python/example.py` | None |
769
+ | Flask | `examples/flask_app/app.py` | Flask |
770
+ | FastAPI | `examples/fastapi_app/app.py` | FastAPI |
771
+
772
+ ### Running Examples
773
+
774
+ ```bash
775
+ # Plain Python example
776
+ python examples/plain_python/example.py
777
+
778
+ # Flask example
779
+ pip install ses-intelligence[flask]
780
+ python examples/flask_app/app.py
781
+
782
+ # FastAPI example
783
+ pip install ses-intelligence[fastapi]
784
+ python examples/fastapi_app/app.py
785
+ ```
786
+
787
+ ---
788
+
789
+ ## Troubleshooting
790
+
791
+ ### "No snapshots available"
792
+
793
+ **Cause**: No functions have been traced yet.
794
+
795
+ **Solution**:
796
+
797
+ 1. Ensure your functions are decorated with `@trace_behavior`
798
+ 2. Run your application code that calls the decorated functions
799
+ 3. Call `get_runtime_snapshots()` after code execution
800
+
801
+ ```python
802
+ @trace_behavior
803
+ def my_function():
804
+ pass
805
+
806
+ # Must actually call the function
807
+ my_function()
808
+
809
+ # Then get snapshots
810
+ snapshots = get_runtime_snapshots()
811
+ ```
812
+
813
+ ### "Low confidence score"
814
+
815
+ **Cause**: Insufficient data points for accurate prediction.
816
+
817
+ **Solution**:
818
+
819
+ - Run the application for longer periods
820
+ - Ensure consistent traffic patterns
821
+ - More snapshots = higher confidence
822
+
823
+ ### "LLM features not working"
824
+
825
+ **Cause**: OpenAI API key not configured.
826
+
827
+ **Solution**:
828
+
829
+ ```python
830
+ # Option 1: Pass API key directly
831
+ initialize(
832
+ project_id="my-app",
833
+ llm_api_key="sk-your-key-here"
834
+ )
835
+
836
+ # Option 2: Set environment variable
837
+ import os
838
+ os.environ["OPENAI_API_KEY"] = "sk-your-key-here"
839
+ initialize(project_id="my-app")
840
+ ```
841
+
842
+ ### Dashboard not loading
843
+
844
+ **Cause**: API server not running or CORS issues.
845
+
846
+ **Solution**:
847
+
848
+ 1. Ensure Django server is running: `python manage.py runserver`
849
+ 2. Check API is accessible: `curl http://localhost:8000/api/v1/projects/`
850
+ 3. Check browser console for CORS errors
851
+ 4. Update CORS settings in Django if needed:
852
+
853
+ ```python
854
+ # settings.py
855
+ CORS_ALLOWED_ORIGINS = [
856
+ "http://localhost:5173",
857
+ "http://127.0.0.1:5173",
858
+ ]
859
+ ```
860
+
861
+ ### Database errors
862
+
863
+ **Cause**: Migrations not applied.
864
+
865
+ **Solution**:
866
+
867
+ ```bash
868
+ python manage.py makemigrations
869
+ python manage.py migrate
870
+ ```
871
+
872
+ ---
873
+
874
+ ## When to Expect Changes
875
+
876
+ The following events will trigger updates to your health scores, forecasts, and metrics:
877
+
878
+ | Event | What Changes |
879
+ | ---------------------------- | ----------------------------------------------- |
880
+ | **New function calls** | Architecture graph expands with new nodes/edges |
881
+ | **Increased call frequency** | Stability index may decrease |
882
+ | **New dependencies added** | Complexity score increases |
883
+ | **Code deployment** | New snapshot created, baseline may shift |
884
+ | **Traffic spikes** | Anomaly detection may trigger |
885
+ | **Function changes** | Behavior diff detected, health recalculated |
886
+
887
+ ### What Gets Recorded
888
+
889
+ Every snapshot captures:
890
+
891
+ - Function call graph (nodes and edges)
892
+ - Call counts and frequencies
893
+ - Execution durations
894
+ - Complexity metrics
895
+ - Stability patterns
896
+
897
+ ### When to Check Health
898
+
899
+ | Scenario | Recommended Action |
900
+ | --------------------- | ------------------------------------- |
901
+ | After deployment | Run `ses health` to check impact |
902
+ | During traffic spikes | Monitor dashboard for anomalies |
903
+ | Before release | Generate forecast for upcoming period |
904
+ | During incidents | Check real-time health and impact |
905
+
906
+ ---
907
+
908
+ ## When NOT to Expect Changes
909
+
910
+ The following scenarios will NOT trigger changes or updates:
911
+
912
+ | Scenario | Reason |
913
+ | ---------------------------------- | ---------------------------------------------- |
914
+ | **Static code analysis** | SES monitors runtime behavior, not static code |
915
+ | **Import statements** | Only actual function calls are traced |
916
+ | **Decorated functions not called** | Must be invoked to generate data |
917
+ | **Environment changes** | Without code execution, no new snapshots |
918
+ | **Configuration-only changes** | Config changes don't affect runtime graph |
919
+ | **Database schema changes** | Only function call patterns matter |
920
+
921
+ ### What SES Does NOT Do
922
+
923
+ | Feature | Status |
924
+ | ------------------------------------- | ----------------------------------- |
925
+ | Static code analysis | ❌ Not supported |
926
+ | Security vulnerability scanning | ❌ Not supported |
927
+ | Performance profiling | ❌ Not supported |
928
+ | Log aggregation | ❌ Not supported |
929
+ | Metrics collection (Prometheus style) | ❌ Not supported |
930
+ | Real-time alerting | ❌ Not supported (forecasting only) |
931
+
932
+ ### Limitations
933
+
934
+ | Limitation | Details |
935
+ | ------------------------- | ------------------------------------------ |
936
+ | **Minimum data required** | Need at least 3 snapshots for forecasting |
937
+ | **Confidence threshold** | Forecasts below 70% confidence are flagged |
938
+ | **Data retention** | Default 90 days, configurable |
939
+ | **Maximum graph size** | Practical limit ~10,000 nodes |
940
+ | **LLM rate limits** | Subject to OpenAI API limits |
941
+
942
+ ---
943
+
944
+ ## Project Structure
945
+
946
+ ```
947
+ ses-intelligence/
948
+ ├── README.md # This file
949
+ ├── LICENSE # MIT License
950
+ ├── pyproject.toml # Python package configuration
951
+ ├── examples/ # Example applications
952
+ │ ├── plain_python/ # Plain Python example
953
+ │ ├── flask_app/ # Flask example
954
+ │ └── fastapi_app/ # FastAPI example
955
+ ├── ses_intelligence/ # Core SDK package
956
+ │ ├── __init__.py # Public API exports
957
+ │ ├── config.py # Configuration management
958
+ │ ├── tracing.py # Behavior tracing decorator
959
+ │ ├── runtime_state.py # Runtime state management
960
+ │ ├── project_storage.py # Project-based storage
961
+ │ ├── cli.py # CLI commands
962
+ │ ├── architecture_health/ # Health scoring engine
963
+ │ ├── behavior_change/ # Behavior change detection
964
+ │ ├── llm/ # LLM service integration
965
+ │ ├── ml/ # ML features
966
+ │ └── narrative/ # Narrative generation
967
+ ├── ses_api/ # Django REST API
968
+ │ ├── views.py # API views
969
+ │ ├── urls.py # URL routing
970
+ │ └── models.py # Database models
971
+ ├── ses_core/ # Django core settings
972
+ │ ├── settings.py # Django settings
973
+ │ ├── urls.py # URL configuration
974
+ │ └── wsgi.py # WSGI application
975
+ ├── demo_app/ # Demo Django application
976
+ │ ├── views.py # Demo views
977
+ │ └── urls.py # Demo URLs
978
+ ├── ses-dashboard/ # React dashboard
979
+ │ ├── src/ # React source
980
+ │ ├── public/ # Static assets
981
+ │ └── package.json # Node dependencies
982
+ ├── docs/ # Documentation
983
+ │ └── index.md # Full documentation
984
+ └── behavior_data/ # Runtime data storage
985
+ ```
986
+
987
+ ---
988
+
989
+ ## License
990
+
991
+ MIT License - see [LICENSE](LICENSE) file for details.
992
+
993
+ ---
994
+
995
+ ## Contributing
996
+
997
+ Contributions are welcome! Please read our contributing guidelines before submitting PRs.
998
+
999
+ ### Development Setup
1000
+
1001
+ ```bash
1002
+ # Clone the repository
1003
+ git clone https://github.com/dummy-pranjal29/self-explaining-software.git
1004
+ cd self-explaining-software
1005
+
1006
+ # Install in development mode
1007
+ pip install -e ".[dev]"
1008
+
1009
+ # Run tests
1010
+ pytest ses_intelligence/tests/
1011
+
1012
+ # Run linting
1013
+ ruff check ses_intelligence/
1014
+ black ses_intelligence/
1015
+ mypy ses_intelligence/
1016
+ ```
1017
+
1018
+ ---
1019
+
1020
+ ## Support
1021
+
1022
+ | Resource | Link |
1023
+ | ------------- | -------------------------------------------------------------------------------------------------------------------------------- |
1024
+ | Documentation | [ses-intelligence.readthedocs.io](https://ses-intelligence.readthedocs.io) |
1025
+ | Issues | [github.com/dummy-pranjal29/self-explaining-software/issues](https://github.com/dummy-pranjal29/self-explaining-software/issues) |
1026
+ | PyPI | [pypi.org/project/ses-intelligence](https://pypi.org/project/ses-intelligence/) |
1027
+
1028
+ ---
1029
+
1030
+ ## Changelog
1031
+
1032
+ ### [1.0.0b0] - Current Version
1033
+
1034
+ #### Added
1035
+
1036
+ - LLM Conversational Layer (`/api/v1/chat/`) for interactive Q&A
1037
+ - Configuration Abstraction Layer for framework-agnostic initialization
1038
+ - New database models: Snapshot, HealthRecord, ForecastRecord
1039
+ - Automated test infrastructure (pytest + vitest)
1040
+ - Frontend component tests with API mocking
1041
+ - Full-stack platform: SDK + API + Dashboard
1042
+
1043
+ #### Changed
1044
+
1045
+ - Updated Project model to use database relationships
1046
+ - Improved project isolation in API endpoints
1047
+
1048
+ #### Fixed
1049
+
1050
+ - Fixed project ID validation in API endpoints
1051
+
1052
+ ---
1053
+
1054
+ _Last updated: February 2026_