A Spring Boot web application designed to transform documents into comprehensive FAQ formats. This application provides an intelligent system for processing documents and generating relevant questions and answers.
- File Upload: Upload PDF, DOCX, and TXT files up to 10 MB
- Cloud Storage: Secure file storage using Amazon S3
- File Validation: Automatic validation of file types and sizes
- Unique File IDs: Generate unique identifiers for uploaded files
- Responsive Web Interface: Modern, user-friendly design with drag-and-drop upload
- Real-time Feedback: Progress indicators and success/error messages
- RESTful API: Ready for integration with other systems
- Java 17: Programming language
- Spring Boot 3.2.0: Application framework
- Maven: Build and dependency management
- Thymeleaf: Template engine for web pages
- Bootstrap 5: Frontend CSS framework
- Font Awesome: Icons
- AWS SDK: Amazon S3 integration for file storage
Before running this application, make sure you have the following installed:
- Java 17 or higher
- Maven 3.6+ (or use the Maven wrapper included in the project)
- Git (for cloning the repository)
- AWS Account with S3 access (for file upload functionality)
To use the file upload feature, you need to configure AWS credentials. The application supports multiple credential sources:
export AWS_ACCESS_KEY_ID=your-access-key-id
export AWS_SECRET_ACCESS_KEY=your-secret-access-keyCreate ~/.aws/credentials file:
[default]
aws_access_key_id = your-access-key-id
aws_secret_access_key = your-secret-access-keyIf running on EC2, attach an IAM role with S3 permissions.
Ensure the S3 bucket bucket-name-51720177 exists and your AWS credentials have the following permissions:
s3:PutObjects3:PutObjectAcl
git clone <repository-url>
cd doc2faqUsing Maven:
mvn clean compileOr using the Maven wrapper (if available):
./mvnw clean compileUsing Maven:
mvn spring-boot:runOr using the Maven wrapper:
./mvnw spring-boot:runAlternatively, you can build a JAR file and run it:
mvn clean package
java -jar target/doc2faq-1.0.0-SNAPSHOT.jarOnce the application starts successfully, you can access it at:
- URL: http://localhost:8080
- Port: 8080 (configurable in
application.properties)
doc2faq/
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── docfaq/
│ │ │ ├── Doc2FaqApplication.java # Main application class
│ │ │ ├── config/
│ │ │ │ └── AwsConfig.java # AWS S3 configuration
│ │ │ ├── controller/
│ │ │ │ ├── HomeController.java # Home page controller
│ │ │ │ └── FileUploadController.java # File upload API controller
│ │ │ ├── service/
│ │ │ │ ├── FileUploadService.java # File upload business logic
│ │ │ │ └── S3Service.java # S3 operations service
│ │ │ └── model/
│ │ │ └── UploadResponse.java # Upload response model
│ │ └── resources/
│ │ ├── templates/
│ │ │ └── index.html # Landing page with upload form
│ │ ├── application.properties # Application configuration
│ │ └── static/ # Static resources (CSS, JS, images)
│ └── test/
│ ├── java/
│ │ └── com/
│ │ └── docfaq/
│ │ └── Doc2FaqApplicationTests.java # Integration tests
│ └── resources/
│ └── application-test.properties # Test configuration
├── target/ # Build output (generated)
├── pom.xml # Maven configuration
├── .gitignore # Git ignore rules
└── README.md # This file
The application can be configured through the application.properties file located in src/main/resources/. Key configuration options include:
server.port: Application port (default: 8080)spring.application.name: Application namespring.servlet.multipart.max-file-size: Maximum file upload size (default: 10MB)spring.servlet.multipart.max-request-size: Maximum request size (default: 10MB)aws.s3.bucket-name: S3 bucket name for file storageaws.s3.region: AWS region for S3 bucketlogging.level.*: Logging levels for different packages
Currently available endpoints:
GET /: Landing page with file upload interfacePOST /api/upload: File upload endpoint- Accepts: multipart/form-data with 'file' parameter
- Supported formats: PDF, DOCX, TXT
- Maximum size: 10 MB
- Returns: JSON response with upload status and file ID
GET /api/upload/status: Upload service health check
Success Response:
{
"success": true,
"message": "File uploaded successfully",
"fileId": "uuid-generated-id.pdf",
"fileName": "original-filename.pdf",
"fileSize": 1024000
}Error Response:
{
"success": false,
"message": "Error description"
}- PDF:
.pdffiles - Word Documents:
.docxfiles - Text Files:
.txtfiles
- Maximum file size: 10 MB per file
- Maximum request size: 10 MB
- User selects file via drag-and-drop or file browser
- Client-side validation checks file type and size
- File is uploaded to
/api/uploadendpoint - Server validates file and uploads to S3
- Unique file ID is generated and returned
- User receives success confirmation with file ID
- Invalid file types are rejected with clear error messages
- Files exceeding size limits are rejected
- Network errors are handled gracefully
- S3 upload failures are reported to the user
To run the test suite:
mvn testThe application includes Spring Boot DevTools for enhanced development experience:
- Automatic restart when code changes
- LiveReload support for web resources
- Enhanced debugging capabilities
The application is structured to easily accommodate new features:
- Controllers: Add new controllers in
com.docfaq.controllerpackage - Services: Create service classes in
com.docfaq.servicepackage - Models: Add data models in
com.docfaq.modelpackage - Templates: Add new Thymeleaf templates in
src/main/resources/templates/ - Static Resources: Add CSS, JS, and images in
src/main/resources/static/
-
Port Already in Use
- Change the port in
application.properties:server.port=8081 - Or kill the process using port 8080
- Change the port in
-
Java Version Issues
- Ensure Java 17 or higher is installed
- Check with:
java -version
-
Maven Issues
- Ensure Maven is properly installed
- Try using the Maven wrapper:
./mvnwinstead ofmvn
-
AWS Credentials Issues
- Verify AWS credentials are properly configured
- Check S3 bucket exists and permissions are correct
- Test with:
aws s3 ls s3://bucket-name-51720177
-
File Upload Issues
- Check file size is under 10 MB limit
- Verify file type is PDF, DOCX, or TXT
- Ensure S3 bucket has proper write permissions
Application logs are available in the console output. For more detailed logging, modify the logging levels in application.properties.
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes and commit:
git commit -am 'Add new feature' - Push to the branch:
git push origin feature-name - Submit a pull request
This project is licensed under the terms specified in the LICENSE file.
For questions or issues, please create an issue in the project repository.
Status: ✅ File upload feature implemented with S3 storage, validation, and responsive UI.