Skip to content

Commit 0275a31

Browse files
committed
v1 release
0 parents  commit 0275a31

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2662
-0
lines changed

.gitignore

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
16+
# Editor directories and files
17+
.vscode/*
18+
!.vscode/extensions.json
19+
.idea
20+
.DS_Store
21+
*.suo
22+
*.ntvs*
23+
*.njsproj
24+
*.sln
25+
*.sw?
26+
.env
27+
bun.lockb
28+
package-lock.json

README.md

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# AI Form Builder
2+
3+
A modern web application that leverages AI to generate dynamic forms instantly with google form and xml export.
4+
5+
## Overview
6+
7+
AI Form Builder simplifies form creation by using artificial intelligence to generate complete form structures from natural language descriptions. Perfect for developers, product managers, and anyone who needs to quickly create professional forms.
8+
9+
## Key Features
10+
11+
- **AI-Powered Generation**: Create complex forms using simple text descriptions
12+
- **Real-time Preview**: Instantly view your generated forms {TODO}
13+
- **Theme Support**: Built-in dark/light mode
14+
- **Google Forms Export**: Export your forms directly to Google Forms
15+
- **Responsive Design**: Fully responsive across all devices
16+
- **Type Safety**: Full TypeScript support for reliable development {TODO}
17+
18+
## 🛠️ Technical Stack
19+
20+
### Frontend
21+
22+
- Vite
23+
- Tailwind CSS
24+
- Shadcn UI
25+
- React Hook Form
26+
- React Router
27+
28+
### Backend
29+
30+
- Express.js server
31+
- OpenAI API integration
32+
- Google Forms API integration
33+
- Hugging Face API integration
34+
35+
## 🚀 Getting Started
36+
37+
1. Clone the repository:
38+
39+
```bash
40+
git clone ..
41+
cd ai-form-builder
42+
```
43+
44+
2. Install Bun (if not already installed):
45+
46+
```bash
47+
curl -fsSL https://bun.sh/install | bash
48+
```
49+
50+
3. Install dependencies:
51+
52+
```bash
53+
bun install
54+
```
55+
56+
4. Set up environment variables:
57+
58+
```bash
59+
cp .env.example .env
60+
```
61+
62+
5. Start development servers:
63+
64+
```bash
65+
# Start both frontend and backend
66+
bun run dev:all
67+
68+
# Or start them separately:
69+
bun run dev # Frontend only
70+
bun run server # Backend only
71+
```
72+
73+
## Environment Setup
74+
75+
Create a `.env` file with the following variables:
76+
77+
```env
78+
# Frontend
79+
VITE_HUGGINGFACE_API_KEY=your_huggingface_key
80+
81+
# Backend
82+
OPENAI_API_KEY=your_openai_key
83+
GOOGLE_CLIENT_ID=your_google_client_id
84+
GOOGLE_CLIENT_SECRET=your_google_client_secret
85+
GOOGLE_REDIRECT_URI=http://localhost:3001/oauth2callback
86+
```
87+
88+
## Available Scripts
89+
90+
- `bun run dev` - Start frontend development server
91+
- `bun run server` - Start backend server
92+
- `bun run dev:all` - Start both frontend and backend
93+
- `bun run build` - Build for production
94+
- `bun run preview` - Preview production build
95+
- `bun run token` - Generate Google OAuth refresh token
96+
97+
## Contributing
98+
99+
1. Fork the repository
100+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
101+
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
102+
4. Push to the branch (`git push origin feature/amazing-feature`)
103+
5. Open a Pull Request
104+
105+
## License
106+
107+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
108+
109+
## Acknowledgments
110+
111+
- [Shadcn UI](https://ui.shadcn.com/) for the beautiful components
112+
- [OpenAI](https://openai.com/) for AI capabilities
113+
- [Google Forms API](https://developers.google.com/forms/api) for form export functionality

components.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"$schema": "https://ui.shadcn.com/schema.json",
3+
"style": "default",
4+
"rsc": false,
5+
"tsx": true,
6+
"tailwind": {
7+
"config": "tailwind.config.js",
8+
"css": "src/index.css",
9+
"baseColor": "neutral",
10+
"cssVariables": true,
11+
"prefix": ""
12+
},
13+
"aliases": {
14+
"components": "@/components",
15+
"utils": "@/lib/utils",
16+
"ui": "@/components/ui",
17+
"lib": "@/lib",
18+
"hooks": "@/hooks"
19+
}
20+
}

eslint.config.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import js from '@eslint/js'
2+
import globals from 'globals'
3+
import reactHooks from 'eslint-plugin-react-hooks'
4+
import reactRefresh from 'eslint-plugin-react-refresh'
5+
import tseslint from 'typescript-eslint'
6+
7+
export default tseslint.config(
8+
{ ignores: ['dist'] },
9+
{
10+
extends: [js.configs.recommended, ...tseslint.configs.recommended],
11+
files: ['**/*.{ts,tsx}'],
12+
languageOptions: {
13+
ecmaVersion: 2020,
14+
globals: globals.browser,
15+
},
16+
plugins: {
17+
'react-hooks': reactHooks,
18+
'react-refresh': reactRefresh,
19+
},
20+
rules: {
21+
...reactHooks.configs.recommended.rules,
22+
'react-refresh/only-export-components': [
23+
'warn',
24+
{ allowConstantExport: true },
25+
],
26+
},
27+
},
28+
)

index.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Formify AI - Build Forms with ease!</title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/main.tsx"></script>
12+
</body>
13+
</html>

package.json

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"name": "ai-formgen",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite",
8+
"build": "tsc && vite build",
9+
"preview": "vite preview",
10+
"server": "bun run server/index.ts",
11+
"dev:all": "bun run dev & bun run server",
12+
"token": "bun run scripts/get-refresh-token.ts"
13+
},
14+
"dependencies": {
15+
"@hookform/resolvers": "^3.9.1",
16+
"@radix-ui/react-alert-dialog": "^1.1.2",
17+
"@radix-ui/react-dropdown-menu": "^2.1.2",
18+
"@radix-ui/react-label": "^2.1.0",
19+
"@radix-ui/react-slot": "^1.1.0",
20+
"@radix-ui/react-switch": "^1.1.1",
21+
"@radix-ui/react-tabs": "^1.1.1",
22+
"@radix-ui/react-toast": "^1.2.2",
23+
"@types/cors": "^2.8.17",
24+
"@types/express": "^5.0.0",
25+
"class-variance-authority": "^0.7.0",
26+
"clsx": "^2.1.1",
27+
"cors": "^2.8.5",
28+
"dotenv": "^16.4.5",
29+
"express": "^4.21.1",
30+
"googleapis": "^144.0.0",
31+
"lucide-react": "^0.454.0",
32+
"next-themes": "^0.3.0",
33+
"openai": "^4.70.2",
34+
"react": "^18.3.1",
35+
"react-dom": "^18.3.1",
36+
"react-hook-form": "^7.53.2",
37+
"react-router-dom": "^6.28.0",
38+
"sonner": "^1.6.1",
39+
"tailwind-merge": "^2.5.4",
40+
"tailwindcss-animate": "^1.0.7",
41+
"zod": "^3.23.8"
42+
},
43+
"devDependencies": {
44+
"@eslint/js": "^9.13.0",
45+
"@types/node": "^22.9.0",
46+
"@types/react": "^18.3.12",
47+
"@types/react-dom": "^18.3.1",
48+
"@vitejs/plugin-react": "^4.3.3",
49+
"autoprefixer": "^10.4.20",
50+
"eslint": "^9.13.0",
51+
"eslint-plugin-react-hooks": "^5.0.0",
52+
"eslint-plugin-react-refresh": "^0.4.14",
53+
"globals": "^15.11.0",
54+
"postcss": "^8.4.47",
55+
"tailwindcss": "^3.4.14",
56+
"typescript": "~5.6.2",
57+
"typescript-eslint": "^8.11.0",
58+
"vite": "^5.4.10"
59+
}
60+
}

postcss.config.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default {
2+
plugins: {
3+
tailwindcss: {},
4+
autoprefixer: {},
5+
},
6+
}

public/vite.svg

+1
Loading

server.ts

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import express from "express";
2+
import { OpenAI } from "openai";
3+
import dotenv from "dotenv";
4+
import cors from "cors";
5+
6+
dotenv.config();
7+
8+
const app = express();
9+
app.use(cors());
10+
app.use(express.json());
11+
12+
// Validate environment variables
13+
if (!process.env.OPENAI_API_KEY) {
14+
console.error("Missing OPENAI_API_KEY environment variable");
15+
process.exit(1);
16+
}
17+
18+
const openai = new OpenAI({
19+
apiKey: process.env.OPENAI_API_KEY,
20+
});
21+
22+
app.post("/api/generate", async (req, res) => {
23+
try {
24+
if (!req.body.messages) {
25+
return res.status(400).json({ error: "Messages are required" });
26+
}
27+
28+
const response = await openai.chat.completions.create({
29+
model: "gpt-3.5-turbo",
30+
messages: req.body.messages,
31+
});
32+
33+
res.json(response.choices[0].message);
34+
} catch (error) {
35+
console.error("OpenAI API Error:", error);
36+
res.status(500).json({
37+
error: "Failed to generate response",
38+
details: error.message,
39+
});
40+
}
41+
});
42+
43+
app.listen(3001, () => {
44+
console.log("Server running on port 3001");
45+
});

0 commit comments

Comments
 (0)