8888 points by clockworkcoders 6 months ago flag hide 23 comments
wonderprogrammer 6 months ago next
Incredible work! Real-time stock trackers need quick and efficient data retrieval. What tech stack did you use for this project?
nemophilist 6 months ago next
I relied on Python's aiohttp library and websockets for real-time data consumption, while using PostgreSQL and SQLAlchemy for the database. The frontend utilizes React for rendering the UI components.
dizzydeveloper 6 months ago next
Fantastic! aiohttp and websockets are great for async processing. I'm curious, did you use a specific streaming API for stock prices? I've been looking into APIs from Alpha Vantage and Intrinio for my projects.
racingrb 6 months ago prev next
Really clean and user-friendly design! I started coding my real-time stock tracker a few days ago. Would love to share and collaborate on our projects for improvements.
moccasinsprogrammer 6 months ago prev next
Great job! As a beginner, I'd love to know how you handled displaying data on the frontend, specifically with the different charts and tables in a consistent manner?
nemophilist 6 months ago next
moccasinsprogrammer, I used the Recharts library (https://recharts.org/) for implementing charts, as it is simple and customizable. To prevent inconsistencies, I created a reusable Card component that I use with various props for tables and charts.
craftycoder 6 months ago prev next
Inspiring work! I'd love to know more about your frontend architecture, including the state management and data handling with real-time updates. Any resources or tips you can share?
nemophilist 6 months ago next
craftycoder, I would recommend watching this React state management talk by Dan Abramov (https://www.youtube.com/watch?v=8Z8UtlK_OZo). For data handling, I opted for Redux for predictable state containers while implementing the real-time feature with Redux Thunk for async actions. reselect and normalizr libraries were also beneficial for optimized rendering and complex nested data.
realisticdeveloper 6 months ago prev next
Fantastic piece of technology! Just wanted to share a gist I created (https://gist.github.com/realisticdev/ccf946a8b5b5a7b37e2183ffb ...) that covers a high-level architecture of a real-time stock tracker, if someone wants to expand on the idea. Thank you for the motivation!
zenmaster 6 months ago prev next
Absolutely magnificent job! I'm still learning web dev, but I'd love to jump into your codebase and take a peek through your components and architecture, if that's okay by you? Did you use a versioning system (e.g. Git)?
nemophilist 6 months ago next
Zenmaster, thank you! Yes, my project uses Git for version control. I also have a public GitHub repo (https://github.com/nemophilist/realtime-stock-tracker), so feel free to contribute, open issues and pull requests. I'll try to assist as much as I can!
mountaingod 6 months ago prev next
Fascinating! However, I'm unsure about the legality with obtaining and showing realtime stock data in this manner. I want to build something similar but would hate to violate terms of service or copyright. Does anyone have experience or thoughts on this?
legalcoderyhmer 6 months ago next
mountaingod, the rules for showing realtime data may vary depending on the provider and usage. Some providers require API keys, and some allow a limited amount of requests per timeframe. To be specific, I've used IEX Cloud for my own projects, which does provide limited free access and is known for friendly terms of service: https://iexcloud.io/docs/api/ -- I recommend checking if this or another provider fits your needs!
wittydeveloper 6 months ago prev next
Incredible, nemophilist! I do have a question about scalability. In more-demanding situations (e.g. handling tens of thousands of users), would using serverless or containerized infrastructure have more benefits or should the primary concern be optimizing code?
nemophilist 6 months ago next
Wittydeveloper, that's a terrific question! Serving a high volume of users always calls for evaluating the best strategies. Serverless or containerized infrastructure can relieve bottlenecks, but optimizing code is crucial for ensuring high performance as well. I'd recommend reviewing the Getting Started guide on AWS Lambda (https://docs.aws.amazon.com/lambda/latest/dg/getting-started.html) and using performance-profiling tools like Python's cProfile.
nimbledev 6 months ago prev next
Your use of Python with aiohttp, SQLAlchemy and Postgre for your realtime stock tracker looks great! I'm considering adjusting my data stack for other projects somewhat similar. Nemophilist, may I know if you utilized any ORM (Object-Relational Mapping) features or raw SQL with SQLAlchemy?
nemophilist 6 months ago next
nimbledev, glad to hear that! In my implementation, I used SQLAlchemy's ORM for mapping realtime stock data between the database and application. For more advanced queries and raw expressions, I went ahead and used SQLAlchemy Core, as it provides additional utility for working with relational databases and avoiding unwanted transitions.
curiouscoder 6 months ago prev next
Really interesting! Could you tell us how weighty and intricate the frontend setup is compared to the backend? I'd appreciate if you'd share some light on this.
nemophilist 6 months ago next
Curiouscoder, I'm happy to! I'd say my project is weighted about 70-30 for backend-heavy design. Let me explain: I made sure to fully focus on data retrieval, processing, and sophisticated dissemination. Under the hood, I used several RESTful API endpoints for handling requests. The frontend, on the other hand, primarily follows a narrow interface for data feeds. I'll clarify as needed. Happy to elaborate further!
eliquidcoder 6 months ago prev next
Beautiful design and brilliant work! I am impressed! Feeling inspired myself to start coding a real-time tracking dashboard! Interested to know if the load time is practically low while loading the bundled main getInitialProps or componentDidMount for realtime stock data?
nemophilist 6 months ago next
Thanks! The load time isn't extremely long, but it does have some time before executing getInitialProps and componentDidMount. Efforts to bring down the loading stats utilize a combination of code splitting, server-side rendering and React progressive hydration. The following resources should provide a starting point for balancing load time and UI responsiveness: (1) https://reactjs.org/docs/code-splitting.html , (2) https://nextjs.org/docs/advanced-features/server-side-rendering , (3) https://reactjs.org/docs/react-dom.html#hydrate
quietcoder 6 months ago prev next
Just seen the repo, pure elegance! Do you have experience using something like AWS Lambda in production? I'm sick of maintaining servers and want everything to be serverless, if possible. This project looks ripe for this!
nemophilist 6 months ago next
Quietcoder, glad to hear that! Indeed, going serverless can offload tons of maintenance efforts. To answer your question, I'm a beginner with AWS Lambda and first deployed my realtime stock tracker on a conventional VPS during the project, while focusing on microservices by integrating smaller, independent functions as much as possible. But I wholeheartedly agree this could be great on AWS Lambda, and I plan on experimenting with it soon. For starters, have a look at the AWS Lambda Getting Started guide for Python: https://docs.aws.amazon.com/lambda/latest/dg/getting-started-python.html