Self-paced

Explore our extensive collection of courses designed to help you master various subjects and skills. Whether you're a beginner or an advanced learner, there's something here for everyone.

Bootcamp

Learn live

Join us for our free workshops, webinars, and other events to learn more about our programs and get started on your journey to becoming a developer.

Upcoming live events

Learning library

For all the self-taught geeks out there, here is our content library with most of the learning materials we have produced throughout the years.

It makes sense to start learning by reading and watching videos about fundamentals and how things work.

Search from all Lessons


Login

Start interactive tutorial

← Back to Projects

Inventory Management App with React and TypeScript

Difficulty

  • intermediate

Average duration

4 hrs

Technologies

Difficulty

  • intermediate

Average duration

4 hrs

Technologies

📝 Instructions
📂 Project Structure

🌱 How to Start this Project?

This project uses the following base repository:
🔗 4GeeksAcademy/react-hello

We recommend opening the project using Codespaces (recommended) or Gitpod. Alternatively, you can work locally if you have Node.js installed.


📝 Instructions

This project consists of developing the frontend for an Inventory Management Application using React and TypeScript, integrating it with the backend built in FastAPI.

Before starting, we recommend setting up the backend by following this project:
🔗 Inventory Management API with FastAPI

If you don’t have it yet, you can start using test data.


📂 Project Structure

Organize the project files by creating the following folders inside src/:

/src
  /components
    ├── InventoryForm.tsx
    ├── InventoryList.tsx
  /pages
    ├── Home.tsx
    ├── AddItem.tsx
  /services
    ├── api.ts
  App.tsx
  index.tsx
  • InventoryForm.tsx: Form to add new products.
  • InventoryList.tsx: List of products fetched from the backend.
  • api.ts: File to handle HTTP requests to the backend.

1. 🔧 Install Dependencies

Run the following command to install the necessary libraries:

1npm install axios react-router-dom

2. 🔌 Connect to the Backend

In api.ts, configure Axios to interact with the FastAPI backend:

1import axios from "axios"; 2 3const API_URL = "http://localhost:8000/api"; // Replace with your backend URL 4 5export interface InventoryItem { 6 id?: number; 7 name: string; 8 quantity: number; 9 price: number; 10} 11 12export const getInventory = async (): Promise<InventoryItem[]> => { 13 const response = await axios.get(`${API_URL}/items`); 14 return response.data; 15}; 16 17export const addInventoryItem = async (item: InventoryItem) => { 18 await axios.post(`${API_URL}/items`, item); 19};

3. 🗂️ Display the Product List

In InventoryList.tsx, fetch and display products from the backend.

4. 📝 Add New Products

In InventoryForm.tsx, create a form to add products to the inventory.

5. 🚏 Set Up Routing and Pages

In App.tsx, configure the routes. It might look something like this:

1import { BrowserRouter as Router, Routes, Route } from "react-router-dom"; 2import InventoryList from "./components/InventoryList"; 3import InventoryForm from "./components/InventoryForm"; 4 5function App() { 6 return ( 7 <Router> 8 <Routes> 9 <Route path="/" element={<InventoryList />} /> 10 <Route path="/add" element={<InventoryForm />} /> 11 </Routes> 12 </Router> 13 ); 14} 15 16export default App;

🎨 Improve the User Experience

🚀 Bonus: Deploy Your Application


🎉 Congratulations! You now have a fully functional Inventory Management Application built with React, TypeScript, and FastAPI. 🚀

Signup and get access to this project for free

We will use it to give you access to your account.
Already have an account? Login here.

By signing up, you agree to the Terms and conditions and Privacy policy.

Difficulty

  • intermediate

Average duration

4 hrs

Technologies

Difficulty

  • intermediate

Average duration

4 hrs

Technologies

Difficulty

  • intermediate

Average duration

4 hrs

Technologies

Difficulty

  • intermediate

Average duration

4 hrs

Technologies

Signup and get access to this project for free

We will use it to give you access to your account.
Already have an account? Login here.

By signing up, you agree to the Terms and conditions and Privacy policy.

Difficulty

  • intermediate

Average duration

4 hrs

Technologies

Difficulty

  • intermediate

Average duration

4 hrs

Technologies

Supplementary Material

In order to prepare better for completing this exercises, we suggest the following materials

Lesson

Learn React here: React JS Tutorial

Lesson

React Hooks Explained

Exercise

Learn React.js Tutorial and Interactive Exercises

Project

Todolist Application Using React and Fetch