6.1 KiB
Contributing to Perplexica
Hey there, thanks for deciding to contribute to Perplexica. Anything you help with will support the development of Perplexica and will make it better! This guide will help you get started with contributing to our project.
Table of Contents
- Prerequisites
- Project Structure
- Setting Up Your Environment
- Development Workflow
- Coding and Contribution Practices
- Making Contributions
- Coding Standards
- Reporting Issues
- Help and Support
Prerequisites
Before you begin, ensure you have the following installed:
- Git
- Node.js (version specified in the project's package.json)
- npm or yarn
- Docker and Docker Compose (if using the Docker setup)
Project Structure
Perplexica's design consists of two main domains:
- Frontend (
uidirectory): This is a Next.js application holding all user interface components. It's a self-contained environment that manages everything the user interacts with. - Backend (root and
srcdirectory): The backend logic is situated in thesrcfolder, but the root directory holds the mainpackage.jsonfor backend dependency management.
Setting Up Your Environment
Before diving into coding, setting up your local environment is key. You have two options: using Docker (recommended) or setting up without Docker.
Option 1: Using Docker (Recommended)
This method provides a consistent development environment with hot reloading.
-
Ensure Docker and Docker Compose are installed on your system.
-
Fork the repository on GitHub.
-
Clone your forked repository:
git clone https://github.com/your-username/perplexica.git cd perplexica -
Copy the sample configuration files:
cp sample.config.toml config.toml cp ui/.env.example ui/.env -
Edit
config.tomlandui/.envto add necessary configuration values. -
Build and start the development environment:
docker-compose -f docker-compose.dev.yaml up --build
The services will be available at:
- Frontend: http://localhost:3000
- Backend: http://localhost:3001
This setup includes hot reloading:
- Frontend code changes (in
uidirectory) are immediately reflected in the browser. - Backend code changes (in
srcdirectory) automatically restart the backend service. - Changes to
package.jsonin either root oruidirectory trigger an automatic rebuild.
Option 2: Without Docker
Backend Setup
- In the root directory, locate the
sample.config.tomlfile. - Rename it to
config.tomland fill in the necessary configuration fields specific to the backend. - Run
npm installto install dependencies. - Run
npm run db:pushto set up the local sqlite. - Use
npm run devto start the backend in development mode.
Frontend Setup
- Navigate to the
uifolder and repeat the process of renaming.env.exampleto.env, making sure to provide the frontend-specific variables. - Execute
npm installwithin theuidirectory to get the frontend dependencies ready. - Launch the frontend development server with
npm run dev.
Please note: While Docker configurations are present for setting up production environments, npm run dev is used for development purposes in the non-Docker setup.
Development Workflow
-
Create a new branch for your feature or bug fix:
git checkout -b feature/your-feature-name -
Make your changes in the appropriate directories (
srcfor backend,uifor frontend). -
Test your changes thoroughly.
-
Run the formatter:
npm run format:write -
Commit your changes with a descriptive commit message:
git commit -am "Add your commit message here" -
Push your branch to GitHub:
git push origin feature/your-feature-name -
Open a pull request on GitHub, describing your changes in detail.
Coding and Contribution Practices
Before committing changes:
- Ensure that your code functions correctly by thorough testing.
- Always run
npm run format:writeto format your code according to the project's coding standards. This helps maintain consistency and code quality. - Write clear, concise commit messages that explain the purpose of your changes.
- Keep your pull requests focused on a single feature or bug fix.
- Update documentation, including README.md and inline comments, if your changes affect the project's usage or setup.
We currently do not have a formal code of conduct, but it is in the works. In the meantime, please be mindful of how you engage with the project and its community. We expect all contributors to be respectful, inclusive, and professional in their interactions.
Making Contributions
- Fork the repository and create your branch from
main. - If you've added code that should be tested, add tests.
- Issue that pull request!
Coding Standards
- Follow the existing code style and structure.
- Write clear, commented code. Use JSDoc comments for functions and classes.
- Write clear, commented code.
- Ensure type safety by using TypeScript effectively.
- Write unit tests for new features when applicable.
Reporting Issues
If you find a bug or have a suggestion for improvement:
- Check if the issue already exists in the GitHub issue tracker.
- If not, create a new issue, providing as much detail as possible, including:
- A clear and descriptive title
- Steps to reproduce the issue
- Expected behavior
- Actual behavior
- Your environment (OS, browser, version, etc.)
- Any relevant screenshots or error messages
Help and Support
If you have any questions or feedback, please feel free to reach out to us. You can:
- Create an issue on GitHub for project-related questions.
We appreciate your contributions and look forward to your involvement in making Perplexica even better!