mirror of
https://github.com/vee1e/bulk-questionnaire-upload.git
synced 2026-09-01 09:50:06 +00:00
mirror of https://github.com/vee1e/bulk-questionnaire-upload - Fork containing all the code for my C4GT '25 menteeship at D
| backend | ||
| frontend | ||
| .gitignore | ||
| README.md | ||
| run.sh | ||
Bulk Questionnaire Upload
A web application for uploading and parsing Excel-based questionnaires in XLSForm-like format with MongoDB integration.
Project Structure
│
├── frontend/ # Angular frontend application
├── backend/ # FastAPI backend with MongoDB
└── README.md
Stack
Frontend
- Angular 16+
- Material UI
- SCSS
Backend
- Python FastAPI
- MongoDB for data persistence
openpyxl/pandasfor Excel parsingmotor/pymongofor MongoDB integration
Prerequisites
- Python 3.8+ (recommend using a virtual environment)
- Node.js 16+ and npm
- MongoDB (local or cloud instance)
- pip
Installation & Setup
1. Install MongoDB (Artix/Arch Linux)
Start MongoDB service:
sudo rc-service mongodb start # OpenRC (Artix default)
# or
sudo systemctl start mongodb # If using systemd
mongosh --eval "db.runCommand('ping')"
# Should output: { ok: 1 }
2. Backend Setup
-
Navigate to the backend directory:
cd backend/ -
Create and activate virtual environment:
python -m venv .venv source .venv/bin/activate -
Install Python dependencies:
pip install --upgrade pip pip install --break-system-packages -r requirements.txtIf you see an "externally-managed-environment" error, use the
--break-system-packagesflag as above. -
Create environment configuration: Create a
.envfile in thebackend/directory:MONGODB_URL=mongodb://localhost:27017 DATABASE_NAME=mform_bulk_upload API_HOST=0.0.0.0 API_PORT=8000 -
Start the FastAPI server:
uvicorn main:app --reloadThe API will be available at http://localhost:8000
3. Frontend Setup
-
Navigate to the frontend directory:
cd frontend/ -
Install Node.js dependencies:
npm install -
Start the development server:
ng serveThe frontend will be available at http://localhost:4200
API Endpoints
File Validation
- POST
/api/validateValidate Excel file structure. Returns detailed validation information including sheet status, metadata, and counts.
File Upload
- POST
/api/uploadParse and store Excel file in MongoDB. Saves form metadata, questions, and answer options to separate collections.
Forms Management
- GET
/api/formsGet 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"
}