Welcome to the Adversarial Machine Learning Challenge project! This repository contains the codebase for both the back-end (Flask API) and front-end (React with Vite) applications.
- Before Contributing
- Setup and Development
- Deployment
- Documentation
- Key Files
- Additional Resources
- Important Notes
- Contact Information
- Create Separate Branches: Always create a separate branch for your changes.
- No Direct Push to Main: Never push your changes directly to the main branch.
- Branch Naming: Use descriptive names (e.g.,
feature-login-page,bugfix-api-endpoint).
- Mandatory Pull Requests: All changes must go through a pull request.
- Review and Approval: Pull requests must be reviewed and approved by at least one other team member.
- Communication: Feel free to ask questions or seek clarification.
- Python: Version 3.10 or higher.
- Node.js / npm: Node.js version 22 or higher.
Use
nvmfor managing Node.js versions. - Git: For version control.
Important Note: Before running the back-end, make sure to update the path variable in back-end/app.py to point to the directory on your machine where the data files (e.g., TeamData.json, challenge.json) are stored.
For example:
Unix/Linux: Update path like this:
path = "/path/to/your/directory/back-end/"Windows: Update path to your directory:
path = "C:/path/to/your/directory/back-end/"Without updating this path, the API routes won't be able to find and load the necessary data files for the app to function correctly.
- Clone the Repository:
git clone https://github.com/cudenver-ai/Adversarial-Machine-Learning
cd Adversarial-Machine-Learning- Run the Setup Script:
You can now set up both the back-end and front-end automatically using the provided setup.sh script. Depending on whether you are using Anaconda or a Python virtual environment, you'll need to comment or uncomment certain parts of the script.
./setup.shThis script will:
- Set up
nvmand install Node.js version 22. - Install front-end and back-end dependencies.
- Set up a Python environment (either Anaconda or virtual environment)
- Install Python dependencies.
- Python Virtual Environment: If you prefer to use a standard Python virtual environment (
.venv), ensure thevenvsection is uncommented and the Anaconda section is commented in the setup.sh script. - Anaconda Environment: If you are using Anaconda, ensure the Anaconda setup section is uncommented and the venv section is commented.
- Activate Virtual Environment:
After running the script, you can activate the virtual environment:
source .venv/bin/activate # On Unix/Linux
# Or for Windows:
.venv\Scripts\activate- Running Flask and React:
To start the Flask back-end:
flask runTo start the React front-end:
cd front-end
npm run devFor detailed deployment instructions, refer to production-server.md.
- Server Architecture: See
/docs/Server.mdfor an overview. - Development Setup: See
/docs/development-server.mdfor detailed instructions. - Production Deployment: See
/docs/production-server.mdfor deployment steps.
src/App.jsx: Main entry point for the React app.src/config.js: Contains global variables likeAPI_BASE_URL..env.devand.env.prod: Environment variable files.package.json: Front-end dependencies and scripts.vite.config.js: Vite configuration.
app.py: Main Flask application file.config.py: Environment-specific configurations..flaskenv: Environment variables for Flask.requirements.txt: Python dependencies.
- Python:
- Node.js and npm:
- Frameworks and Libraries:
- Deployment Tools:
-
Environment Variables:
- Keep sensitive information out of version control.
- Add
.env*and.flaskenvto your.gitignore.
-
Switching Environments:
- Development:
- Use
FLASK_DEBUG=1in.flaskenv. - Run
npm run devfor the front-end.
- Use
- Production:
- Set
FLASK_DEBUG=0or remove it. - Build the front-end with
npm run build. - Deploy using Gunicorn and Nginx.
- Set
- Development:
-
Code Formatting:
- Prettier is set up to format code on each commit via Husky and lint-staged.
- Configure your editor to format on save for a better development experience.
-
Team Collaboration:
- Document changes and use comments within configuration files to guide team members.
- Ensure all team members run
npm installat the root to set up Husky and lint-staged.
-
Testing:
- Always test both development and production setups after making changes.
By following this README and the accompanying documentation, you should be able to set up, develop, and deploy the application. Please let me know if you encounter any issues.