Matthewmasturbation commited on
Commit
1e9d29b
Β·
verified Β·
1 Parent(s): 1584052

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +105 -13
app.py CHANGED
@@ -100,8 +100,7 @@ def build_pack(app_idea, stack, platform, style, auth, database, extras):
100
  if "File uploads" in extras:
101
  endpoints += ["POST /api/files/upload", "DELETE /api/files/:id"]
102
 
103
- folder_tree = f"""
104
- {slug}/
105
  β”œβ”€β”€ app/
106
  β”‚ β”œβ”€β”€ components/
107
  β”‚ β”œβ”€β”€ pages/
@@ -121,10 +120,9 @@ def build_pack(app_idea, stack, platform, style, auth, database, extras):
121
  β”œβ”€β”€ tests/
122
  β”œβ”€β”€ .env.example
123
  β”œβ”€β”€ README.md
124
- └── package.json
125
- """.strip()
126
 
127
- starter_code = f'''# {app_name}
128
 
129
  ## Suggested stack
130
  - Frontend: {stack}
@@ -165,11 +163,9 @@ CREATE TABLE projects (
165
  created_at TIMESTAMP DEFAULT NOW(),
166
  updated_at TIMESTAMP DEFAULT NOW()
167
  );
168
- ```
169
- '''
170
 
171
- prd = f"""
172
- # Product Brief
173
 
174
  ## App Name
175
  {app_name}
@@ -197,8 +193,7 @@ Create a {style.lower()} product that feels fast, clear, and easy to expand in a
197
 
198
  api_plan = "# API Routes\n\n" + "\n".join(f"- {route}" for route in endpoints)
199
 
200
- system_prompt = f"""
201
- You are a senior product engineer and UX architect.
202
  Generate implementation-ready output for this app idea: {app_idea}
203
  Stack: {stack}
204
  Platform: {platform}
@@ -215,8 +210,7 @@ Return:
215
  6. API routes
216
  7. Folder structure
217
  8. Starter code
218
- Keep output concise, structured, and copy-paste ready.
219
- """.strip()
220
 
221
  json_export = json.dumps({
222
  "name": app_name,
@@ -244,3 +238,101 @@ css = """
244
  --panel: #121937;
245
  --panel-2: #1a234a;
246
  --line: #2a3569;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  if "File uploads" in extras:
101
  endpoints += ["POST /api/files/upload", "DELETE /api/files/:id"]
102
 
103
+ folder_tree = f"""{slug}/
 
104
  β”œβ”€β”€ app/
105
  β”‚ β”œβ”€β”€ components/
106
  β”‚ β”œβ”€β”€ pages/
 
120
  β”œβ”€β”€ tests/
121
  β”œβ”€β”€ .env.example
122
  β”œβ”€β”€ README.md
123
+ └── package.json"""
 
124
 
125
+ starter_code = f"""# {app_name}
126
 
127
  ## Suggested stack
128
  - Frontend: {stack}
 
163
  created_at TIMESTAMP DEFAULT NOW(),
164
  updated_at TIMESTAMP DEFAULT NOW()
165
  );
166
+ ```"""
 
167
 
168
+ prd = f"""# Product Brief
 
169
 
170
  ## App Name
171
  {app_name}
 
193
 
194
  api_plan = "# API Routes\n\n" + "\n".join(f"- {route}" for route in endpoints)
195
 
196
+ system_prompt = f"""You are a senior product engineer and UX architect.
 
197
  Generate implementation-ready output for this app idea: {app_idea}
198
  Stack: {stack}
199
  Platform: {platform}
 
210
  6. API routes
211
  7. Folder structure
212
  8. Starter code
213
+ Keep output concise, structured, and copy-paste ready."""
 
214
 
215
  json_export = json.dumps({
216
  "name": app_name,
 
238
  --panel: #121937;
239
  --panel-2: #1a234a;
240
  --line: #2a3569;
241
+ --text: #f5f7ff;
242
+ --muted: #a8b3d1;
243
+ --accent: #68e1fd;
244
+ --accent-2: #8b5cf6;
245
+ }
246
+ .gradio-container {
247
+ background: linear-gradient(180deg, #0b1020 0%, #101735 100%);
248
+ }
249
+ .block, .gr-box, .gr-panel {
250
+ border-radius: 18px !important;
251
+ }
252
+ """
253
+
254
+ with gr.Blocks(css=css, theme=gr.themes.Soft(), title=TITLE) as demo:
255
+ gr.Markdown(
256
+ """
257
+ # AppDraft
258
+ ### Turn an app idea into a copy-paste build pack for your IDE.
259
+ Describe the app once, then generate a product brief, UI plan, schema, API routes, folder structure, and starter code.
260
+ """
261
+ )
262
+
263
+ with gr.Row():
264
+ app_idea = gr.Textbox(
265
+ label="App idea",
266
+ lines=5,
267
+ placeholder="Example: A local service marketplace for last-minute movers with quotes, scheduling, reviews, Stripe payments, and an admin dashboard.",
268
+ )
269
+ with gr.Column():
270
+ stack = gr.Dropdown(
271
+ ["Next.js + TypeScript", "React + Vite", "FastAPI + React", "Flask + HTMX", "Electron + React", "React Native + Expo"],
272
+ value="Next.js + TypeScript",
273
+ label="Target stack",
274
+ )
275
+ platform = gr.Dropdown(
276
+ ["Web app", "Mobile app", "Desktop app", "Marketplace", "SaaS dashboard", "Landing page + app"],
277
+ value="Web app",
278
+ label="Platform",
279
+ )
280
+ style = gr.Dropdown(
281
+ ["Minimal modern", "Dark SaaS", "Bold startup", "Playful consumer", "Enterprise clean", "Mobile-first utility"],
282
+ value="Dark SaaS",
283
+ label="Design style",
284
+ )
285
+ auth = gr.Dropdown(
286
+ ["Email + password", "Magic link", "OAuth", "No auth"],
287
+ value="Email + password",
288
+ label="Auth",
289
+ )
290
+ database = gr.Dropdown(
291
+ ["PostgreSQL", "Supabase", "SQLite", "MongoDB", "Firebase"],
292
+ value="PostgreSQL",
293
+ label="Database",
294
+ )
295
+ extras = gr.CheckboxGroup(
296
+ ["Payments", "Notifications", "Admin panel", "AI features", "File uploads", "Realtime"],
297
+ label="Extras",
298
+ )
299
+
300
+ generate = gr.Button("Generate build pack", variant="primary")
301
+
302
+ with gr.Tabs():
303
+ with gr.Tab("PRD"):
304
+ prd = gr.Markdown()
305
+ with gr.Tab("UI"):
306
+ ui = gr.Markdown()
307
+ with gr.Tab("Database"):
308
+ db = gr.Markdown()
309
+ with gr.Tab("API"):
310
+ api = gr.Markdown()
311
+ with gr.Tab("Structure"):
312
+ tree = gr.Code(language="text")
313
+ with gr.Tab("Starter code"):
314
+ starter = gr.Markdown()
315
+ with gr.Tab("Prompt"):
316
+ prompt = gr.Code(language="markdown")
317
+ with gr.Tab("JSON"):
318
+ export_json = gr.Code(language="json")
319
+
320
+ generate.click(
321
+ fn=build_pack,
322
+ inputs=[app_idea, stack, platform, style, auth, database, extras],
323
+ outputs=[prd, ui, db, api, tree, starter, prompt, export_json],
324
+ )
325
+
326
+ if __name__ == "__main__":
327
+ demo.launch()
328
+ ```
329
+
330
+ ## Do this now
331
+
332
+ 1. Open `app.py` in your repo.[1]
333
+ 2. Select all and replace it with the code above.[1]
334
+ 3. Commit the change. Hugging Face will rebuild automatically after the commit.[1]
335
+
336
+ ## If it still fails
337
+
338
+ If there’s another error after this, send the next log output. The current logs show only the unterminated triple-quoted string problem, so fixing `app.py` should move you to the next stage.[1]