R6 Index is a player stats and analytics tool for Rainbow Six Siege. The project is a monorepo managed with Turborepo and PNPM workspaces and contains a simplified version of R6 Index's stats tool, that allows users to host and run their own stats tracker.
r6index-v2/
│
├── apps/ # Contains the main applications
│ ├── web/ # The Remix Web Application
│ └── profiler/ # Vercel serverless function
│
├── packages/ # Shared Packages
│ ├── configs/ # Shared configuration files (e.g., Ranked, Seasons)
│ ├── db/ # Database Client, Schema and Migrations
│ ├── shared-types/ # Shared types and interfaces
│ └── ubisoft-api-client/ # Ubisoft API Client
│
└── workers/ # Cloudflare Workers
├── auth/ # Auth Worker (Handles rolling ubisoft apiauthentication)
└── indexer/ # Indexer Worker (Consumer that processes batched profiles for indexing)
Prerequisites needed to run the project are the following:
- Supabase - PostgreSQL Database
- Cloudflare - Hosting, Workers, Queue, Durable Objects, and KV
- Vercel - Serverless Functions
- PNPM - Package Manager
- BiomeJS - Format and Lint
- Uplay - Ubisoft Uplay Account for API access
Clone repository, ensure PNPM is installed. Then, execute the following command in the root:
- Install the dependencies
pnpm install
- Set up environment variables
You will have to set up environment variables.
.dev.vars.example
files are provided in the following packages:
apps/web
workers/auth
workers/indexer
These files should be copied and renamed to .dev.vars
and the environment variables should be set accordingly if needed.
.env.local
and .env.production
files are provided in the packages/db
package. These files should be copied and renamed to .env.local
and .env.production
and the environment variables should be set accordingly if needed for the database.
- Run the setup script
This sets up a local supabase instance and seeds the database with initial data.
pnpm run setup
- Start the development server
pnpm run dev
Please ensure Installation steps were followed before hand and the project is set up correctly. You will also have to set up environment variables in different packages due to the way wrangler run the development environment.
.dev.vars.example
files are provided in the following packages:
apps/web
workers/auth
workers/indexer
These files should be copied and renamed to .dev.vars
and the environment variables should be set accordingly if needed.
.env.local
and .env.production
files are provided in the packages/db
package. These files should be copied and renamed to .env.local
and .env.production
and the environment variables should be set accordingly if needed for the database.
The development server can be started with the following command:
pnpm run dev
This will start the auth and indexer workers and the remix web application. The profiler serverless function will not be started as it is only used in a production environment. This was a stopgap measure due to Ubisoft's api blocking requests from cloudflare workers.
Again, please ensure Installation steps were followed before hand and the project is set up correctly. If not completed, initial migrations may not have been applied and no data will have been inserted.
To check if Supabase is running, you can use the following command:
pnpm run db:status
The development database can be started with the following command:
pnpm run db:start
This will start a local supabase instance and seed the database with initial data. The admin interface can be accessed at localhost:54323/
.
Once you are done with development, you can stop the database with the following command:
pnpm run db:stop
The production environment is managed by Vercel and Cloudflare. The Remix web application is hosted on Cloudflare Pages, the profiler serverless function is hosted on Vercel, and the workers are hosted on Cloudflare Workers. Additionally, Cloudflare KV, Durable Objects, and Queue are used to store and manage events and data.
Github Actions are provided to deploy changes automatically to the production environment. To use this, you will need to set up the following secrets in your repository:
CLOUDFLARE_ACCOUNT_ID
CLOUDFLARE_API_AW_TOKEN
SUPABASE_URL
UBISOFT_APPID
UBISOFT_CLIENT_ID_{n}
UBISOFT_CLIENT_PASSWORD_{n}
UBISOFT_NEWAPPID
UBISOFT_URL
UBISOFT_USERAGENT
VERCEL_TOKEN
The use of Vercel Functions: Frustratingly, this was a stopgap measure due to Ubisoft's api blocking requests from cloudflare workers. This is not ideal and should be replaced with an alternative solution if serious about using this project.
Rate Limiting: The project does not include rate limiting, this should be added if serious about using this project.
- Responsive Issues on Smaller Screens (1023px and below)
- Ubisoft blocks CF workers on certain api endpoints
- Profile Button on /profile/maps, /profile/operators etc. missing
- Pill in AnimatedTabs may not show up on initial render
- Search Menu Profiles may not show up on initial render