/cryptallion-backend

This repository houses the backend code for Cryptallion, a cryptocurrency portfolio tracker application. Utilizing Node.js and MongoDB

Primary LanguageJavaScript

Cryptallion Backend: Getting Started

This guide outlines the steps to set up and run the Cryptallion backend project effectively.

Prerequisites:

Installation:

  1. Clone the Repository:

    git clone https://github.com/your-username/cryptallion-backend.git
  2. Navigate to the Project Directory:

    cd cryptallion-backend
  3. Install Dependencies:

    npm install  # or yarn install

Environment Variables:

  • Create a file named .env in the project's root directory. This file should not be committed to version control.

  • Fill the .env file with the following variables, replacing the placeholders with your actual values:

    # Database
    DB_HOST=localhost  # Your MongoDB host address
    DB_PORT=27017      # MongoDB port (default: 27017)
    DB_DATABASE=cryptallion  # Your database name
    DB_USERNAME=your_username  # Your MongoDB username (if required)
    DB_PASSWORD=your_password  # Your MongoDB password (if required)
    
    # Server
    PORT=5000  # Port on which the server will run (default: 5000)
    
    # Node Environment
    NODE_ENV=development  # Set to 'production' for deployment (default: development)
    
    # Redis Server (optional)
    REDIS_URL=redis.cloud.redislabs.com  # Your Redis server URL (if using)
    REDIS_PASSWORD=your_password  # Your Redis password (if using)
    REDIS_PORT=19094  # Your Redis port (if using)
    
    # JWT Secret (for authentication)
    JWT_SECRET=your_secret_key  # A strong and unique secret key
    
    # File Storage Path (optional)
    FILES_PATH=/tmp/cryptallion  # Path for storing uploaded files
    
  • Important: Consider using a secure environment variable management tool like dotenv for managing sensitive information like passwords.

Running the Development Server:

  1. Start the MongoDB instance:

    Follow MongoDB's installation instructions to set up your MongoDB server and create the desired database (cryptallion in this case).

  2. Start the Server:

    npm run start-server  # or yarn start-server

    This will start the backend server, typically listening on port 5000 (as defined in .env). You can access the API at http://localhost:5000/ in your browser (depending on your API endpoints).

Deployment (Optional):

  1. Set NODE_ENV=production:

    In your deployment environment, ensure the NODE_ENV variable is set to production. This might involve environment variable configuration steps specific to your deployment platform.

  2. Build for Production (Optional):

    Some projects benefit from creating a production build to optimize the code for deployment. Consult your project's build instructions if applicable.

  3. Start the Server:

    The command to start the server in production mode might differ. Refer to your project's specific instructions.

Available Scripts:

  • npm lint or yarn lint: Runs the linter to check for code style and potential errors.
  • npm check-lint or yarn check-lint: Checks for lint errors in specifically numbered files (e.g., 1.js, 2.js).
  • npm start-server or yarn start-server: Starts the backend server in development mode.
  • npm start-worker or yarn start-worker: Starts any background workers for tasks like image processing (if applicable).
  • npm dev or yarn dev: Starts the server and any workers for development.
  • npm test or yarn test: Runs the test suite to ensure code quality.

Key Dependencies:

  • Express: The web framework used for building the server.
  • MongoDB: The NoSQL database used for data storage.
  • Redis: An in-memory data store used for caching and potentially for task queues.
  • Bcrypt: A password-hashing library for secure authentication.
  • JSON Web Tokens (JWT): A library for creating and verifying authentication tokens.
  • Image-Thumbnail: A library for generating image thumbnails (if applicable).
  • Bull: A library for handling background job queues (if applicable).

By following these steps and customizing them as needed, you should be able to successfully set up and run the Cryptallion backend project.