Skip to content

TraderCharts/trader-charts-backend

Repository files navigation

Trader Charts

Trader Charts is a tool for performing technical analysis with interactive charts. It allows users to visualize stock data or other asset data depending on what the data providers supply, and to apply technical indicators to analyze price trends

* One charting tool to rule them all *

Node.js Express Babel MongoDB Sequelize PostgreSQL MySQL MariaDB SQLite MSSQL Mocha Dotenv CORS Luxon Winston Morgan ESLint Prettier License


Trader Charts Backend - Overview

The Backend handles API requests, processes data, and serves chart information to the frontend.
Built with Node.js, Express, Babel, MongoDB, and PostgreSQL via Sequelize, it acts as the bridge between the data collector and the frontend.
See frontend β†’ | See data collector β†’


πŸš€ Want to contribute?

We welcome collaborators who wish to contribute and help enhance this trading tool. Feel free to reach out to the maintainers to get involved.


Project Structure

⚠️ Important: Make sure you follow the existing project structure

  • /src
    • /adapters: data access layer (DBs, APIs, external services)
    • /controllers: Express routes, organized by module
    • /fixtures: mock or fixture data
    • _/managers: business logic layer β€” sits between controllers and adapters, handling data processing and coordination
  • /assets: static public assets (images, CSS, client JS)
  • /config: configuration files
  • /docs: API and documentation files
  • /scripts: helper or automation scripts
  • /scripts/install: setup/installation scripts
  • /tests: test files

Installing project

Trader Charts Project is based on Nodejs, and use Sequelize to be able to connect to a PostgreSQL database.

It supports several database connections, SQL and mongodb, local and cloud databases.

  1. Install dependencies

    $ npm ci
    

Roadmap πŸ›€οΈ

Included features

  • Adding AppRouter
  • Adding UploadRouter
  • Adding PhotoRouter
  • Adding UsersRouter
  • Adding NegotiableInstrumentTypesRouter
  • Adding IndicatorsRouter
  • Adding AlertConditionExpressionsRouter
  • Adding AlertConditionOperationsRouter
  • Adding NegotiableInstrumentsRouter
  • Adding BymaStocksDataRouter
  • Adding AlertsTargetNegotiableInstrumentsRouter
  • Adding API UI Endpoints
  • Adding API Documentation
  • Add SQL logger
  • Adding RssFeedsDataRouter, including sentiment analysis and topics
  • Add Application logger
  • Adding HTTP Requests logger
  • Adding Code Validation & Linting
  • Adding Code Auto-Formatting

Database Connections

This project supports SQL and MongoDB databases.
To use them, you must either install the database locally or use a cloud solution like MongoDB Atlas or AWS.
After that, configure the required environment variables.

Environments

There are three environments: development, development with fixtures, and production.

  1. Development with Mocked Database
    You just need to create an empty database. All tables and basic example data will be automatically installed at runtime.
    To run the mocked database environment:

    npm run start-mock
    
  2. Development
    Database tables and structure will be created automatically. No fixture data will be inserted.
    To run the development environment:

    npm run start-dev
    
  3. Production
    No data is set up automatically. You must create all tables and insert data manually.
    To run the production environment:

    npm run start
    

API

You can interact with the API using tools like Postman, or via Trader Charts API. We use Swagger for testing API endpoints and generating the API specification, and Redoc for a clean, readable API documentation.

1. Generate the API client

Before using the API, run the following command to generate the necessary Swagger API files:

npm run generate-swagger-api

2. Access the API

Testing the API

There are three main options for testing the project:

  1. Access the Trader Charts API and make API calls directly using the "Execute" feature in the API Endpoints.
  2. Run Postman or any other similar tool for making calls.
  3. Run Frontend to test the integration with the project

2. Update the API Documentation

⚠️ Important: When adding new endpoints, make sure to update the corresponding endpoint files and verify that all previous endpoints are still available in the documentation

Generate Runtime Documentation

  1. Run the following command to generate documentation including all new endpoints:
npm run generate-swagger-api
  1. Copy the runtime files only after verifying your endpoints locally. This is crucial to ensure the schemas appear correctly in Redoc.

  2. After testing, replace the default specification files with the runtime versions by renaming them:

  • Rename swagger_runtime.json to swagger_default.json (overwrites the default file)
  • Rename swagger_runtime_v3.json to swagger_default_v3.json (overwrites the default file)

Required Env Variables

🧩 Common Variables

These variables are shared across all environments.

πŸ“ Note: You only need to include the variables for the database you are using (SQL or MongoDB).

SQL Database (only if using SQL)

    DB_HOST=[string]
    DB_NAME=[string]
    DB_PORT=[number]
    DB_USER=[string]
    DB_PASS=[string]
    DB_SSL=true

MongoDB (only if using MongoDB)

    DB_DIALECT=mongodb        # Use MongoDB instead of SQL ['mongodb', 'sql]
    ATLAS_URI=[string]      # MongoDB Atlas cloud URI
    MONGODB_URI=[string]    # Local/other MongoDB URI

πŸ§ͺ Development

Create .env.development.local file:

    # + include all common variables

πŸš€ Production

Create .env.production file:

    NODE_PATH=./src
    NODE_ENV='production'
    # + include all common variables

Contributors ✨

Thanks goes to these wonderful people:

gonzalo
Gonzalo