My Journey as a Student Developer: Building an Online Plant Store with Flask-SQLAlchemy and React.js
Published: 2023-06-13 17:25:36


**Introduction:**
Hey there, fellow student developers! Today, I want to share my exciting journey of building an online plant store using Flask-SQLAlchemy as the backend and React.js as the frontend. Join me as I dive into the world of web development and share my experiences, challenges, and triumphs in creating this web application.

First I want to say, this was a team project, and I couldn't have accomplished it without the encouragement and support of my partner. A huge shoutout to Casey, thank you so much for your patience and guidance through this process!

**Flask-SQLAlchemy: A Backend Adventure:**
As a student developer, I was thrilled to discover the power of Flask-SQLAlchemy – a perfect combination of Flask, a lightweight Python web framework, and SQLAlchemy, a flexible SQL toolkit. Together, they offered me a solid foundation for building the backend of my online plant store.

In my project, I defined models to represent the plants in my inventory and the information about plant owners. With Flask-SQLAlchemy, I created routes to handle the CRUD (Create, Read, Update, Delete) operations, allowing me to focus on the logic of my application. I was able to create routes that enabled me to add new plants, display plant details, update inventory, and even delete plants if needed. The sample code below is the route to view the plant catalog.

```
class PlantCatalog(Resource):
    def get(self):
        plants = Plant.query.all()
        plant_data = [plant.to_dict() for plant in plants]
        return make_response(jsonify(plant_data), 200)
```

**React.js: Unleashing Creativity on the Frontend:**
It had been several weeks since I had been taught about React, so I was eager to refresh my memory and further explore React.js, a JavaScript library known for its reusable component-based architecture. It was the perfect choice for creating an engaging and dynamic frontend for my online plant store.

My partner took the lead on the front end of the project. Using React.js, she started by setting up the project and organizing the components. Drawing inspiration from the guidance of experienced mentors like OpenAI, she crafted UI elements such as plant listings, a shopping cart, and a garden curation form. Each component encapsulated its logic, allowing us to create reusable and efficient code.

**Connecting the Dots: Building the API:**
As student developers, we initially struggled with connecting our Flask-SQLAlchemy backend with the React.js frontend. However, with determination and the support of our mentors, we were able to build a robust API that acted as a bridge between the two.

We utilized a combination of JavaScript's built-in fetch function as well as the popular library Axios to make HTTP requests from our React.js components. These requests were directed to the appropriate endpoints on my Flask server, where I handled them using Flask-SQLAlchemy. We could retrieve plant data, update inventory, and provide a shopping cart tool to process orders.

**Conclusion:**
For someone new to web development, building an online plant store with Flask-SQLAlchemy and React.js was great learning experience. The challenges I faced along the way only fueled my determination to overcome them. With the support of my instructor and the knowledge I gained, I successfully created a web application that allows users to explore and curate their own gardens.

To all my fellow student developers out there, I encourage you to embark on your own projects, no matter how big or small. With patience, persistence, and the support of the developer community, you'll unlock your potential and create remarkable web applications. Happy coding, and may your software development journey be filled with exciting discoveries!