|
| 1 | +# Contributing to Mu2Mi |
| 2 | + |
| 3 | +Mu2Mi welcomes contributions from the community. There are many ways to get involved! |
| 4 | + |
| 5 | +## Provide Feedback |
| 6 | + |
| 7 | +You might find things that can be improved while you are using Mu2Mi. You can help by [submitting an issue](https://github.com/FelixNgFender/Mu2Mi/issues/new) when: |
| 8 | + |
| 9 | +- Mu2Mi crashes, or you encounter a bug that can only be resolved by refreshing the browser. |
| 10 | +- An error occurs that is unrecoverable, causes data integrity problems or loss, or generally prevents you from using Mu2Mi. |
| 11 | +- A new feature or an enhancement to an existing feature will improve the utility or usability of Mu2Mi. |
| 12 | + |
| 13 | +Before creating a new issue, please confirm that an existing issue doesn't already exist. |
| 14 | + |
| 15 | +## Participate in the Community |
| 16 | + |
| 17 | +You can engage with the community by: |
| 18 | + |
| 19 | +- Helping other users on [Discord](https://discord.gg/7BkTD7RNRG). |
| 20 | +- Improving documentation |
| 21 | +- Participating in general discussions about open source, music, and AI |
| 22 | +- Authoring new Mu2Mi features |
| 23 | + |
| 24 | +## Contributing Code |
| 25 | + |
| 26 | +You can contribute to Mu2Mi by: |
| 27 | + |
| 28 | +- Enhancing current functionality |
| 29 | +- Fixing bugs |
| 30 | +- Adding new features and capabilities |
| 31 | + |
| 32 | +Before starting your contribution, especially for core features, I encourage you to reach out to me on [Discord](https://discord.gg/7BkTD7RNRG). This allows me to ensure that your proposed feature aligns with the project's roadmap and goals. Developers are the key to making Mu2Mi the best tool it can be, and I value input from the community. |
| 33 | + |
| 34 | +I look forward to working with you to improve Mu2Mi. |
| 35 | + |
| 36 | +### Steps to Contribute Code |
| 37 | + |
| 38 | +Follow the following steps to ensure your contribution goes smoothly. |
| 39 | + |
| 40 | +1. Fork the repository to your GitHub account. |
| 41 | +2. Clone the forked repository to your local machine. |
| 42 | +3. Create a new branch for your feature or bug fix. |
| 43 | +4. Commit your changes to your branch. |
| 44 | +5. Push your changes to your fork on GitHub. |
| 45 | +6. Create a pull request to the main repository. |
| 46 | +7. Wait for the maintainers to review your pull request. |
| 47 | +8. Make any necessary changes to your pull request. |
| 48 | +9. Once your pull request is approved, it will be merged into the main repository. |
| 49 | +10. Celebrate your contribution to Mu2Mi! |
| 50 | + |
| 51 | +### Development Environment |
| 52 | + |
| 53 | +#### Prerequisites |
| 54 | + |
| 55 | +- Node.js v21.6.1 |
| 56 | +- Docker |
| 57 | +- Docker Compose |
| 58 | + |
| 59 | +#### Setting Up Your Development Environment |
| 60 | + |
| 61 | +Mu2Mi is built with Next.js, PostgreSQL, Minio, and Redis. The development environment is orchestrated with Docker Compose. To set up your development environment: |
| 62 | + |
| 63 | +1. Have the required dependencies installed on your machine and the repository cloned. |
| 64 | +2. Create a `.env` file in the root directory of the project. Use the `.env.example` file as a template and fill out the values required. The `.env.example` file has some default values that you can use. Rate limiting, captcha, email, and analytics are disabled by default in development. You can view the [environment variable schema](src/config/env.ts) to see which are required for booting up the Next.js server. |
| 65 | + |
| 66 | +```bash |
| 67 | +cp .env.example .env |
| 68 | +``` |
| 69 | + |
| 70 | +3. Run `make up` to start the development environment. *Quick tip: The `Makefile` and `compose.yaml` files are used to manage the development environment and contain other useful commands*. |
| 71 | +4. Run `npm i` to install the project dependencies. |
| 72 | +5. Run `npm run dev` to start the development server. |
| 73 | +6. Visit `http://localhost:3000` in your browser to view the application. |
| 74 | +7. Run `make down` to stop the development environment. |
| 75 | +8. (Optional) Run `make clean` to remove all persistent Docker volumes and images. |
| 76 | + |
| 77 | +#### Testing Track Processing Functionality |
| 78 | + |
| 79 | +To test out track processing functionality that uses Replicate service, you will need to have Replicate API token and webhook secret, which can be generated in your Replicate account settings, configured as environment variables in your `.env` file. And you will also need to set up tunnels using either [ngrok](https://ngrok.com/) or [localtunnel](https://localtunnel.github.io/www/). The two tunnels needed should be set up for the following ports: |
| 80 | + |
| 81 | +- 3000 (Next.js) |
| 82 | +- 9000 (Minio) |
| 83 | + |
| 84 | +Once the tunnels are set up, update these variables in your `.env`: |
| 85 | + |
| 86 | +- `PROTOCOL` to `https` |
| 87 | +- `HOST` to the Next.js tunnel URL |
| 88 | +- `APP_PORT` to `443` for `https` connection |
| 89 | +- `S3_ENDPOINT` to the Minio tunnel URL |
| 90 | +- `S3_PORT` to `443` for `https` connection |
| 91 | +- `S3_USE_SSL` to `true` for `https` connection |
| 92 | + |
| 93 | +You may also need to restart the Next.js server to apply the changes. |
| 94 | + |
| 95 | +### Codebase Overview |
| 96 | + |
| 97 | +#### Data Access Layer |
| 98 | + |
| 99 | +Exported functions in the `src/models` directory are ready to be consumed in Route Handlers, Server Actions, and Server Components. They act as a data access layer and interact with the database. |
| 100 | + |
| 101 | +#### Data Fetching and Mutation |
| 102 | + |
| 103 | +Server Components get their data from queries in `queries.ts` files, re-export queries from `actions.ts` to get them inside the `'use server'` boundary, which enables the use of `useQuery` and `useMutation` hooks in Client Components. Route Handlers should be wrapped with `withErrorHandling` in [the error module](src/lib/error.ts) to handle errors. |
| 104 | + |
| 105 | +Server Actions in `actions.ts` files. Server Actions should be wrapped with either `action` or `authAction` in [the safe-action module](src/lib/safe-action.ts) to handle errors and add the current user and session to the context. |
0 commit comments