FrederickSundeep commited on
Commit
d040477
·
1 Parent(s): f1d7e4e
Files changed (4) hide show
  1. package-lock.json +0 -0
  2. package.json +1 -0
  3. src/App.js +5 -16
  4. src/FileUploadForm.js +82 -0
package-lock.json ADDED
The diff for this file is too large to render. See raw diff
 
package.json CHANGED
@@ -7,6 +7,7 @@
7
  "@testing-library/jest-dom": "^6.6.3",
8
  "@testing-library/react": "^16.3.0",
9
  "@testing-library/user-event": "^13.5.0",
 
10
  "react": "^19.1.0",
11
  "react-dom": "^19.1.0",
12
  "react-scripts": "5.0.1",
 
7
  "@testing-library/jest-dom": "^6.6.3",
8
  "@testing-library/react": "^16.3.0",
9
  "@testing-library/user-event": "^13.5.0",
10
+ "axios": "^1.11.0",
11
  "react": "^19.1.0",
12
  "react-dom": "^19.1.0",
13
  "react-scripts": "5.0.1",
src/App.js CHANGED
@@ -1,23 +1,12 @@
1
- import logo from './logo.svg';
2
- import './App.css';
 
3
 
4
  function App() {
5
  return (
6
  <div className="App">
7
- <header className="App-header">
8
- <img src={logo} className="App-logo" alt="logo" />
9
- <p>
10
- Edit <code>src/App.js</code> and save to reload.
11
- </p>
12
- <a
13
- className="App-link"
14
- href="https://reactjs.org"
15
- target="_blank"
16
- rel="noopener noreferrer"
17
- >
18
- Learn React
19
- </a>
20
- </header>
21
  </div>
22
  );
23
  }
 
1
+ // src/App.js
2
+ import React from 'react';
3
+ import FileUploadForm from './FileUploadForm';
4
 
5
  function App() {
6
  return (
7
  <div className="App">
8
+ <h1>🧠 AI Project Generator</h1>
9
+ <FileUploadForm />
 
 
 
 
 
 
 
 
 
 
 
 
10
  </div>
11
  );
12
  }
src/FileUploadForm.js ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // src/FileUploadForm.js
2
+ import React, { useState } from 'react';
3
+ import axios from 'axios';
4
+
5
+ const FileUploadForm = () => {
6
+ const [file, setFile] = useState(null);
7
+ const [frontend, setFrontend] = useState("React");
8
+ const [backend, setBackend] = useState("Flask");
9
+ const [database, setDatabase] = useState("PostgreSQL");
10
+ const [loading, setLoading] = useState(false);
11
+
12
+ const handleDownload = async (e) => {
13
+ e.preventDefault();
14
+ if (!file) return alert("Please select a file!");
15
+
16
+ const formData = new FormData();
17
+ formData.append("file", file);
18
+ formData.append("frontend", frontend);
19
+ formData.append("backend", backend);
20
+ formData.append("database", database);
21
+
22
+ try {
23
+ setLoading(true);
24
+ const response = await axios.post(
25
+ "https://your-flask-api-url/chat-stream-doc", // ✅ Update to actual URL
26
+ formData,
27
+ {
28
+ responseType: "blob", // important for zip file
29
+ }
30
+ );
31
+
32
+ // create download link
33
+ const blob = new Blob([response.data], { type: "application/zip" });
34
+ const url = window.URL.createObjectURL(blob);
35
+ const a = document.createElement("a");
36
+ a.href = url;
37
+ a.download = "generated_project.zip";
38
+ document.body.appendChild(a);
39
+ a.click();
40
+ window.URL.revokeObjectURL(url);
41
+ } catch (error) {
42
+ console.error("Error downloading ZIP:", error);
43
+ alert("Failed to generate ZIP. Check your input or server logs.");
44
+ } finally {
45
+ setLoading(false);
46
+ }
47
+ };
48
+
49
+ return (
50
+ <form onSubmit={handleDownload}>
51
+ <h2>Upload Requirement Document</h2>
52
+ <input type="file" onChange={(e) => setFile(e.target.files[0])} accept=".txt,.pdf" required />
53
+ <br />
54
+ <label>Frontend:</label>
55
+ <select value={frontend} onChange={(e) => setFrontend(e.target.value)}>
56
+ <option value="React">React</option>
57
+ <option value="Angular">Angular</option>
58
+ <option value="Vue">Vue</option>
59
+ </select>
60
+ <br />
61
+ <label>Backend:</label>
62
+ <select value={backend} onChange={(e) => setBackend(e.target.value)}>
63
+ <option value="Flask">Flask</option>
64
+ <option value="Node.js">Node.js</option>
65
+ <option value="Django">Django</option>
66
+ </select>
67
+ <br />
68
+ <label>Database:</label>
69
+ <select value={database} onChange={(e) => setDatabase(e.target.value)}>
70
+ <option value="PostgreSQL">PostgreSQL</option>
71
+ <option value="MongoDB">MongoDB</option>
72
+ <option value="MySQL">MySQL</option>
73
+ </select>
74
+ <br /><br />
75
+ <button type="submit" disabled={loading}>
76
+ {loading ? "Generating..." : "Generate ZIP"}
77
+ </button>
78
+ </form>
79
+ );
80
+ };
81
+
82
+ export default FileUploadForm;