<palign="center">A progressive <ahref="http://nodejs.org"target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
<ahref="https://opencollective.com/nest#backer"target="_blank"><imgsrc="https://opencollective.com/nest/backers/badge.svg"alt="Backers on Open Collective"/></a>
<ahref="https://opencollective.com/nest#sponsor"target="_blank"><imgsrc="https://opencollective.com/nest/sponsors/badge.svg"alt="Sponsors on Open Collective"/></a>
<ahref="https://twitter.com/nestframework"target="_blank"><imgsrc="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"alt="Follow us on Twitter"></a>
</p>
<!--[](https://opencollective.com/nest#backer)
[](https://opencollective.com/nest#sponsor)-->
Backend API for a trading assistant platform built with NestJS, PostgreSQL, JWT authentication, RBAC, portfolio management, position tracking, and AI-assisted chat workflows.
## Compile and run the project
## Demo
```bash
# development
$ npm run start
- Public demo: https://tradingbot.anthony-jacob.com
tradingbot@demo.com / uCNWgUsDshBJd5y
# watch mode
$ npm run start:dev
- more information available at: https://blog.anthony-jacob.com/construire-un-bot-de-trading-ia-en-utilisant-un-simple-llm/
# production mode
$ npm run start:prod
```
## Run tests
## Main Features
```bash
# unit tests
$ npm run test
- JWT authentication with access/refresh tokens and session revocation
- Role-based access control (`ADMIN`, `USER`)
- User and role management
- Portfolio management with cash and holdings details
- Position open/close and position history tracking
- Settings management
- AI chat module for portfolio-oriented assistant workflows
- Scheduled jobs for automation
## Tech Stack
- NestJS 11
- TypeORM
- PostgreSQL
- Supertest for testing
- Docker / GitLab CI for publish and deploy pipeline
-`portfolios/` - portfolio CRUD and portfolio detail endpoints
-`positions/` - open/close positions
-`position-history/` - closed position history
-`chat/` - AI chat sessions/messages
-`cronjob/` - scheduled background tasks
## Requirements
- Node.js 22+
- npm 10+
- PostgreSQL 16+ (or compatible)
# e2e tests
$ npm run test:e2e
## Environment Variables
# test coverage
$ npm run test:cov
Create a `.env` file at project root.
Minimum required variables:
```env
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_PASS=postgres
DB_NAME=trading
JWT_SECRET=change-me
JWT_EXP_ACCESS=900
JWT_EXP_REFRESH=604800
PORT=3000
XAI_API_KEY=your_key_here
```
## Deployment
When you're ready to deploy your NestJS application to production, there are some key steps you can take to ensure it runs as efficiently as possible. Check out the [deployment documentation](https://docs.nestjs.com/deployment) for more information.
## Local Setup
If you are looking for a cloud-based platform to deploy your NestJS application, check out [Mau](https://mau.nestjs.com), our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps:
```bash
npm install
```
## Run the API
```bash
$ npm install-g @nestjs/mau
$ mau deploy
# development
npm run start:dev
# production build
npm run build
npm run start:prod
```
With Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure.
## Tests
## Resources
```bash
# unit tests
npm run test
Check out a few resources that may come in handy when working with NestJS:
# e2e tests (serial execution)
npm run test:e2e ----runInBand
- Visit the [NestJS Documentation](https://docs.nestjs.com) to learn more about the framework.
- For questions and support, please visit our [Discord channel](https://discord.gg/G7Qnnhy).
- To dive deeper and get more hands-on experience, check out our official video [courses](https://courses.nestjs.com/).
- Deploy your application to AWS with the help of [NestJS Mau](https://mau.nestjs.com) in just a few clicks.
- Visualize your application graph and interact with the NestJS application in real-time using [NestJS Devtools](https://devtools.nestjs.com).
- Need help with your project (part-time to full-time)? Check out our official [enterprise support](https://enterprise.nestjs.com).
- To stay in the loop and get updates, follow us on [X](https://x.com/nestframework) and [LinkedIn](https://linkedin.com/company/nestjs).
- Looking for a job, or have a job to offer? Check out our official [Jobs board](https://jobs.nestjs.com).
# coverage
npm run test:cov
```
## Support
## CI/CD
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).