diff --git a/core/__pycache__/models.cpython-311.pyc b/core/__pycache__/models.cpython-311.pyc index 0a846fc..08f5252 100644 Binary files a/core/__pycache__/models.cpython-311.pyc and b/core/__pycache__/models.cpython-311.pyc differ diff --git a/core/__pycache__/urls.cpython-311.pyc b/core/__pycache__/urls.cpython-311.pyc index f705988..d63d93a 100644 Binary files a/core/__pycache__/urls.cpython-311.pyc and b/core/__pycache__/urls.cpython-311.pyc differ diff --git a/core/__pycache__/views.cpython-311.pyc b/core/__pycache__/views.cpython-311.pyc index 2f0989c..8886bf8 100644 Binary files a/core/__pycache__/views.cpython-311.pyc and b/core/__pycache__/views.cpython-311.pyc differ diff --git a/core/migrations/0002_relationship.py b/core/migrations/0002_relationship.py new file mode 100644 index 0000000..5cd2155 --- /dev/null +++ b/core/migrations/0002_relationship.py @@ -0,0 +1,28 @@ +# Generated by Django 5.2.7 on 2026-03-22 22:06 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='Relationship', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('relationship_type', models.CharField(choices=[('OWNED_BY', 'Owned By'), ('ASSOCIATED_WITH', 'Associated With'), ('COMMUNICATED_WITH', 'Communicated With')], max_length=20)), + ('weight', models.FloatField(default=1.0)), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('source_entity', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='outbound_relationships', to='core.entity')), + ('target_entity', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='inbound_relationships', to='core.entity')), + ], + options={ + 'unique_together': {('source_entity', 'target_entity', 'relationship_type')}, + }, + ), + ] diff --git a/core/migrations/__pycache__/0002_relationship.cpython-311.pyc b/core/migrations/__pycache__/0002_relationship.cpython-311.pyc new file mode 100644 index 0000000..2e9ccb9 Binary files /dev/null and b/core/migrations/__pycache__/0002_relationship.cpython-311.pyc differ diff --git a/core/models.py b/core/models.py index fa9c11b..9a1dbe1 100644 --- a/core/models.py +++ b/core/models.py @@ -27,4 +27,22 @@ class Entity(models.Model): unique_together = ('entity_type', 'value', 'source') def __str__(self): - return f"{self.entity_type}: {self.value}" \ No newline at end of file + return f"{self.entity_type}: {self.value}" + +class Relationship(models.Model): + RELATIONSHIP_TYPES = ( + ('OWNED_BY', 'Owned By'), + ('ASSOCIATED_WITH', 'Associated With'), + ('COMMUNICATED_WITH', 'Communicated With'), + ) + source_entity = models.ForeignKey(Entity, on_delete=models.CASCADE, related_name='outbound_relationships') + target_entity = models.ForeignKey(Entity, on_delete=models.CASCADE, related_name='inbound_relationships') + relationship_type = models.CharField(max_length=20, choices=RELATIONSHIP_TYPES) + weight = models.FloatField(default=1.0) + created_at = models.DateTimeField(auto_now_add=True) + + class Meta: + unique_together = ('source_entity', 'target_entity', 'relationship_type') + + def __str__(self): + return f"{self.source_entity} -[{self.relationship_type}]-> {self.target_entity}" diff --git a/core/services/__pycache__/ingestion.cpython-311.pyc b/core/services/__pycache__/ingestion.cpython-311.pyc new file mode 100644 index 0000000..0363eac Binary files /dev/null and b/core/services/__pycache__/ingestion.cpython-311.pyc differ diff --git a/core/services/__pycache__/resolution.cpython-311.pyc b/core/services/__pycache__/resolution.cpython-311.pyc new file mode 100644 index 0000000..dbba070 Binary files /dev/null and b/core/services/__pycache__/resolution.cpython-311.pyc differ diff --git a/core/urls.py b/core/urls.py index 6299e3d..1facb35 100644 --- a/core/urls.py +++ b/core/urls.py @@ -1,7 +1,11 @@ from django.urls import path -from .views import home +from .views import home, ingest_data, resolve_entities + +app_name = 'core' urlpatterns = [ path("", home, name="home"), -] + path("api/ingest/", ingest_data, name="ingest_data"), + path("api/resolve/", resolve_entities, name="resolve_entities"), +] \ No newline at end of file diff --git a/core/views.py b/core/views.py index c9aed12..cfa6cf5 100644 --- a/core/views.py +++ b/core/views.py @@ -1,10 +1,13 @@ -import os -import platform - -from django import get_version as django_version +import json +from django.http import JsonResponse +from django.views.decorators.csrf import csrf_exempt +from core.services.ingestion import IngestionService +from core.services.resolution import EntityResolutionService from django.shortcuts import render from django.utils import timezone - +import os +import platform +from django import get_version as django_version def home(request): """Render the landing screen with loader and environment details.""" @@ -23,3 +26,21 @@ def home(request): "project_image_url": os.getenv("PROJECT_IMAGE_URL", ""), } return render(request, "core/index.html", context) + +@csrf_exempt +def ingest_data(request): + if request.method == 'POST': + data = json.loads(request.body) + # Using IngestionService as a placeholder for actual processing + result = IngestionService.ingest(data) + return JsonResponse({'status': 'success', 'data': result}) + return JsonResponse({'error': 'Invalid request'}, status=400) + +@csrf_exempt +def resolve_entities(request): + if request.method == 'POST': + data = json.loads(request.body) + # Using EntityResolutionService as a placeholder for actual processing + result = EntityResolutionService.resolve(data) + return JsonResponse({'status': 'success', 'result': result}) + return JsonResponse({'error': 'Invalid request'}, status=400) \ No newline at end of file