mirror of
https://github.com/vee1e/bulk-questionnaire-upload.git
synced 2026-09-01 09:50:06 +00:00
2.3 KiB
2.3 KiB
mForm Bulk Upload Backend
A FastAPI backend for parsing and storing Excel form data in MongoDB.
Prerequisites
- Python 3.8+
- MongoDB (local or cloud instance)
- pip
Installation
- Install dependencies:
pip install -r requirements.txt
-
Set up MongoDB:
- Install MongoDB locally or use MongoDB Atlas
- Create a database named
mform_bulk_upload
-
Environment Configuration: Create a
.envfile in the backend directory:MONGODB_URL=mongodb://localhost:27017 DATABASE_NAME=mform_bulk_upload
Running the Application
python main.py
The API will be available at http://localhost:8000
API Endpoints
File Validation
- POST
/api/validate- Validate Excel file structure- Returns detailed validation information including sheet status, metadata, and counts
File Upload
- POST
/api/upload- Parse and store Excel file in MongoDB- Saves form metadata, questions, and answer options to separate collections
Forms Management
- GET
/api/forms- Get all forms from database - GET
/api/forms/{form_id}- Get specific form with questions and options - DELETE
/api/forms/{form_id}- Delete form and all related data
Database Schema
Forms Collection
{
"_id": "ObjectId",
"title": "string",
"language": "string",
"version": "string",
"created_at": "ISO timestamp"
}
Questions Collection
{
"_id": "ObjectId",
"form_id": "string",
"order": "number",
"title": "string",
"view_sequence": "number",
"input_type": "number",
"created_at": "ISO timestamp"
}
Options Collection
{
"_id": "ObjectId",
"form_id": "string",
"order": "number",
"option_id": "number",
"label": "string",
"created_at": "ISO timestamp"
}
Excel File Structure
The application expects Excel files with three sheets:
-
Forms - Form metadata
- Columns: Language, Title
-
Questions Info - Question definitions
- Columns: Order, Title, View Sequence, Input Type
-
Answer Options - Answer choices for questions
- Columns: Order, Id, Label
Features
- ✅ Excel file validation with detailed feedback
- ✅ MongoDB integration for data persistence
- ✅ RESTful API endpoints
- ✅ Error handling and logging
- ✅ CORS support for frontend integration