This project is a Dockerized Python application that uses Flask and RPi.GPIO (for Raspberry Pi GPIO control) for its functionality. Additionally, it features a React-based frontend for an improved user interface. The project has been containerized using Docker and Docker Compose to make deployment and development easy and consistent across different environments.
The project is divided into two main components:
- Backend: A Flask-based Python application that handles GPIO control and serves the API endpoints.
- Frontend: A React-based user interface to interact with the backend.
To get started with this project, you'll need Docker and Docker Compose installed on your system. If you haven't installed Docker yet, please follow the instructions at Docker's official website.
Additionally, make sure you have Docker Compose installed. If you're using Docker Desktop, it comes with Docker Compose preinstalled.
git clone https://github.com/norbraet/Memory.git
cd Memory
Using NVM is highly recommended for managing Node.js versions locally, ensuring consistency across different environments.
- Visit the official GitHub page for nvm-windows.
- Download the latest nvm-setup.zip and follow the installation instructions.
- Before installing Node.js, check the
.nvmrcfile located in thefrontendfolder. This file specifies the Node.js version required for the project.
Replace <Node Version> with the version specified in .nvmrc.
nvm install <Node Version>
To verify that NVM is installed, run:
nvm --version
After installing the correct Node Version, navigate to the frontend folder and execute:
nvm use <Node Version>
To install NVM on macOS, follow these steps:
- Install NVM using Homebrew:
brew install nvm
- Verify that NVM was successfully installed:
nvm --version
- Navigate to the
frontendfolder and execute:
nvm use
This command will automatically use the Node.js version specified in the .nvmrc file.
Docker Compose is used to manage multiple containers for this project. It helps define and run multi-container Docker applications, which makes it easier to manage this application and its dependencies.
To start the application, run the following command:
docker compose up
This will:
- Start the backend on http://localhost:5000
- Start the frontend on http://localhost:3000
The actual port is defined in the .env at the root directory.
To stop the application, use:
docker compose down
If you want to run the application in the background (detached mode), use:
docker compose up -d
The application uses Python's built-in logging module to log important information, including setup and status updates for GPIO channels, events, and errors. The log level is configurable via the LOG_LEVEL environment variable.
By default, logs are displayed on the console. You can customize the logging level as needed to see more or less detail during development.
Husky is set up to run pre-commit hooks, including Commitlint to validate commit messages and Lint-staged to automatically format files before committing.
To install Husky and Commitlint locally, run at the root level:
npm install
This will set up the pre-commit hooks and install necessary dependencies.
Commit messages must follow the Conventional Commits format. Any commit message that does not follow this format will be rejected by Commitlint.
Lint-staged ensures that Prettier is run on all staged files that are frontend-related (i.e., .js, .jsx, .ts, .tsx files). This will format your code before committing, ensuring consistent code style across the project.