{"id":25171328,"url":"https://github.com/basemax/stock-portfolio-tracker-ts","last_synced_at":"2026-04-11T09:46:39.212Z","repository":{"id":193726838,"uuid":"686147359","full_name":"BaseMax/stock-portfolio-tracker-ts","owner":"BaseMax","description":"This repository contains a basic implementation of a stock portfolio tracker backend using Express.js and TypeScript. It includes features for user authentication, adding and removing stocks from the portfolio, real-time stock data retrieval using a financial data API, and tracking portfolio performance over time.","archived":false,"fork":false,"pushed_at":"2025-01-17T11:04:17.000Z","size":2249,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T17:08:09.611Z","etag":null,"topics":["api","api-restful","expressjs","javascript","js","restful","ts","typescript","typescript-api","typescript-express","typescript-restful"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BaseMax.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-01T21:39:33.000Z","updated_at":"2025-01-17T11:04:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"fc1f6ef2-3aa1-4599-8992-150c2b3e39d8","html_url":"https://github.com/BaseMax/stock-portfolio-tracker-ts","commit_stats":null,"previous_names":["basemax/stock-portfolio-tracker-ts"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2Fstock-portfolio-tracker-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2Fstock-portfolio-tracker-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2Fstock-portfolio-tracker-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2Fstock-portfolio-tracker-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BaseMax","download_url":"https://codeload.github.com/BaseMax/stock-portfolio-tracker-ts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247079239,"owners_count":20880018,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","api-restful","expressjs","javascript","js","restful","ts","typescript","typescript-api","typescript-express","typescript-restful"],"created_at":"2025-02-09T09:19:52.500Z","updated_at":"2026-04-11T09:46:34.176Z","avatar_url":"https://github.com/BaseMax.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stock Portfolio Tracker TS\n\nThis repository contains a basic implementation of a stock portfolio tracker backend using Express.js and TypeScript. It includes features for user authentication, adding and removing stocks from the portfolio, real-time stock data retrieval using a financial data API, and tracking portfolio performance over time.\n\nThe Stock Portfolio Tracker is a web-based application that allows users to manage their stock portfolios. It provides real-time stock data, portfolio analysis, and performance tracking.\n\n## Features\n\n- **User Authentication:** Secure user registration and login system.\n- **Stock Portfolio Management:** Add, remove, and track stocks in your portfolio.\n- **Real-Time Stock Data:** Fetch real-time stock prices and information.\n- **Portfolio Diversification:** Analyze and optimize your portfolio for better diversification.\n- **Historical Performance:** View historical performance charts of your portfolio.\n- **User-Friendly API:** Well-documented API for easy integration into other applications.\n\n\n## Demo \n\n### Register : \n\n![ demo ](./screenshots/register.png)\n\n\n\n### Login : \n\n![ demo ](./screenshots/login.png)\n\n\n\n### Create protofilo : \n\n![ demo ](./screenshots/createProtofilo.png)\n\n\n\n### Find one protofilo : \n\n![ demo ](./screenshots/findOneProtofilo.png)\n\n\n\n### Update protofilo :\n\n![ demo ](./screenshots/updateProtofilo.png)\n\n\n\n### Remove protofilo :\n\n![ demo ](./screenshots/removeProtofilo.png)\n\n\n\n### Show protofilo :\n\n![ demo ](./screenshots/showProtofilo.png)\n\n\n\n### Create stock : \n\n![ demo ](./screenshots/createStock.png)\n \n\n\n### Find stock : \n\n![ demo ](./screenshots/findStock.png)\n\n\n\n### Add stock to protofilo \n\n![ demo ](./screenshots/addStockToProtofilo.png)\n\n\n\n### Create setting\n\n![ demo ](./screenshots/createSetting.png)\n\n\n\n### Update setting\n\n![ demo ](./screenshots/updateSetting.png)\n\n\n\n### Get Setting\n\n![ demo ](./screenshots/getSetting.png)\n\n\n\n### Create transaction \n\n![ demo ](./screenshots/createTransaction.png)\n\n\n\n### Get transaction \n\n![ demo ](./screenshots/getTransaction.png)\n\n\n\n### Remove transaction \n\n![ demo ](./screenshots/removeTransaction.png)\n\n\n\n### Find all transaction \n\n![ demo ](./screenshots/getAllTransaction.png)\n\n\n\n\n\n## Getting Started\n\n- Prerequisites\n- Node.js and npm installed on your system.\n\n## API Endpoints\n\n| Endpoint                     | Method | Description                                | Example Request                                | Example Response                                |\n| ---------------------------- | ------ | ------------------------------------------ | ----------------------------------------------- | ----------------------------------------------- |\n| `/api/auth/register`         | POST   | Register a new user account.               | `{ \"username\": \"john_doe\", \"email\": \"john@example.com\", \"password\": \"securePassword123\" }` | `{\"message\": \"User registered successfully\"}` |\n| `/api/auth/login`            | POST   | Log in with an existing user account.      | `{ \"email\": \"john@example.com\", \"password\": \"securePassword123\" }` | `{\"token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...}` |\n| `/api/portfolio`             | GET    | Get the user's portfolio with stock holdings and performance data. | N/A | `{\"portfolio\": {...}, \"stocks\": [...], \"performance\": {...}}` |\n| `/api/portfolio/add`         | POST   | Add a stock to the user's portfolio.       | `{ \"symbol\": \"AAPL\", \"quantity\": 10 }`       | `{\"message\": \"Stock added to the portfolio\"}` |\n| `/api/portfolio/remove`      | POST   | Remove a stock from the user's portfolio.  | `{ \"symbol\": \"AAPL\" }`                        | `{\"message\": \"Stock removed from the portfolio\"}` |\n| `/api/stocks/:symbol`        | GET    | Get real-time stock data for a specific stock symbol. | N/A | `{\"symbol\": \"AAPL\", \"name\": \"Apple Inc.\", \"price\": 150.25, \"lastUpdated\": \"2023-09-01T12:00:00Z\"}` |\n| `/api/stocks/search?query=`  | GET    | Search for stocks by symbol or name.       | `/api/stocks/search?query=AAPL`              | `{\"results\": [...], \"totalResults\": 5}` |\n| `/api/portfolio/analyze`     | GET    | Analyze the diversification of the user's portfolio. | N/A | `{\"diversificationScore\": 85}` |\n| `/api/portfolio/history`     | GET    | Get historical performance data for the user's portfolio. | N/A | `{\"history\": [...], \"startDate\": \"2023-01-01\", \"endDate\": \"2023-09-01\"}` |\n| `/api/user/profile`          | GET    | Get the user's profile information.        | N/A | `{\"username\": \"john_doe\", \"email\": \"john@example.com\", \"firstName\": \"John\", \"lastName\": \"Doe\"}` |\n| `/api/user/profile`          | PUT    | Update the user's profile information.     | `{ \"firstName\": \"John\", \"lastName\": \"Doe\" }` | `{\"message\": \"Profile updated successfully\"}` |\n| `/api/user/settings`         | GET    | Get user account settings.                 | N/A | `{\"currency\": \"USD\", \"theme\": \"dark\"}` |\n| `/api/user/settings`         | PUT    | Update user account settings.              | `{ \"notification\": true, \"theme\": \"dark\" }`  | `{\"message\": \"Settings updated successfully\"}` |\n| `/api/portfolio/buy`         | POST   | Buy stocks and add them to the portfolio.  | `{ \"symbol\": \"GOOG\", \"quantity\": 5 }`        | `{\"message\": \"Stocks bought and added to the portfolio\"}` |\n| `/api/portfolio/sell`        | POST   | Sell stocks from the portfolio.            | `{ \"symbol\": \"AAPL\", \"quantity\": 3 }`        | `{\"message\": \"Stocks sold from the portfolio\"}` |\n| `/api/portfolio/transactions` | GET    | Get a list of all portfolio transactions.  | N/A | `{\"transactions\": [...], \"totalTransactions\": 10}` |\n| `/api/portfolio/transactions/:id` | GET | Get details of a specific transaction.     | N/A | `{\"transaction\": {...}}` |\n| `/api/news`                  | GET    | Fetch the latest financial news.            | N/A | `{\"news\": [...], \"totalNews\": 5}` |\n| `/api/notifications`         | GET    | Get user notifications.                    | N/A | `{\"notifications\": [...], \"totalNotifications\": 5}` |\n| `/api/notifications`         | POST   | Create a new notification.                 | `{ \"message\": \"New stock added.\" }` | `{\"message\": \"Notification created successfully\"}` |\n| `/api/notifications/:id`     | DELETE | Delete a specific notification.           | N/A | `{\"message\": \"Notification deleted successfully\"}` |\n| `/api/watchlist`             | GET    | Get the user's stock watchlist.            | N/A | `{\"watchlist\": [...], \"totalStocks\": 5}` |\n| `/api/watchlist/add`         | POST   | Add a stock to the user's watchlist.       | `{ \"symbol\": \"TSLA\" }` | `{\"message\": \"Stock added to the watchlist\"}` |\n| `/api/watchlist/remove`      | POST   | Remove a stock from the watchlist.         | `{ \"symbol\": \"TSLA\" }` | `{\"message\": \"Stock removed from the watchlist\"}` |\n| `/api/settings`              | GET    | Get application settings.                  | N/A | `{\"currency\": \"USD\", \"theme\": \"light\"}` |\n| `/api/settings`              | PUT    | Update application settings.               | `{ \"currency\": \"USD\", \"theme\": \"light\" }`   | `{\"message\": \"Settings updated successfully\"}` |\n| `/api/portfolio/stats`       | GET    | Get overall portfolio statistics.          | N/A | `{\"statistics\": {...}}` |\n| `/api/portfolio/dividends`   | GET    | Get dividend income for the portfolio.     | N/A | `{\"dividendIncome\": 2500.00}` |\n| `/api/portfolio/roi`         | GET    | Get return on investment for the portfolio.| N/A | `{\"roi\": 10.25}` |\n| `/api/stocks/recommendations` | GET   | Get stock recommendations based on user preferences. | N/A | `{\"recommendations\": [...], \"totalRecommendations\": 5}` |\n| `/api/stocks/history/:symbol` | GET   | Get historical stock data for a specific symbol. | N/A | `{\"history\": [...], \"symbol\": \"AAPL\"}` |\n| `/api/stocks/news/:symbol`   | GET   | Get news related to a specific stock.      | N/A | `{\"news\": [...], \"symbol\": \"AAPL\"}` |\n| `/api/portfolio/alerts`      | GET    | Get portfolio alerts and notifications.   | N/A | `{\"alerts\": [...], \"totalAlerts\": 5}` |\n| `/api/portfolio/alerts`      | POST   | Create a new portfolio alert.             | `{ \"symbol\": \"AAPL\", \"targetPrice\": 150 }`   | `{\"message\": \"Alert created successfully\"}` |\n| `/api/portfolio/alerts/:id`  | PUT    | Update a portfolio alert.                 | `{ \"targetPrice\": 160 }`   | `{\"message\": \"Alert updated successfully\"}` |\n| `/api/portfolio/alerts/:id`  | DELETE | Delete a portfolio alert.                 | N/A | `{\"message\": \"Alert deleted successfully\"}` |\n| `/api/stocks/compare`        | POST   | Compare multiple stocks' performance.     | `{ \"symbols\": [\"AAPL\", \"GOOG\", \"TSLA\"] }`    | `{\"comparison\": {...}}` |\n| `/api/stocks/symbols`        | GET    | Get a list of available stock symbols.    | N/A | `{\"symbols\": [\"AAPL\", \"GOOG\", \"TSLA\"]}` |\n| `/api/portfolio/strategies`  | GET    | Get recommended investment strategies based on user preferences. | N/A | `{\"strategies\": [...], \"totalStrategies\": 5}` |\n| `/api/portfolio/strategies/:id` | GET  | Get details of a specific investment strategy. | N/A | `{\"strategy\": {...}}` |\n| `/api/portfolio/strategies`  | POST   | Create a custom investment strategy.       | `{ \"name\": \"My Strategy\", \"description\": \"A custom investment strategy\", \"assets\": [\"AAPL\", \"GOOG\"] }` | `{\"message\": \"Strategy created successfully\"}` |\n| `/api/portfolio/strategies/:id` | PUT  | Update a custom investment strategy.       | `{ \"name\": \"Updated Strategy\", \"description\": \"An updated custom investment strategy\" }` | `{\"message\": \"Strategy updated successfully\"}` |\n| `/api/portfolio/strategies/:id` | DELETE | Delete a custom investment strategy.     | N/A | `{\"message\": \"Strategy deleted successfully\"}` |\n| `/api/transactions`           | GET    | Get a list of all user transactions (buy/sell orders). | N/A | `{\"transactions\": [...], \"totalTransactions\": 10}` |\n| `/api/transactions/:id`       | GET    | Get details of a specific transaction.     | N/A | `{\"transaction\": {...}}` |\n| `/api/transactions/buy`       | POST   | Create a buy order for a stock.           | `{ \"symbol\": \"AAPL\", \"quantity\": 5 }`        | `{\"message\": \"Buy order created successfully\"}` |\n| `/api/transactions/sell`      | POST   | Create a sell order for a stock.          | `{ \"symbol\": \"AAPL\", \"quantity\": 3 }`        | `{\"message\": \"Sell order created successfully\"}` |\n| `/api/transactions/:id`       | DELETE | Cancel a pending transaction.             | N/A | `{\"message\": \"Transaction canceled successfully\"}` |\n| `/api/alerts`                  | GET    | Get user-specific alerts and notifications. | N/A | `{\"alerts\": [...], \"totalAlerts\": 5}` |\n| `/api/alerts/:id`              | GET    | Get details of a specific alert.           | N/A | `{\"alert\": {...}}` |\n| `/api/alerts`                  | POST   | Create a new alert or notification.       | `{ \"type\": \"price\", \"symbol\": \"AAPL\", \"targetPrice\": 150 }` | `{\"message\": \"Alert created successfully\"}` |\n| `/api/alerts/:id`              | PUT    | Update an existing alert.                 | `{ \"type\": \"price\", \"targetPrice\": 160 }`   | `{\"message\": \"Alert updated successfully\"}` |\n| `/api/alerts/:id`              | DELETE | Delete an alert or notification.          | N/A | `{\"message\": \"Alert deleted successfully\"}` |\n| `/api/transactions/history`    | GET    | Get historical transaction data.           | N/A | `{\"history\": [...], \"totalTransactions\": 10}` |\n| `/api/transactions/history/:id` | GET  | Get historical data for a specific transaction. | N/A | `{\"transaction\": {...}}` |\n| `/api/user/logout`             | POST   | Log the user out and invalidate the session. | N/A | `{\"message\": \"User logged out successfully\"}` |\n| `/api/user/forgot-password`    | POST   | Request a password reset email.            | `{ \"email\": \"john@example.com\" }` | `{\"message\": \"Password reset email sent successfully\"}` |\n| `/api/user/reset-password`     | POST   | Reset the user's password with a valid reset token. | `{ \"token\": \"valid_token\", \"password\": \"newPassword123\" }` | `{\"message\": \"Password reset successfully\"}` |\n| `/api/user/change-password`    | PUT    | Change the user's password.                | `{ \"currentPassword\": \"oldPassword123\", \"newPassword\": \"newPassword123\" }` | `{\"message\": \"Password changed successfully\"}` |\n\n## Database Schema: StockPortfolio\n\n### User Collection\n\n- `user_id` (ObjectId): Unique identifier for each user (auto-generated by MongoDB).\n- `username` (String): User's chosen username.\n- `email` (String): User's email address.\n- `password` (String): Hashed password for authentication.\n- `firstName` (String): User's first name.\n- `lastName` (String): User's last name.\n- `createdAt` (Date): Timestamp for user registration.\n- `updatedAt` (Date): Timestamp for user profile updates.\n\n### Portfolio Collection\n\n- `portfolio_id` (ObjectId): Unique identifier for each portfolio (auto-generated by MongoDB).\n- `user_id` (ObjectId): Reference to the user who owns the portfolio.\n- `name` (String): User-defined name for the portfolio.\n- `description` (String): Description of the portfolio.\n- `createdAt` (Date): Timestamp for portfolio creation.\n- `updatedAt` (Date): Timestamp for portfolio updates.\n\n### Stock Collection\n\n- `stock_id` (ObjectId): Unique identifier for each stock (auto-generated by MongoDB).\n- `symbol` (String): Stock symbol, e.g., AAPL for Apple Inc.\n- `name` (String): Full name of the stock.\n- `price` (Number): Current stock price.\n- `lastUpdated` (Date): Timestamp for the last update of stock data.\n\n### PortfolioStock Collection (Many-to-Many Relationship)\n\n- `portfolioStock_id` (ObjectId): Unique identifier for each portfolio-stock relationship (auto-generated by MongoDB).\n- `portfolio_id` (ObjectId): Reference to the portfolio.\n- `stock_id` (ObjectId): Reference to the stock.\n- `quantity` (Number): Number of shares of the stock in the portfolio.\n- `purchasePrice` (Number): Price at which the stock was purchased.\n- `purchaseDate` (Date): Date of purchase.\n\n### Transaction Collection\n\n- `transaction_id` (ObjectId): Unique identifier for each transaction (auto-generated by MongoDB).\n- `user_id` (ObjectId): Reference to the user initiating the transaction.\n- `stock_id` (ObjectId): Reference to the stock involved in the transaction.\n- `type` (String): Transaction type (e.g., \"buy\" or \"sell\").\n- `quantity` (Number): Number of shares bought or sold.\n- `price` (Number): Price per share at the time of the transaction.\n- `transactionDate` (Date): Timestamp for the transaction.\n\n### Notification Collection\n\n- `notification_id` (ObjectId): Unique identifier for each notification (auto-generated by MongoDB).\n- `user_id` (ObjectId): Reference to the user receiving the notification.\n- `type` (String): Notification type (e.g., \"priceAlert\" or \"news\").\n- `message` (String): Content of the notification.\n- `createdAt` (Date): Timestamp for notification creation.\n\n### Watchlist Collection\n\n- `watchlist_id` (ObjectId): Unique identifier for each user's watchlist (auto-generated by MongoDB).\n- `user_id` (ObjectId): Reference to the user who owns the watchlist.\n- `stocks` (Array of ObjectId): References to stocks added to the watchlist.\n- `createdAt` (Date): Timestamp for watchlist creation.\n- `updatedAt` (Date): Timestamp for watchlist updates.\n\n### Alert Collection\n\n- `alert_id` (ObjectId): Unique identifier for each user's custom alerts (auto-generated by MongoDB).\n- `user_id` (ObjectId): Reference to the user who set up the alert.\n- `type` (String): Alert type (e.g., \"price\" or \"news\").\n- `symbol` (String): Symbol of the stock the alert is associated with.\n- `targetPrice` (Number): The price at which the alert should trigger (for price alerts).\n- `createdAt` (Date): Timestamp for alert creation.\n\n### StockRecommendation Collection\n\n- `recommendation_id` (ObjectId): Unique identifier for each stock recommendation (auto-generated by MongoDB).\n- `user_id` (ObjectId): Reference to the user receiving the recommendation.\n- `symbol` (String): Symbol of the recommended stock.\n- `strategy` (String): Name of the investment strategy that led to the recommendation.\n- `createdAt` (Date): Timestamp for recommendation creation.\n\n### Strategy Collection\n\n- `strategy_id` (ObjectId): Unique identifier for each investment strategy (auto-generated by MongoDB).\n- `user_id` (ObjectId): Reference to the user who created the strategy.\n- `name` (String): Name of the investment strategy.\n- `description` (String): Description of the strategy.\n- `assets` (Array of String): List of stock symbols associated with the strategy.\n- `createdAt` (Date): Timestamp for strategy creation.\n- `updatedAt` (Date): Timestamp for strategy updates.\n\n### AssetRecommendation Collection\n\n- `assetRecommendation_id` (ObjectId): Unique identifier for each asset recommendation (auto-generated by MongoDB).\n- `strategy_id` (ObjectId): Reference to the investment strategy that led to the recommendation.\n- `symbol` (String): Symbol of the recommended asset (stock).\n- `recommendationType` (String): Type of recommendation (e.g., \"buy\" or \"sell\").\n- `targetPrice` (Number): The target price for the asset.\n- `createdAt` (Date): Timestamp for asset recommendation creation.\n\n### Settings Collection\n\n- `settings_id` (ObjectId): Unique identifier for each user's application settings (auto-generated by MongoDB).\n- `user_id` (ObjectId): Reference to the user who owns the settings.\n- `currency` (String): User's preferred currency for financial data (e.g., \"USD\" or \"EUR\").\n- `theme` (String): User's preferred application theme (e.g., \"light\" or \"dark\").\n- `createdAt` (Date): Timestamp for settings creation.\n- `updatedAt` (Date): Timestamp for settings updates.\n\n### TransactionHistory Collection\n\n- `transactionHistory_id` (ObjectId): Unique identifier for each transaction history entry (auto-generated by MongoDB).\n- `user_id` (ObjectId): Reference to the user associated with the transaction history.\n- `type` (String): Type of transaction (e.g., \"buy\" or \"sell\").\n- `symbol` (String): Symbol of the stock involved in the transaction.\n- `quantity` (Number): Number of shares bought or sold.\n- `price` (Number): Price per share at the time of the transaction.\n- `transactionDate` (Date): Timestamp for the transaction.\n- `notes` (String): Additional notes or comments for the transaction.\n\n### DividendCollection\n\n- `dividend_id` (ObjectId): Unique identifier for each dividend record (auto-generated by MongoDB).\n- `user_id` (ObjectId): Reference to the user associated with the dividend record.\n- `stock_id` (ObjectId): Reference to the stock that paid the dividend.\n- `amount` (Number): Dividend amount received.\n- `paymentDate` (Date): Date when the dividend was paid.\n- `recordDate` (Date): Record date for dividend eligibility.\n\n### ReturnOnInvestmentCollection\n\n- `roi_id` (ObjectId): Unique identifier for each return on investment (ROI) record (auto-generated by MongoDB).\n- `user_id` (ObjectId): Reference to the user associated with the ROI record.\n- `portfolio_id` (ObjectId): Reference to the portfolio for which ROI is calculated.\n- `startDate` (Date): Start date for ROI calculation.\n- `endDate` (Date): End date for ROI calculation.\n- `roi` (Number): Return on investment percentage.\n\n### StockComparisonCollection\n\n- `comparison_id` (ObjectId): Unique identifier for each stock comparison (auto-generated by MongoDB).\n- `user_id` (ObjectId): Reference to the user who initiated the comparison.\n- `symbols` (Array of Strings): Symbols of the stocks being compared.\n- `comparisonDate` (Date): Timestamp for the comparison.\n- `results` (Object): Comparison results, such as stock prices and performance metrics.\n\n### StockSymbolCollection\n\n- `symbol_id` (ObjectId): Unique identifier for each stock symbol (auto-generated by MongoDB).\n- `symbol` (String): Symbol of the stock.\n- `name` (String): Full name of the stock.\n- `createdAt` (Date): Timestamp for symbol registration.\n\n### PortfolioPerformanceCollection\n\n- `performance_id` (ObjectId): Unique identifier for each portfolio performance record (auto-generated by MongoDB).\n- `user_id` (ObjectId): Reference to the user associated with the portfolio performance.\n- `portfolio_id` (ObjectId): Reference to the portfolio for which performance is calculated.\n- `startDate` (Date): Start date for performance calculation.\n- `endDate` (Date): End date for performance calculation.\n- `initialValue` (Number): Initial portfolio value at the start date.\n- `finalValue` (Number): Portfolio value at the end date.\n- `percentageChange` (Number): Percentage change in portfolio value.\n\n### NewsArticleCollection\n\n- `article_id` (ObjectId): Unique identifier for each news article (auto-generated by MongoDB).\n- `title` (String): Title of the news article.\n- `content` (String): Content of the news article.\n- `publishedDate` (Date): Date when the article was published.\n- `source` (String): Source or publication of the article.\n- `url` (String): URL to the full article.\n- `createdAt` (Date): Timestamp for article registration.\n\n### NotificationPreferencesCollection\n\n- `preferences_id` (ObjectId): Unique identifier for each user's notification preferences (auto-generated by MongoDB).\n- `user_id` (ObjectId): Reference to the user associated with the preferences.\n- `priceAlertsEnabled` (Boolean): Indicates if price alerts are enabled.\n- `newsAlertsEnabled` (Boolean): Indicates if news alerts are enabled.\n- `dividendAlertsEnabled` (Boolean): Indicates if dividend alerts are enabled.\n- `createdAt` (Date): Timestamp for preferences creation.\n- `updatedAt` (Date): Timestamp for preferences updates.\n\n### StrategyAssetCollection\n\n- `strategyAsset_id` (ObjectId): Unique identifier for each strategy-asset relationship (auto-generated by MongoDB).\n- `strategy_id` (ObjectId): Reference to the investment strategy.\n- `symbol` (String): Symbol of the associated asset (stock).\n- `weight` (Number): Weight assigned to the asset within the strategy.\n\n### RecommendationCommentCollection\n\n- `comment_id` (ObjectId): Unique identifier for each recommendation comment (auto-generated by MongoDB).\n- `recommendation_id` (ObjectId): Reference to the stock recommendation.\n- `user_id` (ObjectId): Reference to the user who posted the comment.\n- `content` (String): Content of the comment.\n- `createdAt` (Date): Timestamp for comment creation.\n\n## Installation\n\nClone the repository:\n\n```bash\ngit clone https://github.com/BaseMax/stock-portfolio-tracker-ts.git\ncd stock-portfolio-tracker-ts\n```\n\nInstall dependencies:\n\n```bash\nnpm install\n```\n\nConfigure environment variables:\n\nCreate a `.env` file in the project root and define the following variables:\n\n```makefile\nPORT=3000\nDATABASE_URL=mongodb://localhost/stock-portfolio\nAPI_KEY=your_stock_api_key\n```\n\nStart the development server:\n\n```bash\nnpm run dev\n```\n\nAccess the application at `http://localhost:3000` in your web browser.\n\n## Database SQL\n\n```sql\n-- User Collection\nCREATE TABLE User (\n    user_id SERIAL PRIMARY KEY,\n    username VARCHAR(255) NOT NULL,\n    email VARCHAR(255) NOT NULL,\n    password VARCHAR(255) NOT NULL,\n    firstName VARCHAR(255),\n    lastName VARCHAR(255),\n    createdAt TIMESTAMP NOT NULL,\n    updatedAt TIMESTAMP\n);\n\n-- Portfolio Collection\nCREATE TABLE Portfolio (\n    portfolio_id SERIAL PRIMARY KEY,\n    user_id INT NOT NULL,\n    name VARCHAR(255),\n    description TEXT,\n    createdAt TIMESTAMP NOT NULL,\n    updatedAt TIMESTAMP,\n    FOREIGN KEY (user_id) REFERENCES User(user_id)\n);\n\n-- Stock Collection\nCREATE TABLE Stock (\n    stock_id SERIAL PRIMARY KEY,\n    symbol VARCHAR(10) NOT NULL,\n    name VARCHAR(255),\n    price DECIMAL(10, 2),\n    lastUpdated TIMESTAMP,\n    UNIQUE (symbol)\n);\n\n-- PortfolioStock Collection (Many-to-Many Relationship)\nCREATE TABLE PortfolioStock (\n    portfolioStock_id SERIAL PRIMARY KEY,\n    portfolio_id INT NOT NULL,\n    stock_id INT NOT NULL,\n    quantity INT NOT NULL,\n    purchasePrice DECIMAL(10, 2),\n    purchaseDate DATE,\n    FOREIGN KEY (portfolio_id) REFERENCES Portfolio(portfolio_id),\n    FOREIGN KEY (stock_id) REFERENCES Stock(stock_id)\n);\n\n-- Transaction Collection\nCREATE TABLE Transaction (\n    transaction_id SERIAL PRIMARY KEY,\n    user_id INT NOT NULL,\n    stock_id INT NOT NULL,\n    type VARCHAR(10) NOT NULL,\n    quantity INT NOT NULL,\n    price DECIMAL(10, 2) NOT NULL,\n    transactionDate TIMESTAMP NOT NULL,\n    FOREIGN KEY (user_id) REFERENCES User(user_id),\n    FOREIGN KEY (stock_id) REFERENCES Stock(stock_id)\n);\n\n-- Notification Collection\nCREATE TABLE Notification (\n    notification_id SERIAL PRIMARY KEY,\n    user_id INT NOT NULL,\n    type VARCHAR(20) NOT NULL,\n    message TEXT,\n    createdAt TIMESTAMP NOT NULL,\n    FOREIGN KEY (user_id) REFERENCES User(user_id)\n);\n\n-- Watchlist Collection\nCREATE TABLE Watchlist (\n    watchlist_id SERIAL PRIMARY KEY,\n    user_id INT NOT NULL,\n    createdAt TIMESTAMP NOT NULL,\n    updatedAt TIMESTAMP,\n    FOREIGN KEY (user_id) REFERENCES User(user_id)\n);\n\n-- Alert Collection\nCREATE TABLE Alert (\n    alert_id SERIAL PRIMARY KEY,\n    user_id INT NOT NULL,\n    type VARCHAR(20) NOT NULL,\n    symbol VARCHAR(10) NOT NULL,\n    targetPrice DECIMAL(10, 2),\n    createdAt TIMESTAMP NOT NULL,\n    FOREIGN KEY (user_id) REFERENCES User(user_id),\n    FOREIGN KEY (symbol) REFERENCES Stock(symbol)\n);\n\n-- Strategy Collection\nCREATE TABLE Strategy (\n    strategy_id SERIAL PRIMARY KEY,\n    user_id INT NOT NULL,\n    name VARCHAR(255) NOT NULL,\n    description TEXT,\n    createdAt TIMESTAMP NOT NULL,\n    updatedAt TIMESTAMP,\n    FOREIGN KEY (user_id) REFERENCES User(user_id)\n);\n\n-- AssetRecommendation Collection\nCREATE TABLE AssetRecommendation (\n    assetRecommendation_id SERIAL PRIMARY KEY,\n    strategy_id INT NOT NULL,\n    symbol VARCHAR(10) NOT NULL,\n    recommendationType VARCHAR(10) NOT NULL,\n    targetPrice DECIMAL(10, 2),\n    createdAt TIMESTAMP NOT NULL,\n    FOREIGN KEY (strategy_id) REFERENCES Strategy(strategy_id),\n    FOREIGN KEY (symbol) REFERENCES Stock(symbol)\n);\n\n-- Settings Collection\nCREATE TABLE Settings (\n    settings_id SERIAL PRIMARY KEY,\n    user_id INT NOT NULL,\n    currency VARCHAR(5),\n    theme VARCHAR(10),\n    createdAt TIMESTAMP NOT NULL,\n    updatedAt TIMESTAMP,\n    FOREIGN KEY (user_id) REFERENCES User(user_id)\n);\n\n-- TransactionHistory Collection\nCREATE TABLE TransactionHistory (\n    transactionHistory_id SERIAL PRIMARY KEY,\n    user_id INT NOT NULL,\n    type VARCHAR(10) NOT NULL,\n    symbol VARCHAR(10) NOT NULL,\n    quantity INT NOT NULL,\n    price DECIMAL(10, 2) NOT NULL,\n    transactionDate TIMESTAMP NOT NULL,\n    notes TEXT,\n    FOREIGN KEY (user_id) REFERENCES User(user_id),\n    FOREIGN KEY (symbol) REFERENCES Stock(symbol)\n);\n\n-- DividendCollection\nCREATE TABLE Dividend (\n    dividend_id SERIAL PRIMARY KEY,\n    user_id INT NOT NULL,\n    stock_id INT NOT NULL,\n    amount DECIMAL(10, 2) NOT NULL,\n    paymentDate DATE,\n    recordDate DATE,\n    FOREIGN KEY (user_id) REFERENCES User(user_id),\n    FOREIGN KEY (stock_id) REFERENCES Stock(stock_id)\n);\n\n-- ReturnOnInvestmentCollection\nCREATE TABLE ReturnOnInvestment (\n    roi_id SERIAL PRIMARY KEY,\n    user_id INT NOT NULL,\n    portfolio_id INT NOT NULL,\n    startDate DATE NOT NULL,\n    endDate DATE NOT NULL,\n    roi DECIMAL(10, 2) NOT NULL,\n    FOREIGN KEY (user_id) REFERENCES User(user_id),\n    FOREIGN KEY (portfolio_id) REFERENCES Portfolio(portfolio_id)\n);\n\n-- StockComparisonCollection\nCREATE TABLE StockComparison (\n    comparison_id SERIAL PRIMARY KEY,\n    user_id INT NOT NULL,\n    comparisonDate TIMESTAMP NOT NULL,\n    results JSONB,\n    FOREIGN KEY (user_id) REFERENCES User(user_id)\n);\n\n-- StockSymbolCollection\nCREATE TABLE StockSymbol (\n    symbol_id SERIAL PRIMARY KEY,\n    symbol VARCHAR(10) NOT NULL,\n    name VARCHAR(255),\n    createdAt TIMESTAMP NOT NULL\n);\n\n-- PortfolioPerformanceCollection\nCREATE TABLE PortfolioPerformance (\n    performance_id SERIAL PRIMARY KEY,\n    user_id INT NOT NULL,\n    portfolio_id INT NOT NULL,\n    startDate DATE NOT NULL,\n    endDate DATE NOT NULL,\n    initialValue DECIMAL(10, 2) NOT NULL,\n    finalValue DECIMAL(10, 2) NOT NULL,\n    percentageChange DECIMAL(5, 2) NOT NULL,\n    FOREIGN KEY (user_id) REFERENCES User(user_id),\n    FOREIGN KEY (portfolio_id) REFERENCES Portfolio(portfolio_id)\n);\n\n-- NewsArticleCollection\nCREATE TABLE NewsArticle (\n    article_id SERIAL PRIMARY KEY,\n    title VARCHAR(255) NOT NULL,\n    content TEXT NOT NULL,\n    publishedDate DATE,\n    source VARCHAR(255),\n    url VARCHAR(255),\n    createdAt TIMESTAMP NOT NULL\n);\n\n-- NotificationPreferencesCollection\nCREATE TABLE NotificationPreferences (\n    preferences_id SERIAL PRIMARY KEY,\n    user_id INT NOT NULL,\n    priceAlertsEnabled BOOLEAN,\n    newsAlertsEnabled BOOLEAN,\n    dividendAlertsEnabled BOOLEAN,\n    createdAt TIMESTAMP NOT NULL,\n    updatedAt TIMESTAMP,\n    FOREIGN KEY (user_id) REFERENCES User(user_id)\n);\n\n-- StrategyAssetCollection\nCREATE TABLE StrategyAsset (\n    strategyAsset_id SERIAL PRIMARY KEY,\n    strategy_id INT NOT NULL,\n    symbol VARCHAR(10) NOT NULL,\n    weight DECIMAL(5, 2) NOT NULL,\n    FOREIGN KEY (strategy_id) REFERENCES Strategy(strategy_id),\n    FOREIGN KEY (symbol) REFERENCES Stock(symbol)\n);\n\n-- RecommendationCommentCollection\nCREATE TABLE RecommendationComment (\n    comment_id SERIAL PRIMARY KEY,\n    recommendation_id INT NOT NULL,\n    user_id INT NOT NULL,\n    content TEXT NOT NULL,\n    createdAt TIMESTAMP NOT NULL,\n    FOREIGN KEY (recommendation_id) REFERENCES AssetRecommendation(assetRecommendation_id),\n    FOREIGN KEY (user_id) REFERENCES User(user_id)\n);\n\n-- PortfolioPerformance Collection\nCREATE TABLE PortfolioPerformance (\n    performance_id SERIAL PRIMARY KEY,\n    user_id INT NOT NULL,\n    portfolio_id INT NOT NULL,\n    startDate DATE NOT NULL,\n    endDate DATE NOT NULL,\n    initialValue DECIMAL(10, 2) NOT NULL,\n    finalValue DECIMAL(10, 2) NOT NULL,\n    percentageChange DECIMAL(5, 2) NOT NULL,\n    FOREIGN KEY (user_id) REFERENCES User(user_id),\n    FOREIGN KEY (portfolio_id) REFERENCES Portfolio(portfolio_id)\n);\n\n-- NewsArticle Collection\nCREATE TABLE NewsArticle (\n    article_id SERIAL PRIMARY KEY,\n    title VARCHAR(255) NOT NULL,\n    content TEXT NOT NULL,\n    publishedDate DATE,\n    source VARCHAR(255),\n    url VARCHAR(255),\n    createdAt TIMESTAMP NOT NULL\n);\n\n-- NotificationPreferences Collection\nCREATE TABLE NotificationPreferences (\n    preferences_id SERIAL PRIMARY KEY,\n    user_id INT NOT NULL,\n    priceAlertsEnabled BOOLEAN,\n    newsAlertsEnabled BOOLEAN,\n    dividendAlertsEnabled BOOLEAN,\n    createdAt TIMESTAMP NOT NULL,\n    updatedAt TIMESTAMP,\n    FOREIGN KEY (user_id) REFERENCES User(user_id)\n);\n\n-- StrategyAsset Collection\nCREATE TABLE StrategyAsset (\n    strategyAsset_id SERIAL PRIMARY KEY,\n    strategy_id INT NOT NULL,\n    symbol VARCHAR(10) NOT NULL,\n    weight DECIMAL(5, 2) NOT NULL,\n    FOREIGN KEY (strategy_id) REFERENCES Strategy(strategy_id),\n    FOREIGN KEY (symbol) REFERENCES Stock(symbol)\n);\n\n-- RecommendationComment Collection\nCREATE TABLE RecommendationComment (\n    comment_id SERIAL PRIMARY KEY,\n    recommendation_id INT NOT NULL,\n    user_id INT NOT NULL,\n    content TEXT NOT NULL,\n    createdAt TIMESTAMP NOT NULL,\n    FOREIGN KEY (recommendation_id) REFERENCES AssetRecommendation(assetRecommendation_id),\n    FOREIGN KEY (user_id) REFERENCES User(user_id)\n);\n```\n\n## Usage\n\n- Register a new user account or log in if you already have an account.\n- Add stocks to your portfolio by searching for their symbols or names.\n- Track real-time stock prices and portfolio performance.\n- Analyze and optimize your portfolio for better returns.\n\n## API Documentation\n\nFor API documentation and endpoints, please refer to the API Documentation file.\n\n## Contributing\n\nContributions are welcome! Please read the Contributing Guidelines for more information.\n\n## License\n\nThis project is licensed under the GPL-3.0 License.\n\nCopyright 2023, Max Base\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasemax%2Fstock-portfolio-tracker-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbasemax%2Fstock-portfolio-tracker-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasemax%2Fstock-portfolio-tracker-ts/lists"}