tenderizer / src /models /Tender.js
ismizo's picture
Upload 28 files
35f49fd verified
Raw History Blame Contribute Delete
2.83 kB
import mongoose from 'mongoose';
const tenderSchema = new mongoose.Schema({
user: {
type: mongoose.Schema.Types.ObjectId,
required: true,
ref: 'User'
},
title: {
type: String,
required: true,
trim: true
},
// Which company is this bid for (set by the user)
companyName: {
type: String,
default: '',
trim: true
},
userPrompt: String,
submissionInstructions: String,
description: String,
status: {
type: String,
enum: ['draft', 'analyzing', 'awaiting_documents', 'planning', 'drafting', 'review', 'completed'],
default: 'draft'
},
// Files uploaded by the user (PDFs, Images, Word docs)
inputFiles: [{
originalName: String,
storageKey: String,
mimeType: String,
size: Number,
// 'call' = RFP/TOR/EOI/bid announcement docs
// 'company' = applicant's company documents (profile, CVs, past projects, financials, certs)
// 'other' = uncategorised
documentCategory: {
type: String,
enum: ['call', 'company', 'other'],
default: 'other'
},
// Company name this document belongs to (only meaningful for category='company')
companyName: { type: String, default: '' },
// AI-assigned label e.g. "Call Document - RFP", "Company Profile"
aiLabel: { type: String, default: 'Uploaded Document' },
// AI-assigned 1-2 sentence summary
aiDescription: { type: String, default: '' },
uploadedAt: { type: Date, default: Date.now }
}],
// Context/Instructions extracted by AI
analysis: {
announcementType: String,
summary: String,
requirements: [String],
missingDocuments: [String],
missingDocumentsConfirmed: { type: Boolean, default: false },
existingDocuments: [String],
strategyQuestions: [{
question: String,
answer: String
}],
isComplete: { type: Boolean, default: false }
},
// The Plan for generating documents
draftingPlan: [{
docName: String,
purpose: String,
outline: {
sections: [String],
estimatedPages: Number,
estimatedParagraphs: Number,
keyPoints: [String]
},
status: { type: String, default: 'pending' },
storageKey: String
}],
// How many times the user has started a full from-scratch process (analyze → plan → docs).
// Locked (read-only view) once this hits 3.
generationCount: {
type: Number,
default: 0
},
createdAt: {
type: Date,
default: Date.now
}
});
const Tender = mongoose.model('Tender', tenderSchema);
export default Tender;