-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmock_backend.py
More file actions
144 lines (126 loc) · 4.32 KB
/
mock_backend.py
File metadata and controls
144 lines (126 loc) · 4.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/usr/bin/env python3
"""
Mock backend for AI Virtual Paralegal testing
This provides the API endpoints without requiring a full database setup
"""
from flask import Flask, request, jsonify
from flask_cors import CORS
import json
import time
import random
app = Flask(__name__)
CORS(app, origins=['http://localhost:3000', 'http://localhost:3002'])
# Mock data
workflow_running = False
stats = {
"clients": 0,
"cases": 0,
"tasks": 0,
"documents": 0
}
activity_log = []
@app.route('/api/v1/health', methods=['GET'])
def health():
return jsonify({"status": "healthy", "service": "AI Virtual Paralegal Mock Backend"})
@app.route('/api/v1/ai-virtual-paralegal/dashboard', methods=['GET'])
def get_dashboard():
return jsonify({
"success": True,
"workflow_running": workflow_running,
"stats": stats,
"recent_activity": activity_log[-10:],
"capabilities": [
"Autonomous Workflow Management",
"Client Case Processing",
"Document Generation",
"Task Scheduling",
"Deadline Monitoring",
"Client Communication"
]
})
@app.route('/api/v1/ai-virtual-paralegal/start', methods=['POST'])
def start_workflow():
global workflow_running, stats, activity_log
workflow_running = True
# Simulate workflow steps
steps = [
"AI Virtual Paralegal workflow started",
"Initializing client case processing...",
"Setting up task scheduling system...",
"Activating deadline monitoring...",
"Analyzing 3 pending cases - identified 12 required actions",
"Researched 47 relevant cases from CourtListener API",
"Found 12 similar cases in local ChromaDB",
"Generated I-485 Application Form with 95% accuracy",
"Generated Divorce Petition with 95% accuracy",
"Generated Custody Agreement with 95% accuracy",
"Generated Financial Disclosure Form with 95% accuracy",
"Scheduled: Schedule biometrics appointment for John Smith",
"Scheduled: File divorce petition with court",
"Scheduled: Prepare custody mediation documents",
"Scheduled: Follow up on I-485 status",
"Updated John Smith with case progress and next steps",
"Updated Maria Garcia with case progress and next steps",
"AI Virtual Paralegal completed workflow cycle"
]
# Add steps to activity log
for step in steps:
activity_log.append({
"timestamp": time.strftime("%H:%M:%S"),
"message": step,
"level": "info"
})
# Update stats
stats = {
"clients": 5,
"cases": 12,
"tasks": 8,
"documents": 4
}
return jsonify({
"success": True,
"message": "AI workflow started successfully",
"workflow_running": True,
"stats": stats,
"activity": activity_log[-5:]
})
@app.route('/api/v1/ai-virtual-paralegal/stop', methods=['POST'])
def stop_workflow():
global workflow_running, activity_log
workflow_running = False
# Add stop messages
stop_messages = [
"AI Virtual Paralegal workflow stopped",
"Saving current state...",
"Workflow paused successfully"
]
for msg in stop_messages:
activity_log.append({
"timestamp": time.strftime("%H:%M:%S"),
"message": msg,
"level": "info"
})
return jsonify({
"success": True,
"message": "AI workflow stopped successfully",
"workflow_running": False,
"activity": activity_log[-5:]
})
@app.route('/api/v1/ai-virtual-paralegal/status', methods=['GET'])
def get_status():
return jsonify({
"success": True,
"workflow_running": workflow_running,
"stats": stats,
"activity": activity_log[-10:]
})
if __name__ == '__main__':
print("🚀 Starting AI Virtual Paralegal Mock Backend...")
print("📡 Available endpoints:")
print(" GET /api/v1/health")
print(" GET /api/v1/ai-virtual-paralegal/dashboard")
print(" POST /api/v1/ai-virtual-paralegal/start")
print(" POST /api/v1/ai-virtual-paralegal/stop")
print(" GET /api/v1/ai-virtual-paralegal/status")
print("🌐 Server running on http://localhost:3001")
app.run(host='0.0.0.0', port=3001, debug=True)