2begyb commited on
Commit
81e976b
·
verified ·
1 Parent(s): b4c6359

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. client/src/pages/Home.tsx +104 -127
  2. server/_core/context.ts +10 -0
  3. server/db.ts +17 -0
client/src/pages/Home.tsx CHANGED
@@ -8,143 +8,120 @@ import { ArrowRight, Zap, Code2, Brain, Cpu, Shield, TrendingUp } from "lucide-r
8
  export default function Home() {
9
  const { user, isAuthenticated } = useAuth();
10
 
11
- if (isAuthenticated) {
12
- return (
13
- <div className="min-h-screen bg-black text-white">
14
- {/* Navigation */}
15
- <nav className="border-b border-green-500/20 bg-black/50 backdrop-blur-sm sticky top-0 z-40">
16
- <div className="container mx-auto px-4 py-4 flex justify-between items-center">
17
- <div className="flex items-center gap-3">
18
- <div className="w-10 h-10 rounded-lg bg-gradient-to-br from-green-400 to-cyan-400 flex items-center justify-center">
19
- <Zap className="text-black" size={20} />
20
- </div>
21
- <h1 className="text-xl font-bold bg-gradient-to-r from-green-400 via-cyan-400 to-blue-500 bg-clip-text text-transparent">
22
- Hacking Factory
23
- </h1>
24
- </div>
25
- <div className="flex gap-4">
26
- <Link href="/dashboard">
27
- <Button variant="ghost" className="text-green-400 hover:text-green-300">
28
- Dashboard
29
- </Button>
30
- </Link>
31
- <Link href="/chat">
32
- <Button variant="ghost" className="text-cyan-400 hover:text-cyan-300">
33
- AI Chat
34
- </Button>
35
- </Link>
36
  </div>
 
 
 
37
  </div>
38
- </nav>
39
-
40
- {/* Hero Section */}
41
- <section className="container mx-auto px-4 py-20">
42
- <div className="max-w-3xl mx-auto text-center mb-20">
43
- <h2 className="text-5xl md:text-6xl font-bold mb-6 bg-gradient-to-r from-green-400 via-cyan-400 to-blue-500 bg-clip-text text-transparent">
44
- AI-Powered Code Generation & Evaluation
45
- </h2>
46
- <p className="text-xl text-gray-400 mb-8">
47
- Generate, evaluate, and optimize code with advanced AI models. Support for multiple modes and content types.
48
- </p>
49
  <Link href="/dashboard">
50
- <Button className="bg-gradient-to-r from-green-500 to-cyan-500 text-black hover:from-green-600 hover:to-cyan-600 text-lg px-8 py-6">
51
- Get Started <ArrowRight className="ml-2" size={20} />
52
  </Button>
53
  </Link>
54
- </div>
55
-
56
- {/* Features Grid */}
57
- <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 mb-20">
58
- {[
59
- {
60
- icon: Code2,
61
- title: "Code Generation",
62
- description: "Generate production-ready code with Qwen AI",
63
- color: "from-green-400 to-emerald-500",
64
- },
65
- {
66
- icon: Brain,
67
- title: "AI Evaluation",
68
- description: "Evaluate code quality with DeepSeek analysis",
69
- color: "from-cyan-400 to-blue-500",
70
- },
71
- {
72
- icon: Cpu,
73
- title: "Iterative Loop",
74
- description: "Continuous improvement through AI feedback loops",
75
- color: "from-purple-400 to-pink-500",
76
- },
77
- {
78
- icon: Shield,
79
- title: "Security Focus",
80
- description: "Analyze code for security vulnerabilities",
81
- color: "from-orange-400 to-red-500",
82
- },
83
- {
84
- icon: TrendingUp,
85
- title: "Performance Metrics",
86
- description: "Track and optimize code performance",
87
- color: "from-yellow-400 to-orange-500",
88
- },
89
- {
90
- icon: Zap,
91
- title: "Real-time Processing",
92
- description: "Instant code generation and evaluation",
93
- color: "from-pink-400 to-rose-500",
94
- },
95
- ].map((feature, idx) => {
96
- const Icon = feature.icon;
97
- return (
98
- <Card key={idx} className="bg-gray-900/50 border-green-500/20 hover:border-green-500/50 transition-all">
99
- <CardHeader>
100
- <div className={`w-12 h-12 rounded-lg bg-gradient-to-br ${feature.color} p-2 mb-4`}>
101
- <Icon className="text-black" size={24} />
102
- </div>
103
- <CardTitle className="text-green-400">{feature.title}</CardTitle>
104
- </CardHeader>
105
- <CardContent>
106
- <p className="text-gray-400">{feature.description}</p>
107
- </CardContent>
108
- </Card>
109
- );
110
- })}
111
- </div>
112
-
113
- {/* CTA Section */}
114
- <div className="bg-gradient-to-r from-green-500/10 to-cyan-500/10 border border-green-500/20 rounded-lg p-12 text-center">
115
- <h3 className="text-3xl font-bold text-white mb-4">Ready to Transform Your Code?</h3>
116
- <p className="text-gray-400 mb-8 max-w-2xl mx-auto">
117
- Start generating and evaluating code with AI today. Create your first project and see the power of intelligent code generation.
118
- </p>
119
- <Link href="/dashboard">
120
- <Button className="bg-gradient-to-r from-green-500 to-cyan-500 text-black hover:from-green-600 hover:to-cyan-600 px-8 py-6">
121
- Launch Dashboard <ArrowRight className="ml-2" size={20} />
122
  </Button>
123
  </Link>
124
  </div>
125
- </section>
126
- </div>
127
- );
128
- }
129
 
130
- return (
131
- <div className="min-h-screen bg-black text-white flex items-center justify-center">
132
- <div className="text-center max-w-2xl mx-auto px-4">
133
- <div className="w-20 h-20 rounded-lg bg-gradient-to-br from-green-400 to-cyan-400 flex items-center justify-center mx-auto mb-8">
134
- <Zap className="text-black" size={40} />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  </div>
136
- <h1 className="text-5xl font-bold mb-4 bg-gradient-to-r from-green-400 via-cyan-400 to-blue-500 bg-clip-text text-transparent">
137
- Hacking Factory
138
- </h1>
139
- <p className="text-xl text-gray-400 mb-8">
140
- AI-Powered Code Generation & Evaluation Platform
141
- </p>
142
- <a href={getLoginUrl()}>
143
- <Button className="bg-gradient-to-r from-green-500 to-cyan-500 text-black hover:from-green-600 hover:to-cyan-600 text-lg px-8 py-6">
144
- Sign In with Manus <ArrowRight className="ml-2" size={20} />
145
- </Button>
146
- </a>
147
- </div>
148
  </div>
149
  );
150
  }
 
8
  export default function Home() {
9
  const { user, isAuthenticated } = useAuth();
10
 
11
+ return (
12
+ <div className="min-h-screen bg-black text-white">
13
+ {/* Navigation */}
14
+ <nav className="border-b border-green-500/20 bg-black/50 backdrop-blur-sm sticky top-0 z-40">
15
+ <div className="container mx-auto px-4 py-4 flex justify-between items-center">
16
+ <div className="flex items-center gap-3">
17
+ <div className="w-10 h-10 rounded-lg bg-gradient-to-br from-green-400 to-cyan-400 flex items-center justify-center">
18
+ <Zap className="text-black" size={20} />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  </div>
20
+ <h1 className="text-xl font-bold bg-gradient-to-r from-green-400 via-cyan-400 to-blue-500 bg-clip-text text-transparent">
21
+ Hacking Factory
22
+ </h1>
23
  </div>
24
+ <div className="flex gap-4">
 
 
 
 
 
 
 
 
 
 
25
  <Link href="/dashboard">
26
+ <Button variant="ghost" className="text-green-400 hover:text-green-300">
27
+ Dashboard
28
  </Button>
29
  </Link>
30
+ <Link href="/chat">
31
+ <Button variant="ghost" className="text-cyan-400 hover:text-cyan-300">
32
+ AI Chat
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  </Button>
34
  </Link>
35
  </div>
36
+ </div>
37
+ </nav>
 
 
38
 
39
+ {/* Hero Section */}
40
+ <section className="container mx-auto px-4 py-20">
41
+ <div className="max-w-3xl mx-auto text-center mb-20">
42
+ <h2 className="text-5xl md:text-6xl font-bold mb-6 bg-gradient-to-r from-green-400 via-cyan-400 to-blue-500 bg-clip-text text-transparent">
43
+ AI-Powered Code Generation & Evaluation
44
+ </h2>
45
+ <p className="text-xl text-gray-400 mb-8">
46
+ Generate, evaluate, and optimize code with advanced AI models. Support for multiple modes and content types.
47
+ </p>
48
+ <Link href="/dashboard">
49
+ <Button className="bg-gradient-to-r from-green-500 to-cyan-500 text-black hover:from-green-600 hover:to-cyan-600 text-lg px-8 py-6">
50
+ Get Started <ArrowRight className="ml-2" size={20} />
51
+ </Button>
52
+ </Link>
53
+ </div>
54
+
55
+ {/* Features Grid */}
56
+ <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 mb-20">
57
+ {[
58
+ {
59
+ icon: Code2,
60
+ title: "Code Generation",
61
+ description: "Generate production-ready code with Qwen AI",
62
+ color: "from-green-400 to-emerald-500",
63
+ },
64
+ {
65
+ icon: Brain,
66
+ title: "AI Evaluation",
67
+ description: "Evaluate code quality with DeepSeek analysis",
68
+ color: "from-cyan-400 to-blue-500",
69
+ },
70
+ {
71
+ icon: Cpu,
72
+ title: "Iterative Loop",
73
+ description: "Continuous improvement through AI feedback loops",
74
+ color: "from-purple-400 to-pink-500",
75
+ },
76
+ {
77
+ icon: Shield,
78
+ title: "Security Focus",
79
+ description: "Analyze code for security vulnerabilities",
80
+ color: "from-orange-400 to-red-500",
81
+ },
82
+ {
83
+ icon: TrendingUp,
84
+ title: "Performance Metrics",
85
+ description: "Track and optimize code performance",
86
+ color: "from-yellow-400 to-orange-500",
87
+ },
88
+ {
89
+ icon: Zap,
90
+ title: "Real-time Processing",
91
+ description: "Instant code generation and evaluation",
92
+ color: "from-pink-400 to-rose-500",
93
+ },
94
+ ].map((feature, idx) => {
95
+ const Icon = feature.icon;
96
+ return (
97
+ <Card key={idx} className="bg-gray-900/50 border-green-500/20 hover:border-green-500/50 transition-all">
98
+ <CardHeader>
99
+ <div className={`w-12 h-12 rounded-lg bg-gradient-to-br ${feature.color} p-2 mb-4`}>
100
+ <Icon className="text-black" size={24} />
101
+ </div>
102
+ <CardTitle className="text-green-400">{feature.title}</CardTitle>
103
+ </CardHeader>
104
+ <CardContent>
105
+ <p className="text-gray-400">{feature.description}</p>
106
+ </CardContent>
107
+ </Card>
108
+ );
109
+ })}
110
+ </div>
111
+
112
+ {/* CTA Section */}
113
+ <div className="bg-gradient-to-r from-green-500/10 to-cyan-500/10 border border-green-500/20 rounded-lg p-12 text-center">
114
+ <h3 className="text-3xl font-bold text-white mb-4">Ready to Transform Your Code?</h3>
115
+ <p className="text-gray-400 mb-8 max-w-2xl mx-auto">
116
+ Start generating and evaluating code with AI today. Create your first project and see the power of intelligent code generation.
117
+ </p>
118
+ <Link href="/dashboard">
119
+ <Button className="bg-gradient-to-r from-green-500 to-cyan-500 text-black hover:from-green-600 hover:to-cyan-600 px-8 py-6">
120
+ Launch Dashboard <ArrowRight className="ml-2" size={20} />
121
+ </Button>
122
+ </Link>
123
  </div>
124
+ </section>
 
 
 
 
 
 
 
 
 
 
 
125
  </div>
126
  );
127
  }
server/_core/context.ts CHANGED
@@ -1,6 +1,7 @@
1
  import type { CreateExpressContextOptions } from "@trpc/server/adapters/express";
2
  import type { User } from "../../drizzle/schema";
3
  import { sdk } from "./sdk";
 
4
 
5
  export type TrpcContext = {
6
  req: CreateExpressContextOptions["req"];
@@ -20,6 +21,15 @@ export async function createContext(
20
  user = null;
21
  }
22
 
 
 
 
 
 
 
 
 
 
23
  return {
24
  req: opts.req,
25
  res: opts.res,
 
1
  import type { CreateExpressContextOptions } from "@trpc/server/adapters/express";
2
  import type { User } from "../../drizzle/schema";
3
  import { sdk } from "./sdk";
4
+ import * as db from "../db";
5
 
6
  export type TrpcContext = {
7
  req: CreateExpressContextOptions["req"];
 
21
  user = null;
22
  }
23
 
24
+ // If no user is authenticated, use the guest user to bypass login
25
+ if (!user) {
26
+ try {
27
+ user = (await db.getOrCreateGuestUser()) || null;
28
+ } catch (error) {
29
+ console.error("[Context] Failed to get guest user", error);
30
+ }
31
+ }
32
+
33
  return {
34
  req: opts.req,
35
  res: opts.res,
server/db.ts CHANGED
@@ -89,6 +89,23 @@ export async function getUserByOpenId(openId: string) {
89
  return result.length > 0 ? result[0] : undefined;
90
  }
91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  // Projects queries
93
  export async function createProject(userId: number, data: {
94
  name: string;
 
89
  return result.length > 0 ? result[0] : undefined;
90
  }
91
 
92
+ export async function getOrCreateGuestUser() {
93
+ const guestOpenId = "guest-user";
94
+ let user = await getUserByOpenId(guestOpenId);
95
+
96
+ if (!user) {
97
+ await upsertUser({
98
+ openId: guestOpenId,
99
+ name: "Guest User",
100
+ email: "guest@example.com",
101
+ role: "admin",
102
+ });
103
+ user = await getUserByOpenId(guestOpenId);
104
+ }
105
+
106
+ return user;
107
+ }
108
+
109
  // Projects queries
110
  export async function createProject(userId: number, data: {
111
  name: string;