Skip to content

Framework for the Adversarial Machine Learning Challenge at CU Denver, showcasing techniques in AI model defense and attack.

License

Notifications You must be signed in to change notification settings

cudenver-ai/Adversarial-Machine-Learning

Repository files navigation

Adversarial Machine Learning Challenge - Production Branch

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.

Table of Contents


Before Contributing

Branching Strategy

  • 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).

Pull Requests

  • 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.

Prerequisites

  • Python: Version 3.10 or higher.
  • Node.js / npm: Node.js version 22 or higher. Use nvm for managing Node.js versions.
  • Git: For version control.

Setup and Development

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.


Running the Setup Script

  1. Clone the Repository:
git clone https://github.com/cudenver-ai/Adversarial-Machine-Learning
cd Adversarial-Machine-Learning
  1. 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.sh

This script will:

  • Set up nvm and 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.

Important Notes for the Setup Script:

  • Python Virtual Environment: If you prefer to use a standard Python virtual environment (.venv), ensure the venv section 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.
  1. 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
  1. Running Flask and React:

To start the Flask back-end:

flask run

To start the React front-end:

cd front-end
npm run dev

Deployment

For detailed deployment instructions, refer to production-server.md.


Documentation

  • Server Architecture: See /docs/Server.md for an overview.
  • Development Setup: See /docs/development-server.md for detailed instructions.
  • Production Deployment: See /docs/production-server.md for deployment steps.

Key Files

Front-End

  • src/App.jsx: Main entry point for the React app.
  • src/config.js: Contains global variables like API_BASE_URL.
  • .env.dev and .env.prod: Environment variable files.
  • package.json: Front-end dependencies and scripts.
  • vite.config.js: Vite configuration.

Back-End

  • app.py: Main Flask application file.
  • config.py: Environment-specific configurations.
  • .flaskenv: Environment variables for Flask.
  • requirements.txt: Python dependencies.

Additional Resources


Important Notes

  • Environment Variables:

    • Keep sensitive information out of version control.
    • Add .env* and .flaskenv to your .gitignore.
  • Switching Environments:

    • Development:
      • Use FLASK_DEBUG=1 in .flaskenv.
      • Run npm run dev for the front-end.
    • Production:
      • Set FLASK_DEBUG=0 or remove it.
      • Build the front-end with npm run build.
      • Deploy using Gunicorn and Nginx.
  • 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 install at 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.

About

Framework for the Adversarial Machine Learning Challenge at CU Denver, showcasing techniques in AI model defense and attack.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published