Skip to content

Commit 6eb2c0a

Browse files
committed
Refactor document processing structure and implement new services
- Removed the AWS Textract integration documentation from backend/docs/aws-textract-integration.md as it is no longer relevant. - Updated import paths in backend/src/app.module.ts and backend/src/app.module.spec.ts to reflect the new directory structure for document processing services. - Introduced backend/src/document-processor/document-processor.module.ts to encapsulate document processing logic, including AWS Textract and Bedrock services. - Added backend/src/document-processor/controllers/document-processor.controller.ts to handle document uploads and processing requests. - Implemented backend/src/document-processor/services/aws-textract.service.ts and backend/src/document-processor/services/aws-bedrock.service.ts for text extraction and medical analysis, respectively. - Enhanced unit tests for the new services and controller to ensure functionality and error handling.
1 parent 521b4af commit 6eb2c0a

11 files changed

+10
-53
lines changed

backend/docs/aws-textract-integration.md

Lines changed: 0 additions & 43 deletions
This file was deleted.

backend/src/app.module.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import { JwtModule } from '@nestjs/jwt';
55
import { ReportsService } from './reports/reports.service';
66
import { vi, describe, it, expect } from 'vitest';
77
import configuration from './config/configuration';
8-
import { AwsBedrockService } from './services/aws-bedrock.service';
8+
import { AwsBedrockService } from './document-processor/services/aws-bedrock.service';
99
import { PerplexityService } from './services/perplexity.service';
1010
import { AwsSecretsService } from './services/aws-secrets.service';
11-
import { AwsTextractService } from './services/aws-textract.service';
11+
import { AwsTextractService } from './document-processor/services/aws-textract.service';
1212

1313
describe('AppModule', () => {
1414
it('should compile the module', async () => {

backend/src/app.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { UserController } from './user/user.controller';
1010
import { ReportsModule } from './reports/reports.module';
1111
import { HealthController } from './health/health.controller';
1212
import { AuthMiddleware } from './auth/auth.middleware';
13-
import { DocumentProcessorModule } from './modules/document-processor.module';
13+
import { DocumentProcessorModule } from './document-processor/document-processor.module';
1414

1515
@Module({
1616
imports: [

backend/src/controllers/document-processor.controller.ts renamed to backend/src/document-processor/controllers/document-processor.controller.ts

File renamed without changes.

backend/src/modules/document-processor.module.ts renamed to backend/src/document-processor/document-processor.module.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Module } from '@nestjs/common';
2-
import { DocumentProcessorService } from '../services/document-processor.service';
2+
import { DocumentProcessorService } from './services/document-processor.service';
33
import { ConfigModule } from '@nestjs/config';
4-
import { AwsTextractService } from '../services/aws-textract.service';
5-
import { AwsBedrockService } from '../services/aws-bedrock.service';
6-
import { DocumentProcessorController } from '../controllers/document-processor.controller';
4+
import { AwsTextractService } from './services/aws-textract.service';
5+
import { AwsBedrockService } from './services/aws-bedrock.service';
6+
import { DocumentProcessorController } from './controllers/document-processor.controller';
77

88
@Module({
99
imports: [ConfigModule],

backend/src/services/aws-bedrock.service.spec.ts renamed to backend/src/document-processor/services/aws-bedrock.service.spec.ts

File renamed without changes.

backend/src/services/aws-bedrock.service.ts renamed to backend/src/document-processor/services/aws-bedrock.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
InvokeModelCommand,
66
InvokeModelCommandOutput,
77
} from '@aws-sdk/client-bedrock-runtime';
8-
import { RateLimiter } from '../utils/security.utils';
8+
import { RateLimiter } from '../../utils/security.utils';
99
import { createHash } from 'crypto';
1010

1111
/**

backend/src/services/aws-textract.service.spec.ts renamed to backend/src/document-processor/services/aws-textract.service.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { BadRequestException } from '@nestjs/common';
44
import { vi, describe, it, expect, beforeEach } from 'vitest';
55

66
// Mock the security.utils module
7-
vi.mock('../utils/security.utils', () => ({
7+
vi.mock('../../utils/security.utils', () => ({
88
validateFileSecurely: vi.fn(),
99
RateLimiter: vi.fn().mockImplementation(() => ({
1010
tryRequest: vi.fn().mockReturnValue(true),

backend/src/services/aws-textract.service.ts renamed to backend/src/document-processor/services/aws-textract.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Injectable, Logger, BadRequestException } from '@nestjs/common';
22
import { ConfigService } from '@nestjs/config';
33
import { TextractClient, AnalyzeDocumentCommand, Block } from '@aws-sdk/client-textract';
4-
import { validateFileSecurely, RateLimiter } from '../utils/security.utils';
4+
import { validateFileSecurely, RateLimiter } from '../../utils/security.utils';
55
import { createHash } from 'crypto';
66

77
export interface ExtractedTextResult {

backend/src/services/document-processor.service.spec.ts renamed to backend/src/document-processor/services/document-processor.service.spec.ts

File renamed without changes.

0 commit comments

Comments
 (0)