This guide will help you set up and run the Trading Bot project, including installing dependencies, running the PostgreSQL database using Docker, and initializing the database schema.
- Docker installed on your system
- Docker Compose installed
- Node.js >= 20.17 && <21 and npm installed
-
Clone this repository:
git clone https://github.com/Tech-Expansion/tex-trading-bot-poc.git cd tex-trading-bot-poc -
Install dependencies:
npm install
-
Start the PostgreSQL database with Docker Compose:
docker-compose up -d
This will start a PostgreSQL container named
trading_bot_dbwith the following credentials:- User:
admin - Password:
admin123 - Database:
trading_bot
- User:
-
Verify that the database is running:
docker ps
You should see a running container named
trading_bot_db.
To create the required tables using Prisma migrations, follow these steps:
-
Ensure the database container is running.
-
Run the following command to apply migrations:
npx prisma migrate dev --name init
This will initialize the database schema as defined in
prisma/schema.prisma.
If you update the prisma/schema.prisma file and need to apply changes to the database, follow these steps:
-
Generate a new migration:
npx prisma migrate dev --name init
-
If you need to reset the database and reapply migrations:
npx prisma migrate reset
Warning: This will delete all data in the database.
-
If you only want to update the Prisma Client without applying migrations, run:
npx prisma generate
Once the database is set up, you can start the bot.
-
Set up the environment variables:
cp .env.example .env
Update
.envwith the correct database connection string:DATABASE_URL=postgresql://admin:admin123@localhost:5433/trading_bot -
Run the bot:
npm run dev
To stop the database container, run:
docker-compose downThis will stop and remove the container but keep the database volume.
If you want to remove all data and start fresh, remove the volume:
docker-compose down -vNow your trading bot is ready to use! 🚀