Backend Infrastructure: - Complete Express server setup with security middleware (helmet, CORS, rate limiting) - Comprehensive error handling and logging with Winston - Authentication system with JWT tokens and session management - Database models and migrations for Users, Documents, Feedback, and Processing Jobs - API routes structure for authentication and document management - Integration tests for all server components (86 tests passing) Frontend Infrastructure: - React application with TypeScript and Vite - Authentication UI with login form, protected routes, and logout functionality - Authentication context with proper async state management - Component tests with proper async handling (25 tests passing) - Tailwind CSS styling and responsive design Key Features: - User registration, login, and authentication - Protected routes with role-based access control - Comprehensive error handling and user feedback - Database schema with proper relationships - Security middleware and validation - Production-ready build configuration Test Coverage: 111/111 tests passing Tasks Completed: 1-5 (Project setup, Database, Auth system, Frontend UI, Backend infrastructure) Ready for Task 6: File upload backend infrastructure
8.7 KiB
Requirements Document
Introduction
This feature enables team members to upload CIM (Confidential Information Memorandum) documents through a secure web interface, have them analyzed by an LLM for detailed review, and receive structured summaries in both Markdown and PDF formats. The system provides authentication, document processing, and downloadable outputs following a specific template format.
Requirements
Requirement 1
User Story: As a team member, I want to securely log into the website, so that I can access the CIM processing functionality with proper authentication.
Acceptance Criteria
- WHEN a user visits the website THEN the system SHALL display a login page
- WHEN a user enters valid credentials THEN the system SHALL authenticate them and redirect to the main dashboard
- WHEN a user enters invalid credentials THEN the system SHALL display an error message and remain on the login page
- WHEN a user is not authenticated THEN the system SHALL redirect them to the login page for any protected routes
- WHEN a user logs out THEN the system SHALL clear their session and redirect to the login page
Requirement 2
User Story: As an authenticated team member, I want to upload CIM PDF documents (75-100+ pages), so that I can have them processed and analyzed.
Acceptance Criteria
- WHEN a user accesses the upload interface THEN the system SHALL display a file upload component
- WHEN a user selects a PDF file THEN the system SHALL validate it is a PDF format
- WHEN a user uploads a file larger than 100MB THEN the system SHALL reject it with an appropriate error message
- WHEN a user uploads a non-PDF file THEN the system SHALL reject it with an appropriate error message
- WHEN a valid PDF is uploaded THEN the system SHALL store it securely and initiate processing
- WHEN upload is in progress THEN the system SHALL display upload progress to the user
Requirement 3
User Story: As a team member, I want the uploaded CIM to be reviewed in detail by an LLM using a two-part analysis process, so that I can get both structured data extraction and expert investment analysis.
Acceptance Criteria
- WHEN a CIM document is uploaded THEN the system SHALL extract text content from the PDF
- WHEN text extraction is complete THEN the system SHALL send the content to an LLM with the predefined analysis prompt
- WHEN LLM processing begins THEN the system SHALL execute Part 1 (CIM Data Extraction) using only information from the CIM text
- WHEN Part 1 is complete THEN the system SHALL execute Part 2 (Analyst Diligence Questions) using both CIM content and general industry knowledge
- WHEN LLM processing is in progress THEN the system SHALL display processing status to the user
- WHEN LLM analysis fails THEN the system SHALL log the error and notify the user
- WHEN LLM analysis is complete THEN the system SHALL store both the populated template and diligence analysis results
- IF the document is too large for single LLM processing THEN the system SHALL chunk it appropriately and process in segments
Requirement 4
User Story: As a team member, I want the LLM to populate the predefined BPCP CIM Review Template with extracted data and include investment diligence analysis, so that I receive consistent and structured summaries following our established format.
Acceptance Criteria
- WHEN LLM processing begins THEN the system SHALL provide both the CIM text and the BPCP CIM Review Template to the LLM
- WHEN executing Part 1 THEN the system SHALL ensure the LLM populates all template sections (A-G) using only CIM-sourced information
- WHEN template fields cannot be populated from CIM THEN the system SHALL ensure "Not specified in CIM" is entered
- WHEN executing Part 2 THEN the system SHALL ensure the LLM adds a "Key Investment Considerations & Diligence Areas" section
- WHEN LLM processing is complete THEN the system SHALL validate the output maintains proper markdown formatting and template structure
- WHEN template validation fails THEN the system SHALL log the error and retry the LLM processing
- WHEN the populated template is ready THEN the system SHALL store it as the final markdown summary
Requirement 5
User Story: As a team member, I want to download the CIM summary in both Markdown and PDF formats, so that I can use the analysis in different contexts and share it appropriately.
Acceptance Criteria
- WHEN a CIM summary is ready THEN the system SHALL provide download links for both MD and PDF formats
- WHEN a user clicks the Markdown download THEN the system SHALL serve the .md file for download
- WHEN a user clicks the PDF download THEN the system SHALL convert the markdown to PDF and serve it for download
- WHEN PDF conversion is in progress THEN the system SHALL display conversion status
- WHEN PDF conversion fails THEN the system SHALL log the error and notify the user
- WHEN downloads are requested THEN the system SHALL ensure proper file naming with timestamps
Requirement 6
User Story: As a team member, I want to view the processing status and history of my uploaded CIMs, so that I can track progress and access previous analyses.
Acceptance Criteria
- WHEN a user accesses the dashboard THEN the system SHALL display a list of their uploaded documents
- WHEN viewing document history THEN the system SHALL show upload date, processing status, and completion status
- WHEN a document is processing THEN the system SHALL display real-time status updates
- WHEN a document processing is complete THEN the system SHALL show download options
- WHEN a document processing fails THEN the system SHALL display error information and retry options
- WHEN viewing document details THEN the system SHALL show file name, size, and processing timestamps
Requirement 7
User Story: As a team member, I want to provide feedback on generated summaries and request regeneration with specific instructions, so that I can get summaries that better meet my needs.
Acceptance Criteria
- WHEN viewing a completed summary THEN the system SHALL provide a feedback interface for user comments
- WHEN a user submits feedback THEN the system SHALL store the commentary with the document record
- WHEN a user requests summary regeneration THEN the system SHALL provide a text field for specific instructions
- WHEN regeneration is requested THEN the system SHALL reprocess the document using the original content plus user instructions
- WHEN regeneration is complete THEN the system SHALL replace the previous summary with the new version
- WHEN multiple regenerations occur THEN the system SHALL maintain a history of previous versions
- WHEN viewing summary history THEN the system SHALL show timestamps and user feedback for each version
Requirement 8
User Story: As a system administrator, I want to view and manage all uploaded PDF files and summary files from all users, so that I can maintain an archive and have oversight of all processed documents.
Acceptance Criteria
- WHEN an administrator accesses the admin dashboard THEN the system SHALL display all uploaded documents from all users
- WHEN viewing the admin archive THEN the system SHALL show document details including uploader, upload date, and processing status
- WHEN an administrator selects a document THEN the system SHALL provide access to both original PDF and generated summaries
- WHEN an administrator downloads files THEN the system SHALL log the admin access for audit purposes
- WHEN viewing user documents THEN the system SHALL display user information alongside document metadata
- WHEN searching the archive THEN the system SHALL allow filtering by user, date range, and processing status
- WHEN an administrator deletes a document THEN the system SHALL remove both the original PDF and all generated summaries
- WHEN an administrator confirms deletion THEN the system SHALL log the deletion action for audit purposes
- WHEN files are deleted THEN the system SHALL free up storage space and update storage metrics
Requirement 9
User Story: As a system administrator, I want the application to handle errors gracefully and maintain security, so that the system remains stable and user data is protected.
Acceptance Criteria
- WHEN any system error occurs THEN the system SHALL log detailed error information
- WHEN file uploads fail THEN the system SHALL clean up any partial uploads
- WHEN LLM processing fails THEN the system SHALL retry up to 3 times before marking as failed
- WHEN user sessions expire THEN the system SHALL redirect to login without data loss
- WHEN unauthorized access is attempted THEN the system SHALL log the attempt and deny access
- WHEN sensitive data is processed THEN the system SHALL ensure encryption at rest and in transit