This is a simple quiz application built with Flask for the backend API and Vue.js for the frontend. The application supports user authentication, quiz participation, and stores results in a SQLite database. It also allows administrators to rebuild the database and fetch quiz information.
- Backend: Flask (Python)
- Frontend: Vue.js
- Database: SQLite
- Containerization: Docker (for both backend and frontend)
- Authentication: JWT (JSON Web Tokens)
- /quiz-info: Get quiz information including total question count and participant scores.
- /rebuild-db: Rebuild the database (admin-only).
- /login: Login to receive a JWT token for admin access.
- Admin Login: Access the admin panel if logged in.
- Navigation: Navbar with dynamic login/logout state.
- Responsive UI: The UI adjusts based on whether the user is logged in.
To run this project, you need Docker installed on your machine. The project is containerized using Docker, which simplifies the setup and deployment process.
git clone https://github.com/yourusername/quiz-app.git
cd quiz-app
Make sure Docker is running, then execute the following command to build and start the services:
docker-compose up --build
This will:
- Build the quiz-api and quiz-ui containers.
- Run the API on port
5000
. - Serve the frontend UI on port
8080
.
- Backend API: The API will be available at http://localhost:5000.
- Frontend UI: The UI will be available at http://localhost:8080.
The Admin password is "AdminQuiz2024"
Postman collections were collected in order to add questions into the database and fully test the application.
GET Request: Fetches the quiz information such as the total number of questions and the list of participants and their scores.
Example response:
{
"size": 10,
"scores": [
{
"playerName": "John Doe",
"score": 85,
"date": "12/12/2024 14:30:00"
},
{
"playerName": "Jane Smith",
"score": 90,
"date": "12/12/2024 15:00:00"
}
]
}
POST Request: Rebuilds the database. Requires an Authorization
header with a valid JWT token.
POST Request: Authenticates the user and returns a JWT token if the password matches.
Example request body:
{
"password": "yourpassword"
}
- Install dependencies for the backend:
pip install -r requirements.txt
- Run the Flask app:
python app.py
- Install dependencies for the frontend:
npm install
- Run the Vue.js development server:
npm run serve
This will start the development server on http://localhost:8080.
The project uses Docker to containerize the application. The Dockerfile
for the backend (quiz-api
) and frontend (quiz-ui
) ensures that all dependencies are installed and the application is ready to run in any environment.
- quiz-api Dockerfile: Builds the Flask API, installs SQLite, and runs the application using Gunicorn.
- quiz-ui Dockerfile: Builds the Vue.js application and serves it using Nginx.
Feel free to open issues or submit pull requests to improve the project.
This project is licensed under the MIT License.