diff --git a/MCP-SERVER.md b/MCP-SERVER.md
deleted file mode 100644
index 675acdbb77beeb3bdc3e0b7b49a2e01d39df1b58..0000000000000000000000000000000000000000
--- a/MCP-SERVER.md
+++ /dev/null
@@ -1,428 +0,0 @@
-# DeepSite MCP Server
-
-DeepSite is now available as an MCP (Model Context Protocol) server, enabling AI assistants like Claude to create websites directly using natural language.
-
-## Two Ways to Use DeepSite MCP
-
-**Quick Comparison:**
-
-| Feature | Option 1: HTTP Server | Option 2: Local Server |
-|---------|----------------------|------------------------|
-| **Setup Difficulty** | β
Easy (just config) | β οΈ Requires installation |
-| **Authentication** | HF Token in config header | HF Token or session cookie in env |
-| **Best For** | Most users | Developers, custom modifications |
-| **Maintenance** | β
Always up-to-date | Need to rebuild for updates |
-
-**Recommendation:** Use Option 1 (HTTP Server) unless you need to modify the MCP server code.
-
----
-
-### π Option 1: HTTP Server (Recommended)
-
-**No installation required!** Use DeepSite's hosted MCP server.
-
-#### Setup for Claude Desktop
-
-Add to your Claude Desktop configuration file:
-
-**MacOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
-**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
-
-```json
-{
- "mcpServers": {
- "deepsite": {
- "url": "https://huggingface.co/deepsite/api/mcp",
- "transport": {
- "type": "sse"
- },
- "headers": {
- "Authorization": "Bearer hf_your_token_here"
- }
- }
- }
-}
-```
-
-**Getting Your Hugging Face Token:**
-
-1. Go to https://huggingface.co/settings/tokens
-2. Create a new token with `write` access
-3. Copy the token
-4. Add it to the `Authorization` header in your config (recommended for security)
-5. Alternatively, you can pass it as the `hf_token` parameter when using the tool
-
-**β οΈ Security Recommendation:** Use the `Authorization` header in your config instead of passing the token in chat. This keeps your token secure and out of conversation history.
-
-#### Example Usage with Claude
-
-> "Create a portfolio website using DeepSite. Include a hero section, about section, and contact form."
-
-Claude will automatically:
-1. Use the `create_project` tool
-2. Authenticate using the token from your config
-3. Create the website on Hugging Face Spaces
-4. Return the URLs to access your new site
-
----
-
-### π» Option 2: Local Server
-
-Run the MCP server locally for more control or offline use.
-
-> **Note:** Most users should use Option 1 (HTTP Server) instead. Option 2 is only needed if you want to run the MCP server locally or modify its behavior.
-
-#### Installation
-
-```bash
-cd mcp-server
-npm install
-npm run build
-```
-
-#### Setup for Claude Desktop
-
-**Method A: Using HF Token (Recommended)**
-
-```json
-{
- "mcpServers": {
- "deepsite-local": {
- "command": "node",
- "args": ["/absolute/path/to/deepsite-v3/mcp-server/dist/index.js"],
- "env": {
- "HF_TOKEN": "hf_your_token_here",
- "DEEPSITE_API_URL": "https://huggingface.co/deepsite"
- }
- }
- }
-}
-```
-
-**Method B: Using Session Cookie (Alternative)**
-
-```json
-{
- "mcpServers": {
- "deepsite-local": {
- "command": "node",
- "args": ["/absolute/path/to/deepsite-v3/mcp-server/dist/index.js"],
- "env": {
- "DEEPSITE_AUTH_COOKIE": "your-session-cookie",
- "DEEPSITE_API_URL": "https://huggingface.co/deepsite"
- }
- }
- }
-}
-```
-
-**Getting Your Session Cookie (Method B only):**
-
-1. Log in to https://huggingface.co/deepsite
-2. Open Developer Tools (F12)
-3. Go to Application β Cookies
-4. Copy the session cookie value
-5. Set as `DEEPSITE_AUTH_COOKIE` in the config
-
----
-
-## Available Tools
-
-### `create_project`
-
-Creates a new DeepSite project with HTML/CSS/JS files.
-
-**Parameters:**
-
-| Parameter | Type | Required | Description |
-|-----------|------|----------|-------------|
-| `title` | string | No | Project title (defaults to "DeepSite Project") |
-| `pages` | array | Yes | Array of file objects with `path` and `html` |
-| `prompt` | string | No | Commit message/description |
-| `hf_token` | string | No* | Hugging Face API token (*optional if provided via Authorization header in config) |
-
-**Page Object:**
-```typescript
-{
- path: string; // e.g., "index.html", "styles.css", "script.js"
- html: string; // File content
-}
-```
-
-**Returns:**
-```json
-{
- "success": true,
- "message": "Project created successfully!",
- "projectUrl": "https://huggingface.co/deepsite/username/project-name",
- "spaceUrl": "https://huggingface.co/spaces/username/project-name",
- "liveUrl": "https://username-project-name.hf.space",
- "spaceId": "username/project-name",
- "projectId": "space-id",
- "files": ["index.html", "styles.css"]
-}
-```
-
----
-
-## Example Prompts for Claude
-
-### Simple Landing Page
-> "Create a modern landing page for my SaaS product using DeepSite. Include a hero section with CTA, features grid, and footer. Use gradient background."
-
-### Portfolio Website
-> "Build a portfolio website with DeepSite. I need:
-> - Hero section with my name and photo
-> - Projects gallery with 3 sample projects
-> - Skills section with tech stack
-> - Contact form
-> Use dark mode with accent colors."
-
-### Blog Homepage
-> "Create a blog homepage using DeepSite. Include:
-> - Header with navigation
-> - Featured post section
-> - Grid of recent posts (3 cards)
-> - Sidebar with categories
-> - Footer with social links
-> Clean, minimal design."
-
-### Interactive Dashboard
-> "Make an analytics dashboard with DeepSite:
-> - Sidebar navigation
-> - 4 metric cards at top
-> - 2 chart placeholders
-> - Data table
-> - Modern, professional UI with charts.css"
-
----
-
-## Direct API Usage
-
-You can also call the HTTP endpoint directly:
-
-### Using Authorization Header (Recommended)
-
-```bash
-curl -X POST https://huggingface.co/deepsite/api/mcp \
- -H "Content-Type: application/json" \
- -H "Authorization: Bearer hf_your_token_here" \
- -d '{
- "jsonrpc": "2.0",
- "id": 1,
- "method": "tools/call",
- "params": {
- "name": "create_project",
- "arguments": {
- "title": "My Website",
- "pages": [
- {
- "path": "index.html",
- "html": "
HelloHello World!
"
- }
- ]
- }
- }
- }'
-```
-
-### Using Token Parameter (Fallback)
-
-```bash
-curl -X POST https://huggingface.co/deepsite/api/mcp \
- -H "Content-Type: application/json" \
- -d '{
- "jsonrpc": "2.0",
- "id": 1,
- "method": "tools/call",
- "params": {
- "name": "create_project",
- "arguments": {
- "title": "My Website",
- "pages": [
- {
- "path": "index.html",
- "html": "HelloHello World!
"
- }
- ],
- "hf_token": "hf_xxxxx"
- }
- }
- }'
-```
-
-### List Available Tools
-
-```bash
-curl -X POST https://huggingface.co/deepsite/api/mcp \
- -H "Content-Type: application/json" \
- -d '{
- "jsonrpc": "2.0",
- "id": 1,
- "method": "tools/list",
- "params": {}
- }'
-```
-
----
-
-## Testing
-
-### Test Local Server
-
-```bash
-cd mcp-server
-./test.sh
-```
-
-### Test HTTP Server
-
-```bash
-curl -X POST https://huggingface.co/deepsite/api/mcp \
- -H "Content-Type: application/json" \
- -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'
-```
-
----
-
-## Migration Guide: From Parameter to Header Auth
-
-If you're currently passing the token as a parameter in your prompts, here's how to migrate to the more secure header-based authentication:
-
-### Step 1: Update Your Config
-
-Edit your Claude Desktop config file and add the `headers` section:
-
-```json
-{
- "mcpServers": {
- "deepsite": {
- "url": "https://huggingface.co/deepsite/api/mcp",
- "transport": {
- "type": "sse"
- },
- "headers": {
- "Authorization": "Bearer hf_your_actual_token_here"
- }
- }
- }
-}
-```
-
-### Step 2: Restart Claude Desktop
-
-Completely quit and restart Claude Desktop for the changes to take effect.
-
-### Step 3: Use Simpler Prompts
-
-Now you can simply say:
-> "Create a portfolio website with DeepSite"
-
-Instead of:
-> "Create a portfolio website with DeepSite using token `hf_xxxxx`"
-
-Your token is automatically included in all requests via the header!
-
----
-
-## Security Notes
-
-### HTTP Server (Option 1)
-- **β
Recommended:** Store your HF token in the `Authorization` header in your Claude Desktop config
-- The token is stored locally on your machine and never exposed in chat
-- The token is sent with each request but only used to authenticate with Hugging Face API
-- DeepSite does not store your token
-- Use tokens with minimal required permissions (write access to spaces)
-- You can revoke tokens anytime at https://huggingface.co/settings/tokens
-- **β οΈ Fallback:** You can still pass the token as a parameter, but this is less secure as it appears in conversation history
-
-### Local Server (Option 2)
-- Use `HF_TOKEN` environment variable (same security as Option 1)
-- Or use `DEEPSITE_AUTH_COOKIE` if you prefer session-based auth
-- All authentication data stays on your local machine
-- Better for development and testing
-- No need for both HTTP Server and Local Server - choose one!
-
----
-
-## Troubleshooting
-
-### "Invalid Hugging Face token"
-- Verify your token at https://huggingface.co/settings/tokens
-- Ensure the token has write permissions
-- Check that you copied the full token (starts with `hf_`)
-
-### "At least one page is required"
-- Make sure you're providing the `pages` array
-- Each page must have both `path` and `html` properties
-
-### "Failed to create project"
-- Check your token permissions
-- Ensure the project title doesn't conflict with existing spaces
-- Verify your Hugging Face account is in good standing
-
-### Claude doesn't see the tool
-- Restart Claude Desktop after modifying the config
-- Check that the JSON config is valid (no trailing commas)
-- For HTTP: verify the URL is correct
-- For local: check the absolute path to index.js
-
----
-
-## Architecture
-
-### HTTP Server Flow
-```
-Claude Desktop
- β
- (HTTP Request)
- β
-huggingface.co/deepsite/api/mcp
- β
-Hugging Face API (with user's token)
- β
-New Space Created
- β
-URLs returned to Claude
-```
-
-### Local Server Flow
-```
-Claude Desktop
- β
- (stdio transport)
- β
-Local MCP Server
- β
- (HTTP to DeepSite API)
- β
-huggingface.co/deepsite/api/me/projects
- β
-New Space Created
-```
-
----
-
-## Contributing
-
-The MCP server implementation lives in:
-- HTTP Server: `/app/api/mcp/route.ts`
-- Local Server: `/mcp-server/index.ts`
-
-Both use the same core DeepSite logic for creating projects - no duplication!
-
----
-
-## License
-
-MIT
-
----
-
-## Resources
-
-- [Model Context Protocol Spec](https://modelcontextprotocol.io/)
-- [DeepSite Documentation](https://huggingface.co/deepsite)
-- [Hugging Face Spaces](https://huggingface.co/docs/hub/spaces)
-- [Claude Desktop](https://claude.ai/desktop)
-
diff --git a/README.md b/README.md
index 9154f9026a5ccedb6d9aa26c2b34462372d7741b..5ab2231fc7dc96070548f1d03ab1d0f73a799600 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
---
-title: DeepSite v3
+title: DeepSite v2
emoji: π³
colorFrom: blue
colorTo: blue
@@ -7,22 +7,16 @@ sdk: docker
pinned: true
app_port: 3000
license: mit
-failure_strategy: rollback
-short_description: Generate any application by Vibe Coding
+short_description: Generate any application with DeepSeek
models:
- deepseek-ai/DeepSeek-V3-0324
- deepseek-ai/DeepSeek-R1-0528
- - deepseek-ai/DeepSeek-V3.1
- - deepseek-ai/DeepSeek-V3.1-Terminus
- - deepseek-ai/DeepSeek-V3.2-Exp
- - Qwen/Qwen3-Coder-480B-A35B-Instruct
- - moonshotai/Kimi-K2-Instruct
- - moonshotai/Kimi-K2-Instruct-0905
- - zai-org/GLM-4.6
- - MiniMaxAI/MiniMax-M2
- - moonshotai/Kimi-K2-Thinking
---
# DeepSite π³
-DeepSite is a Vibe Coding Platform designed to make coding smarter and more efficient. Tailored for developers, data scientists, and AI engineers, it integrates generative AI into your coding projects to enhance creativity and productivity.
+DeepSite is a coding platform powered by DeepSeek AI, designed to make coding smarter and more efficient. Tailored for developers, data scientists, and AI engineers, it integrates generative AI into your coding projects to enhance creativity and productivity.
+
+## How to use it locally
+
+Follow [this discussion](https://huggingface.co/spaces/enzostvs/deepsite/discussions/74)
diff --git a/app/(public)/layout.tsx b/app/(public)/layout.tsx
index 4c640fb83ccfced8842764d029c87a2d85718d65..4a4ec57d2609c783602beb6c06c8dca6a1e6192d 100644
--- a/app/(public)/layout.tsx
+++ b/app/(public)/layout.tsx
@@ -6,7 +6,7 @@ export default async function PublicLayout({
children: React.ReactNode;
}>) {
return (
-
+
{children}
diff --git a/app/(public)/page.tsx b/app/(public)/page.tsx
index e2d5c88a4977801d6acabd904535b00ad622a267..c0849e72cf29027524ec9ebc3818e80a8aee5ef3 100644
--- a/app/(public)/page.tsx
+++ b/app/(public)/page.tsx
@@ -1,5 +1,44 @@
-import { MyProjects } from "@/components/my-projects";
-
-export default async function HomePage() {
- return
;
+import { AskAi } from "@/components/space/ask-ai";
+import { redirect } from "next/navigation";
+export default function Home() {
+ redirect("/projects/new");
+ return (
+ <>
+
+
+
+
+ Deploy your website in seconds
+
+
+
+
+ Features that make you smile
+
+
+ >
+ );
}
diff --git a/app/(public)/projects/page.tsx b/app/(public)/projects/page.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..374dc6b1194256c5b142a62168ce0f414f6098be
--- /dev/null
+++ b/app/(public)/projects/page.tsx
@@ -0,0 +1,13 @@
+import { redirect } from "next/navigation";
+
+import { MyProjects } from "@/components/my-projects";
+import { getProjects } from "@/app/actions/projects";
+
+export default async function ProjectsPage() {
+ const { ok, projects } = await getProjects();
+ if (!ok) {
+ redirect("/");
+ }
+
+ return
;
+}
diff --git a/app/[namespace]/[repoId]/page.tsx b/app/[namespace]/[repoId]/page.tsx
deleted file mode 100644
index 19a09d72477dd437fa8a786601cbc584676609ee..0000000000000000000000000000000000000000
--- a/app/[namespace]/[repoId]/page.tsx
+++ /dev/null
@@ -1,28 +0,0 @@
-import { AppEditor } from "@/components/editor";
-import { generateSEO } from "@/lib/seo";
-import { Metadata } from "next";
-
-export async function generateMetadata({
- params,
-}: {
- params: Promise<{ namespace: string; repoId: string }>;
-}): Promise
{
- const { namespace, repoId } = await params;
-
- return generateSEO({
- title: `${namespace}/${repoId} - DeepSite Editor`,
- description: `Edit and build ${namespace}/${repoId} with AI-powered tools on DeepSite. Create stunning websites with no code required.`,
- path: `/${namespace}/${repoId}`,
- // Prevent indexing of individual project editor pages if they contain sensitive content
- noIndex: false, // Set to true if you want to keep project pages private
- });
-}
-
-export default async function ProjectNamespacePage({
- params,
-}: {
- params: Promise<{ namespace: string; repoId: string }>;
-}) {
- const { namespace, repoId } = await params;
- return ;
-}
diff --git a/app/actions/auth.ts b/app/actions/auth.ts
index b0028105705dde5ace29f4484398edbd0e9c9dc0..a343e65e6726b35b32f022c117d3f3b5187d78e6 100644
--- a/app/actions/auth.ts
+++ b/app/actions/auth.ts
@@ -11,7 +11,7 @@ export async function getAuth() {
const redirect_uri =
`${host.includes("localhost") ? "http://" : "https://"}` +
url +
- "/deepsite/auth/callback";
+ "/auth/callback";
const loginRedirectUrl = `https://huggingface.co/oauth/authorize?client_id=${process.env.OAUTH_CLIENT_ID}&redirect_uri=${redirect_uri}&response_type=code&scope=openid%20profile%20write-repos%20manage-repos%20inference-api&prompt=consent&state=1234567890`;
return loginRedirectUrl;
diff --git a/app/actions/projects.ts b/app/actions/projects.ts
index 5f99d85273352e21e22efb85b03bced1cf210897..209b16d9d9960eeafb9e0b02d7b1b3eda638338d 100644
--- a/app/actions/projects.ts
+++ b/app/actions/projects.ts
@@ -2,13 +2,13 @@
import { isAuthenticated } from "@/lib/auth";
import { NextResponse } from "next/server";
-import { listSpaces } from "@huggingface/hub";
-import { ProjectType } from "@/types";
+import dbConnect from "@/lib/mongodb";
+import Project from "@/models/Project";
+import { Project as ProjectType } from "@/types";
export async function getProjects(): Promise<{
ok: boolean;
projects: ProjectType[];
- isEmpty?: boolean;
}> {
const user = await isAuthenticated();
@@ -19,29 +19,45 @@ export async function getProjects(): Promise<{
};
}
- const projects = [];
- for await (const space of listSpaces({
- accessToken: user.token as string,
- additionalFields: ["author", "cardData"],
- search: {
- owner: user.name,
- }
- })) {
- if (
- !space.private &&
- space.sdk === "static" &&
- Array.isArray((space.cardData as { tags?: string[] })?.tags) &&
- (
- ((space.cardData as { tags?: string[] })?.tags?.includes("deepsite-v3")) ||
- ((space.cardData as { tags?: string[] })?.tags?.includes("deepsite"))
- )
- ) {
- projects.push(space);
- }
+ await dbConnect();
+ const projects = await Project.find({
+ user_id: user?.id,
+ })
+ .sort({ _createdAt: -1 })
+ .limit(100)
+ .lean();
+ if (!projects) {
+ return {
+ ok: false,
+ projects: [],
+ };
}
-
return {
ok: true,
- projects,
+ projects: JSON.parse(JSON.stringify(projects)) as ProjectType[],
};
}
+
+export async function getProject(
+ namespace: string,
+ repoId: string
+): Promise {
+ const user = await isAuthenticated();
+
+ if (user instanceof NextResponse || !user) {
+ return null;
+ }
+
+ await dbConnect();
+ const project = await Project.findOne({
+ user_id: user.id,
+ namespace,
+ repoId,
+ }).lean();
+
+ if (!project) {
+ return null;
+ }
+
+ return JSON.parse(JSON.stringify(project)) as ProjectType;
+}
diff --git a/app/api/ask-ai/route.ts b/app/api/ask-ai/route.ts
new file mode 100644
index 0000000000000000000000000000000000000000..bbe6cbeed1dbbc625bdb7cc4bd033912e717d4b5
--- /dev/null
+++ b/app/api/ask-ai/route.ts
@@ -0,0 +1,440 @@
+/* eslint-disable @typescript-eslint/no-explicit-any */
+import type { NextRequest } from "next/server";
+import { NextResponse } from "next/server";
+import { headers } from "next/headers";
+import { InferenceClient } from "@huggingface/inference";
+
+import { MODELS, PROVIDERS } from "@/lib/providers";
+import {
+ DIVIDER,
+ FOLLOW_UP_SYSTEM_PROMPT,
+ INITIAL_SYSTEM_PROMPT,
+ MAX_REQUESTS_PER_IP,
+ REPLACE_END,
+ SEARCH_START,
+} from "@/lib/prompts";
+import MY_TOKEN_KEY from "@/lib/get-cookie-name";
+import { createErrorFixPrompt } from "@/lib/error-formatter";
+
+const ipAddresses = new Map();
+
+export async function POST(request: NextRequest) {
+ const authHeaders = await headers();
+ const userToken = request.cookies.get(MY_TOKEN_KEY())?.value;
+
+ const body = await request.json();
+ const { prompt, provider, model, redesignMarkdown, html } = body;
+
+ if (!model || (!prompt && !redesignMarkdown)) {
+ return NextResponse.json(
+ { ok: false, error: "Missing required fields" },
+ { status: 400 }
+ );
+ }
+
+ const selectedModel = MODELS.find(
+ (m) => m.value === model || m.label === model
+ );
+ if (!selectedModel) {
+ return NextResponse.json(
+ { ok: false, error: "Invalid model selected" },
+ { status: 400 }
+ );
+ }
+
+ if (!selectedModel.providers.includes(provider) && provider !== "auto") {
+ return NextResponse.json(
+ {
+ ok: false,
+ error: `The selected model does not support the ${provider} provider.`,
+ openSelectProvider: true,
+ },
+ { status: 400 }
+ );
+ }
+
+ let token = userToken;
+ let billTo: string | null = null;
+
+ /**
+ * Handle local usage token, this bypass the need for a user token
+ * and allows local testing without authentication.
+ * This is useful for development and testing purposes.
+ */
+ if (process.env.HF_TOKEN && process.env.HF_TOKEN.length > 0) {
+ token = process.env.HF_TOKEN;
+ }
+
+ const ip = authHeaders.get("x-forwarded-for")?.includes(",")
+ ? authHeaders.get("x-forwarded-for")?.split(",")[1].trim()
+ : authHeaders.get("x-forwarded-for");
+
+ if (!token) {
+ ipAddresses.set(ip, (ipAddresses.get(ip) || 0) + 1);
+ if (ipAddresses.get(ip) > MAX_REQUESTS_PER_IP) {
+ return NextResponse.json(
+ {
+ ok: false,
+ openLogin: true,
+ message: "Log In to continue using the service",
+ },
+ { status: 429 }
+ );
+ }
+
+ token = process.env.DEFAULT_HF_TOKEN as string;
+ billTo = "huggingface";
+ }
+
+ const DEFAULT_PROVIDER = PROVIDERS.novita;
+ const selectedProvider =
+ provider === "auto"
+ ? PROVIDERS[selectedModel.autoProvider as keyof typeof PROVIDERS]
+ : PROVIDERS[provider as keyof typeof PROVIDERS] ?? DEFAULT_PROVIDER;
+
+ try {
+ // Create a stream response
+ const encoder = new TextEncoder();
+ const stream = new TransformStream();
+ const writer = stream.writable.getWriter();
+
+ // Start the response
+ const response = new NextResponse(stream.readable, {
+ headers: {
+ "Content-Type": "text/plain; charset=utf-8",
+ "Cache-Control": "no-cache",
+ Connection: "keep-alive",
+ },
+ });
+
+ (async () => {
+ let completeResponse = "";
+ try {
+ const client = new InferenceClient(token);
+ const chatCompletion = client.chatCompletionStream(
+ {
+ model: selectedModel.value,
+ provider: selectedProvider.id as any,
+ messages: [
+ {
+ role: "system",
+ content: INITIAL_SYSTEM_PROMPT,
+ },
+ {
+ role: "user",
+ content: redesignMarkdown
+ ? `Here is my current design as a markdown:\n\n${redesignMarkdown}\n\nNow, please create a new design based on this markdown.`
+ : html
+ ? `Here is my current HTML code:\n\n\`\`\`html\n${html}\n\`\`\`\n\nNow, please create a new design based on this HTML.`
+ : prompt,
+ },
+ ],
+ max_tokens: selectedProvider.max_tokens,
+ },
+ billTo ? { billTo } : {}
+ );
+
+ while (true) {
+ const { done, value } = await chatCompletion.next();
+ if (done) {
+ break;
+ }
+
+ const chunk = value.choices[0]?.delta?.content;
+ if (chunk) {
+ let newChunk = chunk;
+ if (!selectedModel?.isThinker) {
+ if (provider !== "sambanova") {
+ await writer.write(encoder.encode(chunk));
+ completeResponse += chunk;
+
+ if (completeResponse.includes("