- Brainwave Website: http://localhost:8000
- Brainwave API Documentation:
- Swagger:
- Redoc:
- Setup editorconfig, ruff and ESLint in the text editor you will use to develop.
- Run
make setup
. This will set up some required files for you
- Open the
backend/.env
file on a text editor and uncomment the lineDATABASE_URL=postgres://brainwave:password@db:5432/brainwave
- Open a new command line window and go to the project's directory
- Run the initial setup:
make docker_setup
- Create the migrations for
users
app:
make docker_makemigrations
- Run the migrations:
make docker_migrate
- Run the project:
make docker_up
- Access
http://localhost:8000
on your browser and the project should be running there - To access the logs for each service, run:
make docker_logs <service name>
(eitherbackend
,frontend
, etc). Leave<service name>
blank to access all logs - To stop the project, run:
make docker_down
- Open a new command line window and go to the project's directory
- Update the dependencies management files by performing any number of the following steps:
- To add a new frontend dependency, run
make docker_frontend
to open an interactive shell and then runnpm install <package name> --save
to add the dependencyThe above command will update your
package.json
, but won't make the change effective inside the container yet - To add a new backend dependency, run
make docker_backend
to open an interactive shell and then runpoetry add {dependency}
to add the dependency. If the dependency should be only available for development user append-G dev
to the command.The above command will update your
pyproject.toml
, but won't make the change effective inside the container yet - After updating the desired file(s), run
make docker_update_dependencies
to update the containers with the new dependenciesThe above command will stop and re-build the containers in order to make the new dependencies effective
- To add a new frontend dependency, run
- Open a new command line window and go to the project's directory
npm install
npm run dev
- This is used to serve the frontend assets to be consumed by django-webpack-loader and not to run the React application as usual, so don't worry if you try to check what's running on port 3000 and see an error on your browser
- Open the
backend/.env
file on a text editor and uncomment the lineDATABASE_URL=sqlite:///backend/db.sqlite3
- Open a new command line window and go to the project's directory
- Run
poetry install
- Go to the
backend
directory - Create the migrations for
users
app:poetry run python manage.py makemigrations
- Run the migrations:
poetry run python manage.py migrate
- Run the project:
poetry run python manage.py runserver
- Open a browser and go to
http://localhost:8000
to see the project running
(This isn't needed for now)
poetry run celery --app=myproject worker --loglevel=info
make test
or make docker_test
(depending on if you are using docker or not)
You may pass a path to the desired test module in the make command. E.g.:
make test someapp.tests.test_views
To add a new backend dependency, run poetry add {dependency}
. If the dependency should be only available for development user append -G dev
to the command.
- At pre-commit time (see below)
- Manually with
poetry run ruff
andnpm run lint
on project root. - During development with an editor compatible with ruff and ESLint.
- If you are NOT using Docker: On project root, run
poetry run pre-commit install
to enable the hook into your git repo. - Using Docker?
- You'll need to install pre-commit yourself
- On project root, run
pre-commit install --config .pre-commit-config-docker.yaml
to enable the hook into your git repo.
The hook will run automatically for each commit.
- I'm getting
Permission Denied
errors from Docker when trying to write to a file
Your user ID and Docker's user ID (
1000
) might be mismatched. Try puttingUGID=<USER_ID>:<GROUP_ID>
in.env
within your project directory. You can find both IDs by runningid -a
on the command line.