This project is a decentralized voting application built with a blockchain backend and a React frontend.
Before you begin, ensure you have the following installed:
- backend/: Contains the Flask backend a
- frontend/: Contains the React frontend.
- contracts/: Contains the Solidity smart contract.
git clone https://github.com/your-repo/voting-dapp.git
cd voting-dappNavigate to the backend directory and install Python dependencies:
cd backend
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txtNavigate to the frontend directory and install Node.js dependencies:
cd ../frontend
npm installNavigate to the contracts directory and compile the Solidity smart contract:
cd ../contracts
npx hardhat compileStart the Flask backend:
cd ../backend
.venv\Scripts\activate
python run.pyThe backend will be available at http://127.0.0.1:5000.
Start the React frontend:
cd ../frontend
npm startThe frontend will be available at http://localhost:3000.
To deploy the application using Docker: NB:you should start docker desktop if you are using windows
-
Build the Docker images:
docker-compose build
-
Start the containers:
docker-compose up
The application will be available at http://localhost:3000.
Run the backend tests:
cd backend
pytestRun the frontend tests:
cd frontend
npm testThis project uses GitHub Actions for continuous integration and deployment. The workflows are located in the .github/workflows/ directory and include:
- Backend Tests: Runs
pytestto ensure the Flask backend is functioning correctly. - Frontend Tests: Runs
npm testto validate the React frontend. - Smart Contract Compilation: Uses Hardhat to compile Solidity contracts.
Workflows are triggered automatically on:
- Push Events: When code is pushed to the repository.
- Pull Requests: When a pull request is opened or updated.
You can view the status of workflows in the "Actions" tab of the GitHub repository.