Skip to content

Commit b88a688

Browse files
Test-1
1 parent d2aacdc commit b88a688

File tree

67 files changed

+1458
-94
lines changed

Some content is hidden

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

67 files changed

+1458
-94
lines changed

aws/.aws-sam/build.toml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,50 @@
11
# This file is auto generated by SAM CLI build command
22

3-
[function_build_definitions.d4cdc4f4-b6a9-48d4-a2ff-19fb9d9e8786]
3+
[function_build_definitions.1c4c8e46-8650-4c74-9f1f-71edc7117c05]
44
packagetype = "Image"
55
functions = ["RegisterFunction"]
66

7-
[function_build_definitions.d4cdc4f4-b6a9-48d4-a2ff-19fb9d9e8786.metadata]
7+
[function_build_definitions.1c4c8e46-8650-4c74-9f1f-71edc7117c05.metadata]
88
DockerTag = "ai-register-lambda"
99
DockerContext = "D:\\GOATED\\Zuno - AI Powered Chatbot\\aws"
1010
Dockerfile = "NodeRegister.Dockerfile"
1111
DockerCMD = ["handlers/registerHandler.handler"]
1212

13-
[function_build_definitions.7ed0cd8e-4ac1-447a-98f5-5f27de2071db]
13+
[function_build_definitions.a376c12b-eeb1-4ce3-ba76-2a0665110fc3]
14+
packagetype = "Image"
15+
functions = ["ProjectFunction"]
16+
17+
[function_build_definitions.a376c12b-eeb1-4ce3-ba76-2a0665110fc3.metadata]
18+
DockerTag = "ai-project-lambda"
19+
DockerContext = "D:\\GOATED\\Zuno - AI Powered Chatbot\\aws"
20+
Dockerfile = "CreateProject.Dockerfile"
21+
DockerCMD = ["handlers/CreateProjectHandler.handler"]
22+
23+
[function_build_definitions.d15cc648-6c32-4c83-911c-7cec3f826e32]
1424
packagetype = "Image"
1525
functions = ["ChatFunction"]
1626

17-
[function_build_definitions.7ed0cd8e-4ac1-447a-98f5-5f27de2071db.metadata]
27+
[function_build_definitions.d15cc648-6c32-4c83-911c-7cec3f826e32.metadata]
1828
DockerTag = "ai-chat-lambda"
1929
DockerContext = "D:\\GOATED\\Zuno - AI Powered Chatbot\\aws"
2030
Dockerfile = "NodeChat.Dockerfile"
2131
DockerCMD = ["handlers/aiChatHandler.handler"]
2232

23-
[function_build_definitions.ea5595d6-5f2e-42af-8cba-5aa26d682af3]
33+
[function_build_definitions.fd320841-8c10-44bc-aa22-3af3e15bae69]
2434
packagetype = "Image"
2535
functions = ["EmbeddingFunction"]
2636

27-
[function_build_definitions.ea5595d6-5f2e-42af-8cba-5aa26d682af3.metadata]
37+
[function_build_definitions.fd320841-8c10-44bc-aa22-3af3e15bae69.metadata]
2838
DockerTag = "ai-embedding-lambda"
2939
DockerContext = "D:\\GOATED\\Zuno - AI Powered Chatbot\\aws"
3040
Dockerfile = "EmbeddingHandler.Dockerfile"
3141
DockerCMD = ["handlers/embeddingHandler.handler"]
3242

33-
[function_build_definitions.a8d59e15-5123-4732-b7a3-f394bec8d81f]
43+
[function_build_definitions.6a9d1400-d6ba-4472-ade4-7f5e5c9262a7]
3444
packagetype = "Image"
3545
functions = ["ScrapingFunction"]
3646

37-
[function_build_definitions.a8d59e15-5123-4732-b7a3-f394bec8d81f.metadata]
47+
[function_build_definitions.6a9d1400-d6ba-4472-ade4-7f5e5c9262a7.metadata]
3848
DockerTag = "ai-scraper-lambda"
3949
DockerContext = "D:\\GOATED\\Zuno - AI Powered Chatbot\\aws"
4050
Dockerfile = "PythonScraper.Dockerfile"

aws/CreateProject.Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM public.ecr.aws/lambda/nodejs:18
2+
3+
WORKDIR /var/task
4+
5+
COPY package*.json ./
6+
7+
RUN npm ci --only=production
8+
9+
COPY . .
10+
11+
CMD ["handlers/createProjectHandler.js"]

aws/EmbeddingHandler.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ RUN npm ci --only=production
1111
COPY . .
1212

1313
# CMD must be module.function
14-
CMD ["embeddingHandler.handler"]
14+
CMD ["handlers/embeddingHandler.handler"]

aws/NodeChat.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ RUN npm ci --only=production
1111
COPY . .
1212

1313
# CMD must be module.function
14-
CMD ["aiChatHandler.handler"]
14+
CMD ["handlers/aiChatHandler.handler"]

aws/NodeRegister.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ RUN npm ci --only=production
1111
COPY . .
1212

1313
# CMD must be module.function
14-
CMD ["registerHandler.handler"]
14+
CMD ["handlers/registerHandler.handler"]

aws/PythonScraper.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ RUN yum install -y gcc gcc-c++ libffi-devel libxml2-devel libxslt-devel python3-
55
RUN pip install --upgrade pip && pip install scrapy boto3
66

77
COPY . .
8-
CMD ["scrapingHandler.handler"]
8+
CMD ["handlers/scrapingHandler.handler"]

aws/controllers/chat.controller.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// aws/controllers/chat.controller.js
2+
const { AppError } = require('../utils/errorHandler');
3+
const aiService = require('../ai/index.js');
4+
5+
async function sendChatQuery(userId, projectId, queryText) {
6+
if (!queryText) throw new AppError("Query is required", 400);
7+
8+
// Call AI service pipeline/chat with query
9+
const response = await aiService.chatPipeline(userId, projectId, queryText);
10+
return response;
11+
}
12+
13+
async function sendChatStream(userId, projectId, queryText) {
14+
if (!queryText) throw new AppError("Query is required", 400);
15+
16+
// Call streaming pipeline
17+
const stream = await aiService.chatStreamPipeline(userId, projectId, queryText);
18+
return stream;
19+
}
20+
21+
module.exports = {
22+
sendChatQuery,
23+
sendChatStream,
24+
};

aws/handlers/createProjectHandler.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// aws/handlers/createProjectHandler.js
2+
require("dotenv").config();
23

34
const { DynamoDBClient } = require('@aws-sdk/client-dynamodb');
45
const {

aws/handlers/registerHandler.js

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,72 @@
11
// aws/handlers/registerHandler.js
2+
require("dotenv").config();
23

34
const { DynamoDBClient } = require('@aws-sdk/client-dynamodb');
45
const { DynamoDBDocumentClient, GetCommand, PutCommand } = require('@aws-sdk/lib-dynamodb');
56

6-
const isLocal = process.env.IS_OFFLINE === "true";
7-
8-
const ddb = DynamoDBDocumentClient.from(
9-
new DynamoDBClient(
10-
isLocal
11-
? {
12-
region: "local",
13-
endpoint: "http://localhost:8000",
14-
credentials: {
15-
accessKeyId: "dummy",
16-
secretAccessKey: "dummy",
17-
},
18-
}
19-
: { region: process.env.AWS_REGION }
20-
)
21-
);
7+
const isLocal = "true";
8+
9+
console.log("Environment variables:", {
10+
USERS_TABLE: process.env.USERS_TABLE,
11+
AWS_REGION: process.env.AWS_REGION,
12+
});
13+
14+
const ddbClientConfig = isLocal
15+
? {
16+
region: "local",
17+
endpoint: "http://localhost:8000",
18+
credentials: {
19+
accessKeyId: "dummy",
20+
secretAccessKey: "dummy",
21+
},
22+
}
23+
: { region: process.env.AWS_REGION };
24+
25+
console.log("DynamoDB Client Config:", ddbClientConfig);
26+
27+
const ddb = DynamoDBDocumentClient.from(new DynamoDBClient(ddbClientConfig));
2228

2329
exports.handler = async (event) => {
2430
try {
31+
console.log("Received event:", JSON.stringify(event, null, 2));
32+
2533
const body = JSON.parse(event.body || '{}');
34+
console.log("Parsed body:", body);
35+
2636
const { userId, fullName, email } = body;
2737

2838
if (!userId || !email || !fullName) {
39+
console.warn("Missing required fields in request body");
2940
return {
3041
statusCode: 400,
3142
body: JSON.stringify({ error: 'Missing required user fields: userId, fullName, email' }),
3243
};
3344
}
3445

46+
const tableName = process.env.USERS_TABLE;
47+
console.log("Using DynamoDB table:", tableName);
48+
49+
if (!tableName) {
50+
console.error("USERS_TABLE env variable is missing or empty");
51+
return {
52+
statusCode: 500,
53+
body: JSON.stringify({ error: "Server misconfiguration: USERS_TABLE is not set" }),
54+
};
55+
}
56+
3557
// Check if user already exists
58+
console.log(`Checking if user ${userId} exists in table ${tableName}...`);
3659
const existingUser = await ddb.send(
3760
new GetCommand({
38-
TableName: process.env.USERS_TABLE,
61+
TableName: tableName,
3962
Key: { userId },
4063
})
4164
);
4265

66+
console.log("DynamoDB GetCommand response:", existingUser);
67+
4368
if (existingUser.Item) {
44-
// User already registered, return success with existing user info (optional)
69+
console.log(`User ${userId} already exists`);
4570
return {
4671
statusCode: 200,
4772
body: JSON.stringify({
@@ -64,13 +89,17 @@ exports.handler = async (event) => {
6489
createdAt: new Date().toISOString(),
6590
};
6691

67-
await ddb.send(
92+
console.log("Creating new user:", newUser);
93+
94+
const putResult = await ddb.send(
6895
new PutCommand({
69-
TableName: process.env.USERS_TABLE,
96+
TableName: tableName,
7097
Item: newUser,
7198
})
7299
);
73100

101+
console.log("DynamoDB PutCommand result:", putResult);
102+
74103
return {
75104
statusCode: 201,
76105
body: JSON.stringify({

aws/sample/project.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// testRegister.js
2+
const { handler } = require("../handlers/createProjectHandler");
3+
4+
const mockEvent = {
5+
body: JSON.stringify({
6+
userId: "test-user-123",
7+
fullName: "Test User",
8+
9+
frontendUrl:"thetechshaikh.online",
10+
projectName:"project-test"
11+
}),
12+
};
13+
14+
console.log("Invoking handler with event:", mockEvent);
15+
16+
handler(mockEvent)
17+
.then((res) => {
18+
console.log("Lambda Response:", res);
19+
})
20+
.catch((err) => {
21+
console.error("Lambda Error:", err);
22+
});
23+

0 commit comments

Comments
 (0)