This is the backend API for the Elite Farmers Website and the Elite Discord Bot.
API Spec: https://api.elitebot.dev/
API TOS: https://elitebot.dev/apiterms
The production API (api.elitebot.dev) should never be used for your own projects without permission. Please run your own instance of the API for that or use something else. This is neither a Mojang API nor a Hypixel API proxy.
We are not affiliated with Mojang or Hypixel in any way.
Contributions are welcome!
- .NET 8.0 SDK
- Docker (unless you run the other services some other way)
- A Discord Application and Bot Token
- A Hypixel API Key
- Recommended: JetBrains Rider or Visual Studio
- New features should only be added if they are relevant and useful to the Website or the Discord Bot.
- Feel free to open an issue or join the Discord to discuss the feature before starting work on it!
- This generally means that new features should be related to farming in Hypixel Skyblock, or the Elite Farmers community.
- Code should follow the existing style and conventions.
- I am aware the project structure isn't perfect and steps should be taken to improve it, but please don't try to change everything without discussing it first.
- Run the tests before submitting a PR, and please consider adding tests for new features.
- Clone the repository
- Make a copy of
EliteAPI/.env.example
and rename it to.env
in the same directory. Then fill in the environment variables in your new file. - Make a copy of
EliteAPI/appsettings.json
and rename it toappsettings.Development.json
in the same directory. - Fill in at least the database connection string in the
appsettings.Development.json
file, but it should work with the default settings if using the provideddocker-compose
file locally. - Start up the database and redis server using
docker compose up -d database cache
in the root directory of the repository. The other services are usually not needed for local development. - Open the solution in JetBrains Rider, Visual Studio, or use the
dotnet
cli to run the API. - The API should now be running on
http://localhost:5164/
.
- Follow the steps above to run the API locally.
- Follow the instructions in the Website or the Discord Bot repos to set them up.
- Fill in the
ELITE_API_URL
environment variable in the Website or Bot with http://localhost:5164/. - The Website and Bot should now be using your local API.
When making changes to responses or adding new endpoints, download the API spec (http://localhost:5164/v1/swagger.json) and run pnpm run generate-api-types
in the bot/website to update the typings.
Please discuss any changes to the database schema in an issue or on Discord before spending the time doing so.
- Make the changes to the
EliteAPI/Models/Entities
and related DTO mappings. - Run the EF Core migrations to generate a new migration into the
EliteAPI/Data/Migrations
folder. - If you are adding a new table, make sure to add a new
DbSet
to theEliteAPI/Data/DataContext.cs
file. - Don't add multiple migrations for the same PR unless absolutely necessary. It should be easy for you to revert the migration and generate a new one with all the changes.
- Keeping migrations uncommited until the PR is ready for review is a good idea to avoid committing and removing multiple migrations.
- Migrations are run automatically when the API starts up. (I am aware this is not ideal for production, but it's fine for development.)
If you need to test admin features, currently you can only do so by manually adding an admin role to yourself from the database.
- Run the API and Website locally.
- Login to the local Website instance with your Discord account.
- Use a tool like PGAdmin to connect to the local database.
- Create a new record in the
AspNetUserRoles
table with yourUserId
and theRoleId
of the admin role. - Log out and back in to the Website.
- You can now access the admin features, including granting other users roles on the
/admin
page of the Website.
- Clone the repository
- Make a copy of
.env.example
and rename it to.env
in the same directory. Then fill in the environment variables in your new file. These variables are used in the containers. - Make a copy of
EliteAPI/.env.example
and rename it to.env
in the same directory. Then fill in the environment variables in your new file. - Make a copy of
EliteAPI/appsettings.json
and rename it toappsettings.Development.json
in the same directory. - Fill in at least the database connection string in the
appsettings.Development.json
file, but it should work with the default settings if using the provideddocker-compose
file locally. - Run
docker compose up
in the root directory of the repository. - The API should now be running on
http://localhost:7008/
and can be put behind a reverse proxy if needed.