This project displays real-time and historical statistics for the CKPool Bitcoin mining pool using data from their API.
- Real-time pool statistics
- Historical data chart
- Responsive design with themed display
- Next.js
- Tailwind CSS
- daisyUI
- Recharts
- Clone the repository
- Install dependencies:
pnpm install
- Set up the environment variables in
.env
- Run database migrations:
pnpm prisma:migrate
- Seed the database:
pnpm seed
- Start the development server:
pnpm dev
DATABASE_URL="postgresql://username:password@server:port/your_database_name"
SHADOW_DATABASE_URL="postgresql://username:password@server:port/your_shadow_database_name"
API_URL="https://solo.ckpool.org"
Replace username
, password
, server
, port
, your_database_name
, and your_shadow_database_name
with your actual PostgreSQL credentials, server details, and database names.
The shadow database is used by Prisma for database migrations in environments where creating tables or modifying the schema of the main database is not possible during development. It's a temporary database that mimics your main database structure.
If you're working in a development environment or have full control over your database, you can use the same database for both DATABASE_URL
and SHADOW_DATABASE_URL
. In this case, your .env
file would look like this:
DATABASE_URL="postgresql://username:password@server:port/your_database_name"
SHADOW_DATABASE_URL="postgresql://username:password@server:port/your_database_name"
API_URL="https://solo.ckpool.org"
This configuration uses the same database for both the main application and Prisma migrations.
- Clone the repository (git clone https://github.com/mrv777/ckstats.git)
- Install pnpm:
curl -fsSL https://get.pnpm.io/install.sh | bash
- Install packages if needed:
sudo apt install postgresql postgresql-contrib nodejs nginx
- Go to the directory:
cd ckstats
- Install dependencies:
pnpm install
- Set up the environment variables in
.env
- Example:
DATABASE_URL="postgres://postgres:password@localhost:5432/postgres"
SHADOW_DATABASE_URL="postgres://postgres:password@localhost:5432/postgres"
API_URL=https://solo.ckpool.org
-
Build the application:
pnpm build
-
Start the production server:
pnpm start
-
Set up cronjobs for regular updates:
- Open the crontab editor:
crontab -e
- Add the following lines (for example, every 1 minute updates with old data cleanup every 12 hours and vacuum every day at 01:05):
*/1 * * * * cd /path/to/your/project && /usr/local/bin/pnpm seed */1 * * * * cd /path/to/your/project && /usr/local/bin/pnpm update-users 5 */2 * * * cd /path/to/your/project && /usr/local/bin/pnpm cleanup 5 1 * * * cd /path/to/your/project && /usr/local/bin/pnpm vacuum
- Save and exit the editor
These cronjobs will run the
seed
andupdate-users
scripts every 10 minutes to populate the database and clean up old statistics every 12 hours. - Open the crontab editor:
pnpm dev
: Start the development serverpnpm build
: Build the production applicationpnpm start
: Start the production serverpnpm lint
: Run ESLintpnpm lint:fix
: Run ESLint and fix issuespnpm prisma:generate
: Generate Prisma clientpnpm prisma:migrate
: Run database migrationspnpm seed
: Save/Update pool stats to databasepnpm update-stats
: Update pool statistics #Currently not usedpnpm update-users
: Update user and worker informationpnpm cleanup
: Clean up old statisticspnpm vacuum
: Optimize the SQLite databasepnpm test
: Run testspnpm test:watch
: Run tests in watch mode
GPL-3.0 license