Navigating the Full-Stack Jungle: My Journey with React, Flask, and SQLAlchemy
So originally I have been a front end oriented programmer. With my eye set on React and JS libraries, though I've always had a soft spot for Python. In the beginning when I was trying to find my path I defiantly dipped my toe into Python. Never into Flask, I didn't know much about it, Django caught my eye. Long story short I'm working my way through my Boot Camp and our backend phase introduces me to Python and Flask along with their favorite companion SQLAlchemy. Come to find out paired with My favorite front end library React you can create some really powerful really fast light weight apps and technologies. I figure you might ask what makes this Stack so powerful. Well with the power of Thor's hammer and a swig off Loki's Flask I will elaborate.
The Stack It's Self
React: your UI tech
React is my favorite JavaScript library I use to build my user interfaces, especially single-page applications. It allows me to create reusable components, manage application state, and handle user interactions with ease. As a beginner, I find that Reacts component-based architecture to be really easy to use for beginners.
Component-Based Architecture: React is easy to read and build by breaking down the UI into small, manageable components. This modular approach makes it easier to build and maintain my application’s interface and readability.
State Management: Reacts state management is amazing! It helps you understand how to manage state with hooks like
useState
anduseEffect
which I found easy to digest and mitigate. It allowed me to handle user inputs and update the UI quickly and dynamically.React Router: Setting up client-side routing with React Router was a dream, I mean it was my first dream. Though I can imagine not an easy task else where. It makes it easy to create multiple pages and navigate between them without having to reload the page. Making debugging and editing the UI seamless and viewable in real time.
Flask: Creating A Light Weight Backend
I found Flask to be a lightweight framework that give you the ability to build out a solid backend with little effort. It’s minimalistic, which means you get to make a lot of decisions on how set things up. Without having to go through tons of commands or precursor code.
Routing and Views: Flask’s routing system allowed me to define endpoints for various API routes really easy. Then I could map HTTP requests to functions with ease, making it simple to handle different operations like CRUD "create, read, update, and delete." It honestly really helped me understand what was going on under the hood, without having to sift through hundreds of lines of code.
Flask-Migrate: Let me tell you migrating databases with Flask-Migrate was so easy. It practically does it for you. A few lines of code and then the correct commands at the correct time and BAM. It allowed me to keep track of changes to the database schema without losing any data or getting confused along the way.
Flask-Marshmallow: Love the name. Honestly this is where I struggled the most. Though I can defiantly attest that to user error. I forgot to install the package and it took a while to figure out what the issue was. When were talking about serialization and deserialization of data, Flask-Marshmallow is crazy good. Just read the documentation and really review your code. It helped me with converting complex data types, like SQLAlchemy models, into JSON format and vice versa. Over all really easy to use when you actually use it LOL.
SQLAlchemy: Managing the Database
SQLAlchemy is a really powerful ORM (Object-Relational Mapping) library for Python. It simplifies database interactions by allowing you to work with Python objects instead of writing raw SQL queries. in comparison to to SQL and SQLite it defiantly automates your queries with less code and more detail.
Models and Relationships: when it comes to defining models and their relationships in SQLAlchemy it was pretty straightforward. in comparison to raw python and SQL it was easier to set up models for different entities and established relationships, such as one-to-many and many-to-many, to represent the data structure for my application. Also it made it easier to understand those relationships and their connections to the routes and migrations.
Querying the Database: SQLAlchemy querying abilities made it easy to retrieve and manipulate my data. like using ORM queries to perform operations like filtering, sorting, and aggregating data without writing complex SQL queries. Overall it was easier to grasp for me with SQLAlchemy.
Data Validation: It was pretty awesome how it was able to allow me to run my validations while making sure my data kept its integrity. SQLAlchemy gave me many ways to define rules and practices and validate data before it’s stored in my database.
The Lessons I Learned
New ways of Integration: Integrating React with Flask required a lot of planning. Setting up CORS (Cross-Origin Resource Sharing) and handling API requests correctly was super important to guarantee smooth communication between my frontend and backend. CORS was new to me but helped so much, avoiding a plethora of errors and endless googling I usually have.
State Management Complexity: As my application started to flesh out, managing state in React started to become more and more complex. Using tools like Redux can be really beneficial for larger applications like enterprise, but for my project, Reacts built-in hooks were plenty.
Error Handling: I learned so much more about proper error handling in both the frontend and backend. I learned to hoe handle errors efficiently and give much more detailed feedback to my users.
Testing and Debugging: I never used tests too much before this stack. I found implementing tests and debugging issues is so important of the development process. It saves so much time and frustration. It cut out so much of the guess work and pointed me right to the issues. Tools like pytest for Flask and testing libraries for React helped ensure my application is going to reliable and functional. If you don't use tests do your self a favor spend a couple days on it you might add a few years back on your life and drop a lot of that stress.
Conclusion
Building a full-stack application with React, Flask, and SQLAlchemy was challenging and rewarding. The technologies in this stack all have their strengths, and learning how they work together was an extremely valuable experience. As a beginner software engineer, I grew exponentially and gained confidence in my abilities, and I’m excited to find new technologies and techniques to add to my arsenal. I defiantly suggest running this gauntlet and learning this stack.
If you’re just starting your journey in full-stack development, don’t worry about the complexity. You should embrace the learning process, experiment with different tools and technologies, but most importantly, don't stop take a breather clear your head and keep building!
Subscribe to my newsletter
Read articles from Ryan Murzyn directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Ryan Murzyn
Ryan Murzyn
I am a young professional I have recently made the switch from Culinary Arts as a Chef to Big Tech as a Software Developer. Just trying to make my way in this big wide world web of opportunity.