Skip to main content

Story 6: Digital Transfer Certificate

Overview

FieldValue
Story IDNGE-13-6
Story Points8
SprintSprint 9

Technical Implementation

TC Generation with QR Verification

@Injectable()
export class TCService {
async generateTC(studentId: string, dto: GenerateTCDto) {
// Generate unique TC number
const tcNumber = `TC/${year}/${String(count).padStart(5, '0')}`;

// Generate verification code for QR
const verificationCode = this.generateCode();
const verifyUrl = `https://verify.edupulse.in/tc/${verificationCode}`;

// Generate QR code
const qrCode = await QRCode.toDataURL(verifyUrl);

// Generate PDF with school letterhead
const pdf = await this.pdfService.generateTC({
student,
tcNumber,
qrCode,
conduct: dto.conduct,
});

// Upload to S3
await this.s3.upload({ key: `tc/${tcNumber}.pdf`, body: pdf });

// Update student status
await this.prisma.student.update({
where: { id: studentId },
data: { status: 'TRANSFERRED', tcNumber }
});

return { tcNumber, downloadUrl };
}

// Public verification endpoint
async verifyTC(code: string) {
const tc = await this.prisma.transferCertificate.findUnique({
where: { verificationCode: code }
});
return tc ? { isValid: true, ...tc } : { isValid: false };
}
}