Skip to content

A stock tracker app for managing portfolios, tracking trades, and accessing real-time stock data.

Notifications You must be signed in to change notification settings

shaepy/moneymoo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

moneymoo

Test Credentials
Username: testuser
Password: password
Screenshot 2025-07-15 at 8 11 03 PM

Overview

Moneymoo is a full-stack web application designed to help investors and traders:

  • Manage and organize investment portfolios
  • Log trade history and track unrealized gains/losses
  • Search real-time stock prices and company financial data
  • Add stocks to a personalized watchlist for quick access

Built with the MEN stack (MongoDB, Express, Node.js) and integrated with stock market APIs for real-time market data, moneymoo delivers accurate, up-to-date financial insights in an intuitive interface with session-based authentication.

signed in homepage portfolio page browse market page stock page

Technology Stack

  • Back-end: Node.js, MongoDB (with Mongoose), Express.js
  • Front-end: HTML5, CSS, Bulma, JavaScript, EJS
  • Tools: Notion, Figma, Postman, Compass

APIs


Features

  • Portfolio Management • Add, edit, and remove stock positions to build and manage multiple investment portfolios.
  • Trade Logging & History • Record trades with purchase price, quantity, and dates to track unrealized gains/losses over time.
  • Real-Time Market Data • Search for tickers and access up-to-date stock prices and key company financials through integrated APIs.
  • Watchlist • Create and monitor a personalized watchlist of stocks for quick reference.
  • Trending Stocks • Browse a curated list of popular and trending tickers to explore new opportunities.
  • User-Friendly Insights • View portfolio performance at a glance, with clear calculations for cost basis and profit/loss.

Planning Phase

My project management was done through Notion, utilizing a Kanban board for development. MVP stories were turned into tasks on the board, with any bugs or additional tickets being added to the backlog during the development phase.

Wireframes

portfolio-trade-mock watchlist-1-mock dashboard-mock

Entity Relationship Diagram (ERD)

After writing my MVP user stories, I focused on the data structure and determining the database relationships for my app. We were instructed to incorporate both reference and embedded subdocument relationships, which influenced how I structured the models. The User model includes arrays for portfolios and watchlists, holding references to portfolioIds and watchlistIds.

I chose to create separate models for Stock and Trade: Stock is referenced in multiple places (like portfolios and watchlists), ensuring a single source of truth. Whereas Trade is a model to handle the large volume of trades each user may have, referencing both portfolioId and userId for easy querying. Portfolios and watchlists are also models, as a user can have many of each, with portfolios containing trade references and embedded userStocks, which reference individual stocks but also store portfolio-specific data.

entity relationship diagram

Researched APIs

During the planning phase, I researched several external APIs to integrate into the app by evaluating their pricing options and call limits. I preferred free services but decided to pay for a single month's subscription to Financial Modeling Prep to test with higher API limits. I used Alpaca Markets for real-time stock data and bar charts, Finnhub for financial metrics such as P/E ratios and earnings per share, and Financial Modeling Prep for detailed stock information and company profiles.

Utilizing Postman, I tested responses from the APIs to view the JSON data. This helped solidify my ERD before beginning development as I knew what data values to expect.


Challenges

  1. One of the main challenges I faced was managing the dependencies of multiple models with references to each other. For example, since the Portfolio model is tied to Trades, UserStocks, and Users, deleting a portfolio required ensuring that corresponding trades were also deleted and that the portfolio reference was removed from the user's portfolio list. This complexity extended to watchlists as well, requiring careful consideration of all database areas that needed to be updated or deleted, making CRUD operations more intricate and time-consuming. Each update or delete operation involved thinking through how different models were linked and ensuring consistency across the database.
  2. Another challenge was time. A week was enough to complete an MVP and get things working, but it didn't leave much room for covering all the edge cases I encountered as I went along. This also meant that achieving my stretch goals would require significantly more time. In the previous unit, I worked on a front-end only browser game, which I was able to complete much quicker. Being new to backend development, this project highlighted the amount of time required for both front-end and back-end work, with a much larger portion dedicated to the backend and server setup.

Wins & Key Learnings

API Integrations

A major win was successfully integrating three different APIs to deliver real-time stock and company data, each serving a distinct purpose within the app. During the planning phase, I evaluated several external APIs by comparing pricing, rate limits, and data coverage. While I prioritized free services, I also subscribed to Financial Modeling Prep for one month to access higher API limits during development. This integration strengthened the app’s reliability and provided a richer, more dynamic experience for users tracking market performance.

The app uses:

  1. Alpaca Markets for real-time stock prices and bar charts
  2. Finnhub for financial metrics like P/E ratios and earnings per share
  3. Financial Modeling Prep for detailed company profiles and fundamental data.

Cron Jobs

A favorite key learning was writing a cron job using node-cron. I gained an understanding of what a cron job is and how it can be utilized to automate tasks at specific intervals. Specifically, I used a cron job to fetch stock prices periodically and update the stock prices in my database’s stock model, ensuring the data stayed up-to-date without manual intervention. This helped streamline the process of keeping stock information current in the app.

cron.schedule("*/15 * * * *", async () => {
  console.log("CRON UPDATING STOCK PRICES. SET TO EVERY 15 MIN");
  const stocks = await queries.getDatabaseStocks();
  const stockSymbols = stocks.map((stock) => stock.symbol).join("%2C");
  const data = await api.fetchPrices(stockSymbols);
  const newPrices = [];
  Object.keys(data.bars).forEach((key) => {
    const newObj = { symbol: key, price: data.bars[key].c };
    newPrices.push(newObj);
  });
  const bulkEdit = newPrices.map((stock) => {
    return {
      updateOne: {
        filter: { symbol: stock.symbol },
        update: { $set: { price: stock.price } },
      },
    };
  });
  await queries.updateStockPrices(bulkEdit);
});

cron.schedule("10 * * * *", async () => {
  console.log("CRON UPDATING PORTFOLIO TOTAL VALUES. SET TO EVERY 10 MIN");
  const portfoliosInDatabase = await queries.getDatabasePortfolios();
  portfoliosInDatabase.forEach((portfolio) => {
    const mktValue = portfolio.userStocks.reduce((total, userStock) => {
      return total + userStock.quantity * userStock.stock.price;
    }, 0);
    portfolio.mktValue = mktValue;
  });
  const bulkEdit = portfoliosInDatabase.map((portfolio) => {
    return {
      updateOne: {
        filter: { _id: portfolio._id },
        update: { $set: { totalValue: portfolio.mktValue } },
      },
    };
  });
  await queries.updateAllPortfolioValues(bulkEdit);
});

Unit Testing

Another key learning was considering unit testing during development. Although I didn’t use official tools like Mocha or Jest, I employed a simple method of writing console.logs as I developed each section of code to check the data being returned. By logging both the expected response and the variable that should store the fetched data, I could easily compare the two and ensure they matched. This approach helped streamline my development process, allowing me to keep things modular and tackle potential issues quickly without needing to debug large blocks of code.

Other Wins

  1. Having a well-structured data diagram and clear MVP requirements allowed me to move through tasks efficiently, with a solid sense of direction. I always knew how to proceed and never felt stuck during the project.
  2. Another win was getting familiar with the MVC architecture and learning how to modularize dependencies. I became very comfortable with the backend components and truly enjoyed working on that part of the project, which fortunately made up a bulk of the work.

Bugs

Known Issues

  • After adding a stock to a watchlist, /watchlist does not show the stock until manual refresh
  • Day change and change percentage are not being updated/recalculated after adding to Stock model

Future Improvements

  • Manual refresh stock prices button
  • Add charts to stock pages and portfolios
  • Show profit/loss history for trades and stocks
  • Search for a stock by company name

Stretch Goals

These were stretch goals set during the MVP phase. As a user,

  • I want to see my realized profit/loss history based on my trades, for each stock I own(ed).
  • I want to see daily chart history for portfolio account values so I may know how my portfolios are performing.
  • I want to see an allocation visual for stocks in my portfolio(s), divided by their industries or sectors.

About

A stock tracker app for managing portfolios, tracking trades, and accessing real-time stock data.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published