jamesbright commited on
Commit
22d0fa7
·
verified ·
1 Parent(s): 09ec9ab

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +136 -0
app.py ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import json
3
+
4
+ class ProjectScopingTool:
5
+ """
6
+ Handles project scoping by collecting key details such as type, domain, budget, and timeline.
7
+ """
8
+ def __init__(self):
9
+ self.project_details = {
10
+ "type": None,
11
+ "domain": None,
12
+ "technical_requirements": {},
13
+ "budget_range": {},
14
+ "timeline": {}
15
+ }
16
+
17
+ def collect_project_details(self, project_type, domain, budget_min, budget_max, timeline_months):
18
+ """
19
+ Collects and structures project details from user input.
20
+ """
21
+ self.project_details = {
22
+ "type": project_type,
23
+ "domain": domain,
24
+ "budget_range": {"min": budget_min, "max": budget_max},
25
+ "timeline": {"months": timeline_months}
26
+ }
27
+ return json.dumps(self.project_details, indent=2)
28
+
29
+ class TechnicalArchitectureTool:
30
+ """
31
+ Determines the appropriate technical architecture based on the project type.
32
+ """
33
+ def generate_architecture(self, project_type):
34
+ architectures = {
35
+ "web": {
36
+ "frontend": ["React", "Next.js", "Tailwind"],
37
+ "backend": ["FastAPI", "Django", "Express"],
38
+ "database": ["PostgreSQL", "MongoDB"]
39
+ },
40
+ "blockchain": {
41
+ "blockchain_type": "EVM-compatible",
42
+ "smart_contract_language": "Solidity",
43
+ "consensus_mechanism": "Proof of Stake"
44
+ },
45
+ "ai": {
46
+ "model_type": "Transformer",
47
+ "inference_strategy": "Cloud-based",
48
+ "data_processing": "Distributed"
49
+ }
50
+ }
51
+ return json.dumps(architectures.get(project_type, "Invalid project type"), indent=2)
52
+
53
+ class CostEstimationTool:
54
+ """
55
+ Estimates the cost based on the architecture complexity and timeline.
56
+ """
57
+ def estimate_project_cost(self, architecture_size, timeline_months):
58
+ base_costs = {
59
+ "development": 5000 * (architecture_size * 0.5),
60
+ "infrastructure": 500 * (architecture_size * 0.3),
61
+ "maintenance": 1000 * (architecture_size * 0.2)
62
+ }
63
+ total_cost = sum(base_costs.values())
64
+ return json.dumps({"total_estimated_cost": total_cost, "breakdown": base_costs}, indent=2)
65
+
66
+ class DeploymentTool:
67
+ """
68
+ Suggests a deployment strategy based on best practices.
69
+ """
70
+ def generate_deployment_strategy(self):
71
+ return json.dumps({
72
+ "container_strategy": "Docker + Kubernetes",
73
+ "cloud_provider": "AWS",
74
+ "services": ["ECS", "Lambda", "S3", "RDS"],
75
+ "ci_cd_pipeline": "GitHub Actions"
76
+ }, indent=2)
77
+
78
+ class MeetingPreparationTool:
79
+ """
80
+ Provides meeting agendas depending on the project stage.
81
+ """
82
+ def generate_meeting_agenda(self, project_stage):
83
+ agendas = {
84
+ "initial_discovery": [
85
+ "Project Vision Validation",
86
+ "Technical Feasibility Discussion",
87
+ "Initial Scope Definition"
88
+ ],
89
+ "architecture_review": [
90
+ "Technical Architecture Walkthrough",
91
+ "Technology Stack Validation",
92
+ "Performance Considerations"
93
+ ]
94
+ }
95
+ return json.dumps(agendas.get(project_stage, "No agenda found for this stage"), indent=2)
96
+
97
+ # Instantiate tools
98
+ scoping_tool = ProjectScopingTool()
99
+ tech_arch_tool = TechnicalArchitectureTool()
100
+ cost_tool = CostEstimationTool()
101
+ deploy_tool = DeploymentTool()
102
+ meeting_tool = MeetingPreparationTool()
103
+
104
+ # Define Gradio Interface
105
+ with gr.Blocks() as demo:
106
+ gr.Markdown("# 🏗️ Project Scoping & Cost Estimation Tool")
107
+
108
+ with gr.Row():
109
+ project_type = gr.Dropdown(["web", "blockchain", "ai"], label="Select Project Type")
110
+ domain = gr.Textbox(label="Enter Project Domain")
111
+
112
+ with gr.Row():
113
+ budget_min = gr.Number(label="Min Budget ($)")
114
+ budget_max = gr.Number(label="Max Budget ($)")
115
+ timeline_months = gr.Number(label="Timeline (Months)")
116
+
117
+ project_output = gr.Textbox(label="Project Details", interactive=False)
118
+ arch_output = gr.Textbox(label="Technical Architecture", interactive=False)
119
+ cost_output = gr.Textbox(label="Estimated Cost", interactive=False)
120
+ deploy_output = gr.Textbox(label="Deployment Strategy", interactive=False)
121
+ meeting_output = gr.Textbox(label="Meeting Agenda", interactive=False)
122
+
123
+ def process_inputs(p_type, dom, min_b, max_b, months):
124
+ project_details = scoping_tool.collect_project_details(p_type, dom, min_b, max_b, months)
125
+ architecture = tech_arch_tool.generate_architecture(p_type)
126
+ estimated_cost = cost_tool.estimate_project_cost(len(architecture), months)
127
+ deployment_strategy = deploy_tool.generate_deployment_strategy()
128
+ meeting_agenda = meeting_tool.generate_meeting_agenda("initial_discovery")
129
+ return project_details, architecture, estimated_cost, deployment_strategy, meeting_agenda
130
+
131
+ process_button = gr.Button("Generate Estimates")
132
+ process_button.click(process_inputs, inputs=[project_type, domain, budget_min, budget_max, timeline_months],
133
+ outputs=[project_output, arch_output, cost_output, deploy_output, meeting_output])
134
+
135
+ # Launch the Gradio App
136
+ demo.launch()