Reubencf commited on
Commit
7a6e1d4
·
1 Parent(s): 3b8892c

Add HuggingFace Space Docker setup and update README

Browse files
Files changed (3) hide show
  1. .dockerignore +19 -49
  2. Dockerfile +41 -51
  3. README.md +33 -335
.dockerignore CHANGED
@@ -1,49 +1,19 @@
1
- # Dependencies
2
- node_modules
3
- npm-debug.log*
4
- yarn-debug.log*
5
- yarn-error.log*
6
- package-lock.json
7
- yarn.lock
8
- pnpm-lock.yaml
9
-
10
- # Next.js
11
- .next
12
- out
13
- dist
14
- build
15
-
16
- # Testing
17
- coverage
18
- .nyc_output
19
-
20
- # Misc
21
- .DS_Store
22
- *.pem
23
- .env
24
- .env.local
25
- .env.development.local
26
- .env.test.local
27
- .env.production.local
28
-
29
- # Debug
30
- npm-debug.log*
31
- yarn-debug.log*
32
- yarn-error.log*
33
-
34
- # IDEs
35
- .idea
36
- .vscode
37
- *.swp
38
- *.swo
39
- *~
40
-
41
- # Git
42
- .git
43
- .gitignore
44
- README.md
45
-
46
- # Docker
47
- Dockerfile
48
- .dockerignore
49
- docker-compose.yml
 
1
+ node_modules
2
+ .next
3
+ out
4
+ build
5
+ coverage
6
+ .DS_Store
7
+ *.pem
8
+ .env
9
+ .env.local
10
+ .env*.local
11
+ npm-debug.log*
12
+ yarn-debug.log*
13
+ .idea
14
+ .vscode
15
+ .git
16
+ .claude
17
+ Dockerfile
18
+ .dockerignore
19
+ docker-compose.yml
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Dockerfile CHANGED
@@ -1,51 +1,41 @@
1
- # Stage 1: Dependencies
2
- FROM node:20-alpine AS deps
3
- RUN apk add --no-cache libc6-compat
4
- WORKDIR /app
5
-
6
- # Copy package files
7
- COPY package.json package-lock.json* ./
8
- RUN npm ci
9
-
10
- # Stage 2: Builder
11
- FROM node:20-alpine AS builder
12
- WORKDIR /app
13
-
14
- # Copy dependencies from deps stage
15
- COPY --from=deps /app/node_modules ./node_modules
16
- COPY . .
17
-
18
- # Disable telemetry during build
19
- ENV NEXT_TELEMETRY_DISABLED=1
20
-
21
- # Build the application
22
- RUN npm run build
23
-
24
- # Stage 3: Runner
25
- FROM node:20-alpine AS runner
26
- WORKDIR /app
27
-
28
- ENV NODE_ENV=production
29
- ENV NEXT_TELEMETRY_DISABLED=1
30
-
31
- # Create a non-root user
32
- RUN addgroup --system --gid 1001 nodejs
33
- RUN adduser --system --uid 1001 nextjs
34
-
35
- # Copy necessary files from builder
36
- COPY --from=builder /app/public ./public
37
- COPY --from=builder /app/.next/standalone ./
38
- COPY --from=builder /app/.next/static ./.next/static
39
-
40
- # Set correct permissions
41
- RUN chown -R nextjs:nodejs /app
42
-
43
- USER nextjs
44
-
45
- EXPOSE 3000
46
-
47
- ENV PORT=3000
48
- ENV HOSTNAME="0.0.0.0"
49
-
50
- # Start the application
51
- CMD ["node", "server.js"]
 
1
+ FROM node:20-alpine AS base
2
+
3
+ # Install dependencies only when needed
4
+ FROM base AS deps
5
+ RUN apk add --no-cache libc6-compat
6
+ WORKDIR /app
7
+
8
+ COPY package.json package-lock.json* ./
9
+ RUN npm ci
10
+
11
+ # Build the application
12
+ FROM base AS builder
13
+ WORKDIR /app
14
+ COPY --from=deps /app/node_modules ./node_modules
15
+ COPY . .
16
+
17
+ ENV NEXT_TELEMETRY_DISABLED=1
18
+
19
+ RUN npm run build
20
+
21
+ # Production image
22
+ FROM base AS runner
23
+ WORKDIR /app
24
+
25
+ ENV NODE_ENV=production
26
+ ENV NEXT_TELEMETRY_DISABLED=1
27
+ ENV PORT=7860
28
+ ENV HOSTNAME="0.0.0.0"
29
+
30
+ RUN addgroup --system --gid 1001 nodejs
31
+ RUN adduser --system --uid 1001 nextjs
32
+
33
+ COPY --from=builder /app/public ./public
34
+ COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
35
+ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
36
+
37
+ USER nextjs
38
+
39
+ EXPOSE 7860
40
+
41
+ CMD ["node", "server.js"]
 
 
 
 
 
 
 
 
 
 
README.md CHANGED
@@ -1,345 +1,43 @@
1
- # PowerPoint AI Generator 🎨
2
-
3
- A modern, AI-powered presentation generator built with Next.js that creates professional PowerPoint presentations using various AI models. The application features a Google Slides-like editor interface with real-time editing capabilities.
4
-
5
- ## ✨ Features
6
-
7
- - **AI-Powered Generation**: Create presentations using multiple AI models (Gemini, DeepSeek, GPT, Kimi, Llama)
8
- - **Automatic Image Integration**: Slides automatically include relevant images from Unsplash
9
- - **Image + Text Layouts**: Professional content-image layouts for visual presentations
10
- - **Google Slides-like Editor**: Modern interface with drag-and-drop functionality
11
- - **Rich Text Editing**: Bold, italic, underline formatting options
12
- - **Multi-slide Management**: Add, delete, and organize slides
13
- - **Export to PowerPoint**: Generate .pptx files with styled content
14
- - **Authentication**: HuggingFace Pro integration for premium models
15
- - **Responsive Design**: Works seamlessly across devices
16
- - **Dark Mode Support**: Built-in dark theme
17
- - **Multiple Slide Templates**: Title, bullets, charts, images, quotes, comparisons
18
-
19
- ## 🛠 Tech Stack
20
-
21
- - **Framework**: Next.js 15.5.3 with App Router
22
- - **Language**: TypeScript 5.9.3
23
- - **Styling**: TailwindCSS v4 with custom design tokens
24
- - **UI Components**: Radix UI primitives
25
- - **AI Integration**: Google Generative AI, HuggingFace, OpenAI, Cohere
26
- - **Presentation Export**: pptxgenjs
27
- - **Authentication**: NextAuth with HuggingFace OAuth
28
-
29
- ## 📁 Project Structure
30
-
31
- ```
32
- powerpoint/
33
- ├── app/ # Next.js app directory
34
- │ ├── api/ # API routes
35
- │ │ ├── auth/ # Authentication endpoints
36
- │ │ ├── export-pptx/ # PowerPoint export
37
- │ │ ├── generate-slides/ # AI slide generation
38
- │ │ ├── presentations/ # Main generation orchestrator
39
- │ │ ├── unsplash-download/ # Image downloads
40
- │ │ └── upload-template/ # Template uploads
41
- │ ├── editor/ # Editor page
42
- │ │ └── page.tsx # Editor route component
43
- │ ├── globals.css # Global styles & design tokens
44
- │ ├── layout.tsx # Root layout with fonts
45
- │ └── page.tsx # Landing page with prompt input
46
-
47
- ├── components/ # React components
48
- │ ├── editor/ # Editor components
49
- │ │ ├── GoogleSlidesEditor.tsx # Main editor interface
50
- │ │ ├── PowerPointEditor.tsx # Alternative editor
51
- │ │ ├── Ribbon.tsx # Toolbar ribbon
52
- │ │ └── SlideThumbnailPanel.tsx # Slide thumbnails
53
- │ ├── slides/ # Slide type components
54
- │ │ ├── TitleSlide.tsx # Title slide template
55
- │ │ ├── BulletsSlide.tsx # Bullet points slide
56
- │ │ ├── ChartSlide.tsx # Chart visualization
57
- │ │ └── SlideFactory.tsx # Slide component factory
58
- │ └── ui/ # UI primitives
59
- │ └── select.tsx # Custom select component
60
-
61
- └── lib/ # Utility libraries
62
- └── orchestrator.ts # AI provider orchestration
63
- ```
64
-
65
- ## 🚀 Getting Started
66
-
67
- ### Prerequisites
68
-
69
- - Node.js 18+
70
- - npm or yarn
71
- - API keys for AI providers (optional, Gemini works free)
72
-
73
- ### Installation
74
-
75
- 1. Clone the repository:
76
- ```bash
77
- git clone https://github.com/yourusername/powerpoint.git
78
- cd powerpoint
79
- ```
80
-
81
- 2. Install dependencies:
82
- ```bash
83
- npm install
84
- ```
85
-
86
- 3. Set up environment variables:
87
- Create a `.env.local` file:
88
- ```env
89
- # AI Provider Keys (Gemini is free and works without key)
90
- GOOGLE_GENERATIVE_AI_API_KEY=your_gemini_key
91
-
92
- # Image Integration (optional)
93
- UNSPLASH_ACCESS_KEY=your_unsplash_key
94
-
95
- # Authentication (optional - for premium models)
96
- NEXTAUTH_URL=http://localhost:3000
97
- NEXTAUTH_SECRET=your_secret_key
98
- ```
99
-
100
- **Note**: Without an Unsplash API key, presentations will use text-only layouts. To enable automatic image integration:
101
- 1. Sign up at [Unsplash Developers](https://unsplash.com/developers)
102
- 2. Create a new application
103
- 3. Copy your Access Key to `.env.local`
104
-
105
- 4. Run the development server:
106
- ```bash
107
- npm run dev
108
- ```
109
-
110
- 5. Open [http://localhost:3000](http://localhost:3000) in your browser
111
-
112
- ## 💡 Usage
113
-
114
- 1. **Landing Page** (`/`): Enter your presentation topic/prompt
115
- 2. **Select AI Model**: Choose from available models (Gemini is free)
116
- 3. **Authenticate** (if needed): Login with HuggingFace for Pro models
117
- 4. **Generate**: Click the arrow button to create presentation
118
- - Slides will automatically include relevant images if Unsplash is configured
119
- - Content slides use professional image + text layouts
120
- 5. **Edit**: Modify slides in the Google Slides-like editor
121
- - Drag and resize elements
122
- - Click on images to change them
123
- - Edit text inline
124
- 6. **Export**: Download as PowerPoint file
125
-
126
- ## 🔌 API Endpoints
127
-
128
- ### POST `/api/presentations/generate`
129
- Main endpoint for generating presentations with automatic image integration.
130
- - **Input**: `{ prompt: string, model: string }`
131
- - **Output**: JSON array of slides with titles, content, images, and layouts
132
- - **Features**: Automatically fetches relevant images from Unsplash for each slide
133
-
134
- ### GET `/api/search-images`
135
- Search for images from Unsplash.
136
- - **Input**: `?query=search_term&per_page=1`
137
- - **Output**: Array of image objects with URLs and metadata
138
- - **Note**: Requires UNSPLASH_ACCESS_KEY in environment variables
139
-
140
- ### POST `/api/export-pptx`
141
- Exports slides to PowerPoint format.
142
- - **Input**: Array of slides with title and content
143
- - **Output**: Base64-encoded .pptx file
144
-
145
- ### POST `/api/generate-slides`
146
- Legacy endpoint for HuggingFace-specific generation.
147
- - **Input**: `{ prompt: string, model: string, authMethod: string }`
148
- - **Output**: JSON array of slides
149
-
150
- ## 🔗 File Connections & Data Flow
151
-
152
- ### Data Flow
153
- 1. **User Input** → `app/page.tsx` (landing page)
154
- 2. **Session Storage** → Stores prompt & model selection
155
- 3. **Navigation** → Routes to `/editor`
156
- 4. **Editor Load** → `app/editor/page.tsx` → `GoogleSlidesEditor.tsx`
157
- 5. **AI Generation** → Calls `/api/presentations`
158
- 6. **Orchestrator** → `lib/orchestrator.ts` routes to appropriate provider
159
- 7. **Slide Rendering** → `components/slides/*` render content
160
- 8. **Export** → `/api/export-pptx` creates PowerPoint file
161
-
162
- ### Key Component Connections
163
- - `app/page.tsx` ↔ `app/editor/page.tsx` (via router & sessionStorage)
164
- - `GoogleSlidesEditor.tsx` ↔ `/api/presentations` (AI generation)
165
- - `GoogleSlidesEditor.tsx` ↔ `/api/export-pptx` (file export)
166
- - `components/slides/*` ← `SlideFactory.tsx` (component selection)
167
-
168
- ## 📦 Key Libraries & Packages
169
-
170
- ### AI & ML Integration
171
- - **@google/generative-ai**: Google's Gemini AI integration
172
- - **@huggingface/inference**: HuggingFace model access
173
- - **openai**: OpenAI GPT models
174
- - **cohere-ai**: Cohere language models
175
-
176
- ### UI & Styling
177
- - **@radix-ui/react-***: Headless UI components (dialog, dropdown, popover, select)
178
- - **tailwindcss**: Utility-first CSS framework
179
- - **lucide-react**: Modern icon library
180
- - **@lobehub/icons**: AI model brand icons
181
- - **react-icons**: General icon set
182
- - **class-variance-authority**: Component variants
183
- - **clsx & tailwind-merge**: Class name utilities
184
-
185
- ### Presentation & Editor
186
- - **pptxgenjs**: PowerPoint file generation
187
- - **react-draggable**: Drag-and-drop functionality for slide elements
188
- - **swiper**: Slide carousel functionality
189
-
190
- ### Visualization
191
- - **chart.js & react-chartjs-2**: Chart creation and React wrapper
192
- - **html2canvas**: HTML to image conversion
193
- - **jspdf**: PDF generation capabilities
194
-
195
- ### Authentication
196
- - **@auth/core**: Authentication core
197
- - **next-auth**: NextAuth integration
198
 
199
- ### Utilities
200
- - **axios**: HTTP client for API calls
201
- - **unsplash-js**: Unsplash image integration
202
 
203
- ## 🎨 Design System
204
 
205
- ### Font Stack
206
- Multiple Google Fonts for varied typography:
207
- - **Geist & Geist Mono**: Primary UI fonts
208
- - **Sora**: Modern display font
209
- - **Inter**: Highly readable body text
210
- - **Roboto**: Classic, versatile font
211
- - **Poppins**: Friendly, rounded font
212
- - **Montserrat**: Geometric sans-serif
213
- - **Playfair Display & Merriweather**: Elegant serif fonts
214
 
215
- ### Color System
216
- - **Light Mode**: Clean whites and subtle grays
217
- - **Dark Mode**: Deep blacks with emerald accents (#34d399)
218
- - **Brand Colors**: Blue-600 (#2563eb) / Blue-400 (#60a5fa)
 
 
 
219
 
220
- ## Example Prompts
221
 
222
- - "Create a 5-slide presentation about renewable energy sources including solar, wind, and hydroelectric power"
223
- - "Make a presentation about machine learning fundamentals for beginners"
224
- - "Generate slides about effective remote work strategies and best practices"
225
- - "Create a business presentation about digital marketing trends in 2024"
 
226
 
227
  ## Environment Variables
228
 
229
- ```env
230
- # Hugging Face OAuth (optional)
231
- HUGGINGFACE_CLIENT_ID=your_client_id
232
- HUGGINGFACE_CLIENT_SECRET=your_client_secret
233
- NEXT_PUBLIC_HUGGINGFACE_CLIENT_ID=your_client_id
234
- ```
235
-
236
- ## Development
237
-
238
- ### Project Structure
239
-
240
- ```
241
- ├── app/
242
- │ ├── api/
243
- │ │ ├── generate-slides/ # Slide generation API
244
- │ │ ├── export-pptx/ # PowerPoint export API
245
- │ │ └── auth/ # Authentication handlers
246
- │ ├── layout.tsx # Root layout
247
- │ └── page.tsx # Home page
248
- ├── components/
249
- │ ├── AuthProvider.tsx # Authentication component
250
- │ ├── PresentationGenerator.tsx # Main generator component
251
- │ ├── ModelSelector.tsx # Model selection component
252
- │ ├── SlideEditor.tsx # Slide editing interface
253
- │ └── SlidePreview.tsx # Presentation preview
254
- └── public/ # Static assets
255
- ```
256
-
257
- ### Running Tests
258
-
259
- ```bash
260
- npm run build
261
- npm run lint
262
- ```
263
-
264
- ## Troubleshooting
265
-
266
- ### Common Issues
267
-
268
- 1. **API Authentication Errors**: Ensure your Hugging Face API token is valid and has the necessary permissions
269
-
270
- 2. **Model Not Found**: Verify the model ID exists on Hugging Face and supports text generation
271
-
272
- 3. **Export Failures**: Check that all slides have valid content before exporting
273
-
274
- 4. **Generation Timeouts**: Some models may take longer to respond; try a different model if timeouts occur
275
-
276
- ## Credits
277
-
278
- Built with:
279
- - [Next.js](https://nextjs.org/) - React framework
280
- - [Hugging Face Inference](https://huggingface.co/docs/huggingface.js/inference/README) - AI model integration
281
- - [pptxgenjs](https://gitbrent.github.io/PptxGenJS/) - PowerPoint generation
282
- - [Tailwind CSS](https://tailwindcss.com/) - Styling
283
- - [Lucide React](https://lucide.dev/) - Icons
284
-
285
- ## 🚦 Development Scripts
286
-
287
- ```bash
288
- npm run dev # Start development server with Turbopack
289
- npm run build # Build for production with Turbopack
290
- npm run start # Start production server
291
- npm run lint # Run ESLint
292
- ```
293
-
294
- ## 🔧 Complex Code Logic Explained
295
-
296
- ### 1. **Drag-and-Drop System** (`GoogleSlidesEditor.tsx`)
297
- The editor uses `react-draggable` to allow element positioning. Each element maintains its position state relative to the slide container, with boundary checking to prevent elements from moving outside the slide area.
298
-
299
- ### 2. **AI Provider Orchestration** (`lib/orchestrator.ts`)
300
- The orchestrator intelligently routes requests to different AI providers based on the selected model name. It uses pattern matching to determine whether to use Gemini, HuggingFace, or other providers.
301
-
302
- ### 3. **Session Storage Communication**
303
- The landing page (`app/page.tsx`) stores the prompt and model selection in sessionStorage, which the editor page retrieves on load. This allows seamless data transfer without URL parameters.
304
-
305
- ### 4. **Slide Element Management**
306
- Each slide maintains an array of elements (text, images) with unique IDs. The editor tracks selected elements and applies transformations (position, size, rotation) through state updates.
307
-
308
- ### 5. **PowerPoint Generation**
309
- The `pptxgenjs` library creates actual .pptx files by converting the slide data structure into PowerPoint-compatible format with styling, backgrounds, and animations.
310
-
311
- ## 🎯 Key Features Explained
312
-
313
- ### Gradient Animations (Landing Page)
314
- The landing page uses CSS keyframe animations with multiple gradient layers to create a dynamic, modern appearance. The animations are GPU-accelerated for smooth performance.
315
-
316
- ### Model Selection Logic
317
- The application automatically determines authentication requirements based on the selected model. Free models like Gemini work without authentication, while premium models require HuggingFace Pro login.
318
-
319
- ### Responsive Slide Editor
320
- The editor maintains a 16:9 aspect ratio for slides while scaling to fit different screen sizes. It uses CSS transforms for zooming without affecting the actual element dimensions.
321
-
322
- ## 🤝 Contributing
323
-
324
- 1. Fork the repository
325
- 2. Create a feature branch (`git checkout -b feature/AmazingFeature`)
326
- 3. Commit changes with clear messages
327
- 4. Push to branch (`git push origin feature/AmazingFeature`)
328
- 5. Open a Pull Request
329
-
330
- ## 📄 License
331
-
332
- This project is proprietary software. All rights reserved.
333
-
334
- ## 🙏 Acknowledgments
335
-
336
- - Next.js team for the amazing framework
337
- - Vercel for hosting and deployment
338
- - Google, HuggingFace, OpenAI for AI APIs
339
- - Open source community for the libraries
340
-
341
- ---
342
 
343
- Built with ❤️ using Next.js and AI
344
- # PPT_AI
345
-
 
 
 
 
 
1
+ ---
2
+ title: Powerpoint AI
3
+ emoji: 🎨
4
+ colorFrom: green
5
+ colorTo: yellow
6
+ sdk: docker
7
+ app_port: 7860
8
+ pinned: false
9
+ ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
+ # PowerPoint AI Generator
 
 
12
 
13
+ AI-powered presentation generator with a Google Slides-like editor. Create professional presentations using Qwen3.5-9B via HuggingFace Inference, with automatic Unsplash image integration and Neo-Brutalism template support.
14
 
15
+ ## Features
 
 
 
 
 
 
 
 
16
 
17
+ - **AI Slide Generation** using Qwen3.5-9B (Together AI provider)
18
+ - **Template System** with Neo-Brutalism theme (dot grids, thick borders, hard shadows, bright colors)
19
+ - **Unsplash Integration** for automatic slide images
20
+ - **Google Slides-like Editor** with drag-and-drop, inline text editing
21
+ - **Multiple Slide Types**: Title, Bullets, Content-Image, Quote, Comparison, Chart, Stats, Section
22
+ - **Export to PowerPoint** (.pptx)
23
+ - **HuggingFace OAuth** login
24
 
25
+ ## Tech Stack
26
 
27
+ - Next.js 15 (App Router, Standalone output)
28
+ - TypeScript, TailwindCSS v4
29
+ - HuggingFace Inference Client
30
+ - pptxgenjs for export
31
+ - Radix UI primitives
32
 
33
  ## Environment Variables
34
 
35
+ Set these as **Secrets** in your HuggingFace Space settings:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
+ | Variable | Required | Description |
38
+ |---|---|---|
39
+ | `UNSPLASH_ACCESS_KEY` | Optional | Unsplash API key for slide images |
40
+ | `HF_TOKEN` | Optional | HuggingFace API token (fallback if OAuth not used) |
41
+ | `HUGGINGFACE_CLIENT_ID` | Optional | HF OAuth client ID |
42
+ | `HUGGINGFACE_CLIENT_SECRET` | Optional | HF OAuth client secret |
43
+ | `NEXT_PUBLIC_HUGGINGFACE_CLIENT_ID` | Optional | Public HF OAuth client ID |