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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import numpy as np
|
4 |
+
import os
|
5 |
+
from datetime import datetime, timedelta, date
|
6 |
+
import time
|
7 |
+
import io
|
8 |
+
import base64
|
9 |
+
|
10 |
+
# Import your existing pages (make sure they're in the same directory or in a 'pages' directory)
|
11 |
+
# If you have these in separate files, you'll need to adjust the imports
|
12 |
+
# For example:
|
13 |
+
# from pages.dashboard import render_financial_dashboard
|
14 |
+
# from pages.decision_simulator import render_decision_simulator
|
15 |
+
# from pages.fund_monitoring import render_fund_monitoring
|
16 |
+
# from pages.advisor import render_ai_financial_advisor
|
17 |
+
|
18 |
+
# Constants
|
19 |
+
DEFAULT_GROWTH_RATE = 0.08 # 8% monthly growth
|
20 |
+
DEFAULT_BURN_RATE = 85000 # $85,000 monthly burn
|
21 |
+
ENGINEER_SALARY = 10000 # $10,000 monthly cost per engineer ($120K/year)
|
22 |
+
|
23 |
+
# Initialize session state variables
|
24 |
+
if 'startups' not in st.session_state:
|
25 |
+
st.session_state.startups = {} # Dictionary to store multiple startup data
|
26 |
+
if 'current_startup' not in st.session_state:
|
27 |
+
st.session_state.current_startup = None # Currently selected startup
|
28 |
+
if 'current_page' not in st.session_state:
|
29 |
+
st.session_state.current_page = 'upload' # Default page
|
30 |
+
if 'insights_cache' not in st.session_state:
|
31 |
+
st.session_state.insights_cache = {}
|
32 |
+
|
33 |
+
def switch_page(page_name):
|
34 |
+
"""Function to switch between pages"""
|
35 |
+
st.session_state.current_page = page_name
|
36 |
+
st.rerun()
|
37 |
+
|
38 |
+
# Page config
|
39 |
+
st.set_page_config(
|
40 |
+
page_title="StartupFinancePilot",
|
41 |
+
page_icon="💰",
|
42 |
+
layout="wide",
|
43 |
+
initial_sidebar_state="expanded"
|
44 |
+
)
|
45 |
+
|
46 |
+
# Custom CSS
|
47 |
+
st.markdown("""
|
48 |
+
<style>
|
49 |
+
#MainMenu {visibility: hidden;}
|
50 |
+
footer {visibility: hidden;}
|
51 |
+
.stDeployButton {display:none;}
|
52 |
+
|
53 |
+
.main-header {
|
54 |
+
font-size: 2.5rem;
|
55 |
+
color: #0066cc;
|
56 |
+
margin-bottom: 0.5rem;
|
57 |
+
}
|
58 |
+
.sub-header {
|
59 |
+
font-size: 1.5rem;
|
60 |
+
color: #5c5c5c;
|
61 |
+
margin-bottom: 1.5rem;
|
62 |
+
}
|
63 |
+
.metric-card {
|
64 |
+
background-color: #f8f9fa;
|
65 |
+
border-radius: 10px;
|
66 |
+
padding: 20px;
|
67 |
+
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
68 |
+
}
|
69 |
+
.metric-label {
|
70 |
+
font-size: 1rem;
|
71 |
+
color: #5c5c5c;
|
72 |
+
}
|
73 |
+
.metric-value {
|
74 |
+
font-size: 1.8rem;
|
75 |
+
color: #0066cc;
|
76 |
+
font-weight: bold;
|
77 |
+
}
|
78 |
+
.good-metric {
|
79 |
+
color: #28a745;
|
80 |
+
}
|
81 |
+
.warning-metric {
|
82 |
+
color: #ffc107;
|
83 |
+
}
|
84 |
+
.danger-metric {
|
85 |
+
color: #dc3545;
|
86 |
+
}
|
87 |
+
|
88 |
+
/* Style for sidebar buttons */
|
89 |
+
div.stButton > button {
|
90 |
+
width: 100%;
|
91 |
+
padding: 10px 10px;
|
92 |
+
border: none;
|
93 |
+
background-color: #E6F3FF;
|
94 |
+
color: #0066cc;
|
95 |
+
border-radius: 10px;
|
96 |
+
text-align: left;
|
97 |
+
margin: 5px 0;
|
98 |
+
font-weight: bold;
|
99 |
+
}
|
100 |
+
|
101 |
+
div.stButton > button:hover {
|
102 |
+
background-color: #CCE5FF;
|
103 |
+
color: #004080;
|
104 |
+
}
|
105 |
+
|
106 |
+
/* Style for title box */
|
107 |
+
.title-box {
|
108 |
+
background: linear-gradient(45deg, #0066cc, #66b3ff);
|
109 |
+
padding: 20px;
|
110 |
+
border-radius: 10px;
|
111 |
+
margin-bottom: 20px;
|
112 |
+
text-align: center;
|
113 |
+
color: white;
|
114 |
+
cursor: pointer;
|
115 |
+
}
|
116 |
+
</style>
|
117 |
+
""", unsafe_allow_html=True)
|
118 |
+
|
119 |
+
# Sample data
|
120 |
+
def load_sample_data():
|
121 |
+
"""Load sample data for demonstration"""
|
122 |
+
# TechHealth AI data
|
123 |
+
startup_data = {
|
124 |
+
"name": "TechHealth AI",
|
125 |
+
"stage": "Seed",
|
126 |
+
"founded": "18 months ago",
|
127 |
+
"employees": 12,
|
128 |
+
"last_funding": "$1.2M seed round 10 months ago",
|
129 |
+
"cash": 320000,
|
130 |
+
"burn_rate": 85000,
|
131 |
+
"revenue": 15000,
|
132 |
+
"growth_rate": 0.08
|
133 |
+
}
|
134 |
+
|
135 |
+
# Cash flow history
|
136 |
+
cash_flow_data = {
|
137 |
+
"Month": [f"Month {i}" for i in range(1, 11)],
|
138 |
+
"Revenue": [8000, 8500, 9200, 10000, 10800, 11700, 12600, 13600, 14700, 15800],
|
139 |
+
"Payroll": [60000, 60000, 62000, 62000, 65000, 65000, 70000, 70000, 75000, 75000],
|
140 |
+
"Marketing": [8000, 9000, 10000, 12000, 15000, 18000, 15000, 12000, 10000, 8000],
|
141 |
+
"Office": [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],
|
142 |
+
"Software": [3000, 3200, 3500, 3800, 4000, 4200, 4500, 4800, 5000, 5200],
|
143 |
+
"Travel": [2000, 1800, 2500, 3000, 4000, 4500, 3500, 3000, 2500, 2000],
|
144 |
+
"Legal": [1500, 1000, 800, 1200, 800, 2000, 1500, 1000, 3000, 1200],
|
145 |
+
"Misc": [1000, 1200, 1300, 1500, 1700, 1800, 2000, 2200, 2500, 2800]
|
146 |
+
}
|
147 |
+
|
148 |
+
# Add calculated fields
|
149 |
+
df = pd.DataFrame(cash_flow_data)
|
150 |
+
df["Total_Expenses"] = df[["Payroll", "Marketing", "Office", "Software", "Travel", "Legal", "Misc"]].sum(axis=1)
|
151 |
+
df["Net_Burn"] = df["Total_Expenses"] - df["Revenue"]
|
152 |
+
|
153 |
+
# Transaction data
|
154 |
+
transactions = pd.DataFrame([
|
155 |
+
{"Date": "2023-11-05", "Category": "Travel", "Vendor": "Caribbean Cruises", "Amount": 8500, "Description": "Team Retreat Planning", "Flag": "Suspicious"},
|
156 |
+
{"Date": "2023-11-12", "Category": "Marketing", "Vendor": "LuxuryGifts Inc", "Amount": 4200, "Description": "Client Appreciation", "Flag": "Suspicious"},
|
157 |
+
{"Date": "2023-11-22", "Category": "Office", "Vendor": "Premium Furniture", "Amount": 12000, "Description": "Office Upgrades", "Flag": "Suspicious"},
|
158 |
+
{"Date": "2023-11-28", "Category": "Consulting", "Vendor": "Strategic Vision LLC", "Amount": 7500, "Description": "Strategy Consulting", "Flag": "Suspicious"},
|
159 |
+
{"Date": "2023-12-05", "Category": "Software", "Vendor": "Personal Apple Store", "Amount": 3200, "Description": "Development Tools", "Flag": "Suspicious"},
|
160 |
+
{"Date": "2023-12-12", "Category": "Legal", "Vendor": "Anderson Brothers", "Amount": 5800, "Description": "Legal Services", "Flag": "Normal"},
|
161 |
+
{"Date": "2023-12-20", "Category": "Payroll", "Vendor": "November Payroll", "Amount": 75000, "Description": "Monthly Payroll", "Flag": "Normal"},
|
162 |
+
{"Date": "2023-12-22", "Category": "Marketing", "Vendor": "Google Ads", "Amount": 8000, "Description": "Ad Campaign", "Flag": "Normal"},
|
163 |
+
{"Date": "2023-12-25", "Category": "Office", "Vendor": "WeWork", "Amount": 5000, "Description": "Monthly Rent", "Flag": "Normal"},
|
164 |
+
{"Date": "2023-12-28", "Category": "Software", "Vendor": "AWS", "Amount": 5200, "Description": "Cloud Services", "Flag": "Normal"}
|
165 |
+
])
|
166 |
+
|
167 |
+
return startup_data, df, transactions
|
168 |
+
|
169 |
+
# Parse CSV file to dataframe
|
170 |
+
def parse_csv_to_df(file):
|
171 |
+
"""Parse uploaded CSV file to Pandas DataFrame"""
|
172 |
+
try:
|
173 |
+
df = pd.read_csv(file)
|
174 |
+
return df, None
|
175 |
+
except Exception as e:
|
176 |
+
return None, f"Error parsing CSV: {e}"
|
177 |
+
|
178 |
+
# Upload and process financial data files
|
179 |
+
def render_upload_page():
|
180 |
+
"""Render the upload page for startup data"""
|
181 |
+
st.markdown("<h1 class='main-header'>Upload Your Startup Data</h1>", unsafe_allow_html=True)
|
182 |
+
st.markdown("<p class='sub-header'>Upload CSV files or use sample data to get started</p>", unsafe_allow_html=True)
|
183 |
+
|
184 |
+
with st.expander("Upload Instructions", expanded=False):
|
185 |
+
st.markdown("""
|
186 |
+
### How to Upload Your Startup Data
|
187 |
+
|
188 |
+
You can upload three types of files:
|
189 |
+
|
190 |
+
1. **Company Profile** - A CSV with basic information about your startup including:
|
191 |
+
- name, stage, founded, employees, last_funding, cash, burn_rate, revenue, growth_rate
|
192 |
+
|
193 |
+
2. **Cash Flow Data** - A CSV with monthly cash flow data with columns:
|
194 |
+
- Month, Revenue, Payroll, Marketing, Office, Software, Travel, Legal, Misc
|
195 |
+
|
196 |
+
3. **Transaction Data** - A CSV with transaction details:
|
197 |
+
- Date, Category, Vendor, Amount, Description, Flag
|
198 |
+
|
199 |
+
If you don't have these files ready, you can use our sample data.
|
200 |
+
""")
|
201 |
+
|
202 |
+
col1, col2 = st.columns(2)
|
203 |
+
|
204 |
+
with col1:
|
205 |
+
startup_name = st.text_input("Startup Name", value="My Startup")
|
206 |
+
|
207 |
+
profile_file = st.file_uploader("Upload Company Profile (CSV)", type=['csv'])
|
208 |
+
cash_flow_file = st.file_uploader("Upload Cash Flow Data (CSV)", type=['csv'])
|
209 |
+
transactions_file = st.file_uploader("Upload Transactions Data (CSV)", type=['csv'])
|
210 |
+
|
211 |
+
with col2:
|
212 |
+
st.markdown("""
|
213 |
+
<div style="background-color: #f0f7ff; padding: 15px; border-radius: 10px; height: 90%;">
|
214 |
+
<h4>Why Upload Your Data?</h4>
|
215 |
+
<p>By uploading your actual financial data, you'll get:</p>
|
216 |
+
<ul>
|
217 |
+
<li>Personalized AI insights tailored to your startup</li>
|
218 |
+
<li>Accurate runway projections based on your real spending patterns</li>
|
219 |
+
<li>Custom recommendations to optimize your burn rate</li>
|
220 |
+
<li>More realistic decision simulations</li>
|
221 |
+
</ul>
|
222 |
+
<p>All data is processed securely and never stored permanently.</p>
|
223 |
+
</div>
|
224 |
+
""", unsafe_allow_html=True)
|
225 |
+
|
226 |
+
# Process the files if uploaded
|
227 |
+
if st.button("Process Data"):
|
228 |
+
# Initialize with default values
|
229 |
+
startup_data = {
|
230 |
+
"name": startup_name,
|
231 |
+
"stage": "Seed",
|
232 |
+
"founded": "12 months ago",
|
233 |
+
"employees": 5,
|
234 |
+
"last_funding": "Not specified",
|
235 |
+
"cash": 100000,
|
236 |
+
"burn_rate": 20000,
|
237 |
+
"revenue": 5000,
|
238 |
+
"growth_rate": 0.05
|
239 |
+
}
|
240 |
+
|
241 |
+
cash_flow_df = None
|
242 |
+
transactions_df = None
|
243 |
+
|
244 |
+
# Parse company profile
|
245 |
+
if profile_file:
|
246 |
+
try:
|
247 |
+
profile_df, error = parse_csv_to_df(profile_file)
|
248 |
+
if error:
|
249 |
+
st.error(error)
|
250 |
+
else:
|
251 |
+
# Get the first row as a dictionary
|
252 |
+
if len(profile_df) > 0:
|
253 |
+
startup_data.update(profile_df.iloc[0].to_dict())
|
254 |
+
st.success(f"Successfully loaded company profile for {startup_data['name']}")
|
255 |
+
except Exception as e:
|
256 |
+
st.error(f"Error processing company profile: {e}")
|
257 |
+
|
258 |
+
# Parse cash flow data
|
259 |
+
if cash_flow_file:
|
260 |
+
cash_flow_df, error = parse_csv_to_df(cash_flow_file)
|
261 |
+
if error:
|
262 |
+
st.error(error)
|
263 |
+
else:
|
264 |
+
# Add calculated fields if not present
|
265 |
+
if "Total_Expenses" not in cash_flow_df.columns:
|
266 |
+
expense_columns = [col for col in cash_flow_df.columns if col not in ["Month", "Revenue", "Total_Expenses", "Net_Burn"]]
|
267 |
+
cash_flow_df["Total_Expenses"] = cash_flow_df[expense_columns].sum(axis=1)
|
268 |
+
|
269 |
+
if "Net_Burn" not in cash_flow_df.columns:
|
270 |
+
cash_flow_df["Net_Burn"] = cash_flow_df["Total_Expenses"] - cash_flow_df["Revenue"]
|
271 |
+
|
272 |
+
st.success("Successfully loaded cash flow data")
|
273 |
+
|
274 |
+
# Parse transactions data
|
275 |
+
if transactions_file:
|
276 |
+
transactions_df, error = parse_csv_to_df(transactions_file)
|
277 |
+
if error:
|
278 |
+
st.error(error)
|
279 |
+
else:
|
280 |
+
# Ensure transactions data has required columns
|
281 |
+
required_columns = ["Date", "Category", "Vendor", "Amount", "Description"]
|
282 |
+
if all(col in transactions_df.columns for col in required_columns):
|
283 |
+
if "Flag" not in transactions_df.columns:
|
284 |
+
transactions_df["Flag"] = "Normal" # Default flag
|
285 |
+
|
286 |
+
st.success("Successfully loaded transactions data")
|
287 |
+
else:
|
288 |
+
st.error("Transactions file is missing required columns")
|
289 |
+
|
290 |
+
# If any files were processed, save the data to session state
|
291 |
+
if profile_file or cash_flow_file or transactions_file:
|
292 |
+
if cash_flow_df is None:
|
293 |
+
# Create a sample cash flow dataframe if none was uploaded
|
294 |
+
cash_flow_data = {
|
295 |
+
"Month": [f"Month {i}" for i in range(1, 7)],
|
296 |
+
"Revenue": [startup_data['revenue'] * (1 + startup_data['growth_rate'])**i for i in range(6)],
|
297 |
+
"Payroll": [startup_data['burn_rate'] * 0.7] * 6,
|
298 |
+
"Marketing": [startup_data['burn_rate'] * 0.15] * 6,
|
299 |
+
"Office": [startup_data['burn_rate'] * 0.05] * 6,
|
300 |
+
"Software": [startup_data['burn_rate'] * 0.03] * 6,
|
301 |
+
"Travel": [startup_data['burn_rate'] * 0.02] * 6,
|
302 |
+
"Legal": [startup_data['burn_rate'] * 0.01] * 6,
|
303 |
+
"Misc": [startup_data['burn_rate'] * 0.04] * 6
|
304 |
+
}
|
305 |
+
cash_flow_df = pd.DataFrame(cash_flow_data)
|
306 |
+
cash_flow_df["Total_Expenses"] = cash_flow_df[["Payroll", "Marketing", "Office", "Software", "Travel", "Legal", "Misc"]].sum(axis=1)
|
307 |
+
cash_flow_df["Net_Burn"] = cash_flow_df["Total_Expenses"] - cash_flow_df["Revenue"]
|
308 |
+
|
309 |
+
if transactions_df is None:
|
310 |
+
# Create a sample transactions dataframe if none was uploaded
|
311 |
+
transactions_data = {
|
312 |
+
"Date": [(datetime.now() - timedelta(days=i*5)).strftime("%Y-%m-%d") for i in range(10)],
|
313 |
+
"Category": ["Payroll", "Marketing", "Office", "Software", "Travel", "Legal", "Misc", "Payroll", "Marketing", "Office"],
|
314 |
+
"Vendor": ["Payroll Provider", "Facebook Ads", "Office Rent", "AWS", "Travel Agency", "Legal Firm", "Miscellaneous", "Payroll Provider", "Google Ads", "Office Supplies"],
|
315 |
+
"Amount": [startup_data['burn_rate'] * 0.7, startup_data['burn_rate'] * 0.15, startup_data['burn_rate'] * 0.05, startup_data['burn_rate'] * 0.03, startup_data['burn_rate'] * 0.02, startup_data['burn_rate'] * 0.01, startup_data['burn_rate'] * 0.04, startup_data['burn_rate'] * 0.7, startup_data['burn_rate'] * 0.15, startup_data['burn_rate'] * 0.05],
|
316 |
+
"Description": ["Monthly Payroll", "Ad Campaign", "Monthly Rent", "Cloud Services", "Business Travel", "Legal Services", "Miscellaneous Expenses", "Monthly Payroll", "Ad Campaign", "Office Supplies"],
|
317 |
+
"Flag": ["Normal", "Normal", "Normal", "Normal", "Normal", "Normal", "Normal", "Normal", "Normal", "Normal"]
|
318 |
+
}
|
319 |
+
transactions_df = pd.DataFrame(transactions_data)
|
320 |
+
|
321 |
+
# Store in session state
|
322 |
+
st.session_state.startups[startup_data['name']] = {
|
323 |
+
'profile': startup_data,
|
324 |
+
'cash_flow': cash_flow_df,
|
325 |
+
'transactions': transactions_df
|
326 |
+
}
|
327 |
+
|
328 |
+
# Set as current startup
|
329 |
+
st.session_state.current_startup = startup_data['name']
|
330 |
+
|
331 |
+
st.success(f"Successfully added {startup_data['name']} to your startups")
|
332 |
+
st.info("You can now analyze this startup's data in the dashboard")
|
333 |
+
|
334 |
+
# Redirect to dashboard
|
335 |
+
switch_page('dashboard')
|
336 |
+
|
337 |
+
# Sample data options
|
338 |
+
st.subheader("Or Use Sample Data")
|
339 |
+
|
340 |
+
sample_col1, sample_col2 = st.columns(2)
|
341 |
+
|
342 |
+
with sample_col1:
|
343 |
+
if st.button("Use TechHealth AI Sample"):
|
344 |
+
# Load sample data
|
345 |
+
startup_data, cash_flow_df, transactions_df = load_sample_data()
|
346 |
+
|
347 |
+
# Store in session state
|
348 |
+
st.session_state.startups["TechHealth AI"] = {
|
349 |
+
'profile': startup_data,
|
350 |
+
'cash_flow': cash_flow_df,
|
351 |
+
'transactions': transactions_df
|
352 |
+
}
|
353 |
+
|
354 |
+
# Set as current startup
|
355 |
+
st.session_state.current_startup = "TechHealth AI"
|
356 |
+
|
357 |
+
st.success("Successfully loaded TechHealth AI sample data")
|
358 |
+
# Redirect to dashboard
|
359 |
+
switch_page('dashboard')
|
360 |
+
|
361 |
+
with sample_col2:
|
362 |
+
if st.button("Use Custom Sample"):
|
363 |
+
# Create a custom sample
|
364 |
+
startup_data = {
|
365 |
+
"name": "GreenTech Innovations",
|
366 |
+
"stage": "Series A",
|
367 |
+
"founded": "3 years ago",
|
368 |
+
"employees": 25,
|
369 |
+
"last_funding": "$4.5M Series A 8 months ago",
|
370 |
+
"cash": 2800000,
|
371 |
+
"burn_rate": 220000,
|
372 |
+
"revenue": 75000,
|
373 |
+
"growth_rate": 0.12
|
374 |
+
}
|
375 |
+
|
376 |
+
# Sample cash flow data
|
377 |
+
cash_flow_data = {
|
378 |
+
"Month": [f"Month {i}" for i in range(1, 11)],
|
379 |
+
"Revenue": [45000, 48000, 52000, 57000, 62000, 66000, 70000, 72000, 74000, 75000],
|
380 |
+
"Payroll": [140000, 142000, 145000, 150000, 160000, 165000, 175000, 180000, 185000, 190000],
|
381 |
+
"Marketing": [25000, 28000, 30000, 32000, 35000, 32000, 30000, 28000, 26000, 25000],
|
382 |
+
"Office": [12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000],
|
383 |
+
"Software": [8000, 8500, 9000, 9500, 10000, 10500, 11000, 11500, 12000, 12500],
|
384 |
+
"Travel": [5000, 6000, 7000, 8000, 7000, 6000, 5000, 6000, 7000, 8000],
|
385 |
+
"Legal": [4000, 3000, 3500, 2500, 3000, 4000, 3500, 3000, 2500, 3000],
|
386 |
+
"Misc": [3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500]
|
387 |
+
}
|
388 |
+
|
389 |
+
cash_flow_df = pd.DataFrame(cash_flow_data)
|
390 |
+
cash_flow_df["Total_Expenses"] = cash_flow_df[["Payroll", "Marketing", "Office", "Software", "Travel", "Legal", "Misc"]].sum(axis=1)
|
391 |
+
cash_flow_df["Net_Burn"] = cash_flow_df["Total_Expenses"] - cash_flow_df["Revenue"]
|
392 |
+
|
393 |
+
# Sample transaction data
|
394 |
+
transactions_df = pd.DataFrame([
|
395 |
+
{"Date": "2023-11-10", "Category": "Travel", "Vendor": "First Class Flights", "Amount": 12000, "Description": "Executive Retreat", "Flag": "Suspicious"},
|
396 |
+
{"Date": "2023-11-18", "Category": "Marketing", "Vendor": "VIP Events Co", "Amount": 18000, "Description": "Investor Dinner", "Flag": "Suspicious"},
|
397 |
+
{"Date": "2023-12-01", "Category": "Office", "Vendor": "Luxury Furniture", "Amount": 25000, "Description": "Executive Office Upgrade", "Flag": "Suspicious"},
|
398 |
+
{"Date": "2023-12-15", "Category": "Legal", "Vendor": "Premium Law Group", "Amount": 35000, "Description": "Legal Consultation", "Flag": "Normal"},
|
399 |
+
{"Date": "2023-12-20", "Category": "Payroll", "Vendor": "December Payroll", "Amount": 190000, "Description": "Monthly Payroll", "Flag": "Normal"}
|
400 |
+
])
|
401 |
+
|
402 |
+
# Store in session state
|
403 |
+
st.session_state.startups["GreenTech Innovations"] = {
|
404 |
+
'profile': startup_data,
|
405 |
+
'cash_flow': cash_flow_df,
|
406 |
+
'transactions': transactions_df
|
407 |
+
}
|
408 |
+
|
409 |
+
# Set as current startup
|
410 |
+
st.session_state.current_startup = "GreenTech Innovations"
|
411 |
+
|
412 |
+
st.success("Successfully loaded GreenTech Innovations sample data")
|
413 |
+
# Redirect to dashboard
|
414 |
+
switch_page('dashboard')
|
415 |
+
|
416 |
+
# Create sidebar navigation
|
417 |
+
def create_sidebar():
|
418 |
+
with st.sidebar:
|
419 |
+
# Title box that works as home button
|
420 |
+
st.markdown("""
|
421 |
+
<div class="title-box" onclick="window.location.href='#'">
|
422 |
+
<h1>💰 StartupFinancePilot</h1>
|
423 |
+
<p>AI-powered financial assistant for startups</p>
|
424 |
+
</div>
|
425 |
+
""", unsafe_allow_html=True)
|
426 |
+
|
427 |
+
# Startup selector (if there are startups in the session state)
|
428 |
+
if st.session_state.startups:
|
429 |
+
st.subheader("Selected Startup")
|
430 |
+
startup_names = list(st.session_state.startups.keys())
|
431 |
+
selected_startup = st.selectbox(
|
432 |
+
"Choose Startup",
|
433 |
+
startup_names,
|
434 |
+
index=startup_names.index(st.session_state.current_startup) if st.session_state.current_startup in startup_names else 0
|
435 |
+
)
|
436 |
+
st.session_state.current_startup = selected_startup
|
437 |
+
|
438 |
+
# Show basic startup info
|
439 |
+
if selected_startup in st.session_state.startups:
|
440 |
+
startup_data = st.session_state.startups[selected_startup]['profile']
|
441 |
+
st.markdown(f"""
|
442 |
+
**Stage:** {startup_data['stage']}
|
443 |
+
**Cash:** ${startup_data['cash']:,}
|
444 |
+
**Monthly Burn:** ${startup_data['burn_rate']:,}
|
445 |
+
**Monthly Revenue:** ${startup_data['revenue']:,}
|
446 |
+
""")
|
447 |
+
|
448 |
+
st.markdown("<hr>", unsafe_allow_html=True) # Divider
|
449 |
+
|
450 |
+
# Upload data button at the top
|
451 |
+
if st.button("📤 Upload Startup Data", use_container_width=True):
|
452 |
+
switch_page('upload')
|
453 |
+
|
454 |
+
# Navigation buttons
|
455 |
+
if st.button("📊 Financial Dashboard", use_container_width=True):
|
456 |
+
switch_page('dashboard')
|
457 |
+
|
458 |
+
if st.button("🔮 Decision Simulator", use_container_width=True):
|
459 |
+
switch_page('simulator')
|
460 |
+
|
461 |
+
if st.button("🕵️ Fund Monitoring", use_container_width=True):
|
462 |
+
switch_page('monitoring')
|
463 |
+
|
464 |
+
if st.button("🤖 AI Financial Advisor", use_container_width=True):
|
465 |
+
switch_page('advisor')
|
466 |
+
|
467 |
+
# Main function
|
468 |
+
def main():
|
469 |
+
# Create sidebar navigation
|
470 |
+
create_sidebar()
|
471 |
+
|
472 |
+
# Check if we have any data to work with
|
473 |
+
if not st.session_state.startups and st.session_state.current_page != 'upload':
|
474 |
+
st.warning("No startup data found. Please upload your data or use a sample dataset.")
|
475 |
+
render_upload_page()
|
476 |
+
return
|
477 |
+
|
478 |
+
# Render the correct page based on session state
|
479 |
+
if st.session_state.current_page == 'upload':
|
480 |
+
render_upload_page()
|
481 |
+
elif st.session_state.current_page == 'dashboard':
|
482 |
+
# Replace with your dashboard page function
|
483 |
+
from dashboard import render_financial_dashboard
|
484 |
+
render_financial_dashboard(
|
485 |
+
st.session_state.startups[st.session_state.current_startup]['profile'],
|
486 |
+
st.session_state.startups[st.session_state.current_startup]['cash_flow']
|
487 |
+
)
|
488 |
+
elif st.session_state.current_page == 'simulator':
|
489 |
+
# Replace with your simulator page function
|
490 |
+
from decision_simulator import render_decision_simulator
|
491 |
+
render_decision_simulator(
|
492 |
+
st.session_state.startups[st.session_state.current_startup]['profile']
|
493 |
+
)
|
494 |
+
elif st.session_state.current_page == 'monitoring':
|
495 |
+
# Replace with your monitoring page function
|
496 |
+
from fund_monitoring import render_fund_monitoring
|
497 |
+
render_fund_monitoring(
|
498 |
+
st.session_state.startups[st.session_state.current_startup]['transactions']
|
499 |
+
)
|
500 |
+
elif st.session_state.current_page == 'advisor':
|
501 |
+
# Replace with your advisor page function
|
502 |
+
from advisor import render_ai_financial_advisor
|
503 |
+
render_ai_financial_advisor(
|
504 |
+
st.session_state.startups[st.session_state.current_startup]['profile']
|
505 |
+
)
|
506 |
+
|
507 |
+
if __name__ == "__main__":
|
508 |
+
main()
|