Day 1 Guide: Launch Your MERN Stack Expense Tracker with Vite + React Frontend

Vishal GuptaVishal Gupta
5 min read

Hey devs! ๐Ÿ‘‹
Welcome to Day 1 of my journey building a fully functional Expense Tracker Website using the MERN stack โ€” MongoDB, Express.js, React.js, and Node.js.

The goal? Build a modern, responsive, and intelligent app that allows users to track their income and expenses, view visual breakdowns, and manage personal finances effortlessly.

Today, I focused on laying a solid frontend foundation. This is where everything begins, and getting the architecture right from the start is crucial for building a scalable and maintainable application.


๐ŸŒŸ Why MERN Stack?

The MERN stack is a powerful and popular full-stack JavaScript solution used to build robust and modern web applications. Here's why it's the perfect choice for this project:

โœ… Unified Language โ€“ JavaScript

Use JavaScript across the stack โ€” from frontend (React) to backend (Node.js) to database queries (MongoDB). This simplifies development and accelerates productivity.

โš›๏ธ React.js โ€“ Rich UI Components

React enables us to build dynamic, reusable, and performant user interfaces with powerful tools like Hooks and Context API.

๐ŸŒ Express.js โ€“ Lightweight Backend Framework

Express offers a minimal and flexible Node.js framework that handles routing, middleware, and server logic efficiently.

๐Ÿƒ MongoDB โ€“ NoSQL Flexibility

MongoDB stores data in JSON-like documents, which makes it ideal for applications that handle varied and evolving data structures (like expenses, users, categories).

๐Ÿš€ Fast Prototyping

MERN enables rapid development and iteration, perfect for MVPs, hackathons, and scalable product builds.

๐Ÿ”’ Scalable & Secure

Using tools like JWT, bcrypt, and Mongoose, MERN apps can scale easily with proper authentication, validation, and data modeling.

โœ… Goals for Day 1

  • Initialize the frontend using React + Vite

  • Organize the folder structure for clean code separation

  • Build basic routing with React Router

  • Create the Auth pages: Login & Signup

  • Add reusable components like Input and ProfilePic

  • Implement an AuthLayout for consistent UI

  • Plan Dashboard routes for Home, Income, and Expense pages


โš™๏ธ Step 1: Setting Up the React App with Vite

Why Vite? It offers a faster development experience with optimized builds and lightning-fast HMR.

bashCopyEditnpm create vite@latest expense-tracker-frontend --template react
cd expense-tracker-frontend
npm install
npm run dev

Boom ๐Ÿ’ฅ โ€” We had a blazing fast React app running in seconds.


๐Ÿงฑ Step 2: Folder Structure for Scalable Development

To avoid future chaos and promote clean separation of concerns, I created the following directory structure:

bashCopyEditsrc/
โ”œโ”€โ”€ assets/         # Images, SVGs, logos
โ”œโ”€โ”€ components/     # Reusable UI components (Input, Button, Navbar, ProfilePic)
โ”œโ”€โ”€ contexts/       # React Context (e.g., AuthContext, ExpenseContext)
โ”œโ”€โ”€ hooks/          # Custom hooks (e.g., useAuth, useForm)
โ”œโ”€โ”€ pages/
โ”‚   โ”œโ”€โ”€ Auth/       # Login and Signup pages
โ”‚   โ””โ”€โ”€ Dashboard/  # Home, Income, Expense pages
โ”œโ”€โ”€ utils/          # Utility functions (validators, formatters)
โ”œโ”€โ”€ App.jsx         # App routing setup
โ”œโ”€โ”€ main.jsx        # App entry point

This structure keeps things modular, maintainable, and future-ready.


๐Ÿ› ๏ธ Step 3: Routing with React Router

I configured routing for the key pages using react-router-dom. Here's the routing logic inside App.jsx:

import React from "react";
import {
  BrowserRouter as Router,
  Routes,
  Route,
  Navigate,
} from "react-router-dom";
import Login from "./pages/Auth/Login";
import Signup from "./pages/Auth/Signup";
import Home from "./pages/Dashboard/Home";
import Income from "./pages/Dashboard/Income";
import Expense from "./pages/Dashboard/Expense";

const App = () => {
  return (
    <div>
      <Router>
        <Routes>
          <Route path="/" element={<Root />} />
          <Route path="/login" exact element={<Login />} />
          <Route path="/signup" exact element={<Signup />} />
          <Route path="/dashboard" exact element={<Home />} />
          <Route path="/income" exact element={<Income />} />
          <Route path="/expense" exact element={<Expense />} />
        </Routes>
      </Router>
    </div>
  );
};

This sets up the routing for both the authentication flow and the dashboard flow.


๐Ÿง‘โ€๐Ÿ’ผ Step 4: Authentication Pages and Layout

I created an AuthLayout component to wrap both Login and Signup forms with consistent styling and layout logic. This will help us:

  • Maintain consistent design

  • Avoid repetition

  • Improve UX structure

๐Ÿ” Login & Signup Forms

Built simple, clean, and responsive forms with reusable Input components.

๐Ÿ‘ค ProfilePic Component

The ProfilePic component allows users to upload or preview an avatar during signup โ€” this will be integrated later with backend storage. Adding this early on sets the tone for a personalized user experience.


๐Ÿ“‚ Planned Dashboard Pages

Weโ€™ve scaffolded the routing for the Dashboard section, which includes:

  • Home Page: Will show an overview of all transactions and a summary.

  • Income Page: For viewing and adding income transactions.

  • Expense Page: For tracking all expenses.

We havenโ€™t built these pages yet โ€” theyโ€™re placeholders for now โ€” but having their routes in place will streamline development later.


๐Ÿ“ Summary of Day 1

TaskStatus
React + Vite Setupโœ… Done
Folder Structureโœ… Done
React Router Configurationโœ… Done
Auth Pages (Login/Signup)โœ… Done
Reusable Componentsโœ… Done
AuthLayout Integrationโœ… Done
Dashboard Routes Plannedโœ… Done

๐Ÿ”ฎ Whatโ€™s Next (Day 2 Goals)

On Day 2, the plan is to:

  • Set up the Node.js + Express backend

  • Initialize a MongoDB database

  • Create User and Expense models

  • Implement authentication APIs

  • Create Multiple routes such as Authentication, Dashboard, Expense and Income

  • Setup the folder structure for the backend - models, configs, controllers, middlewares , routes and uploads alongwith basic node configuration files


๐Ÿš€ Final Thoughts

First impressions matter โ€” even in code. By starting with a clean architecture, reusable components, and a structured layout, Iโ€™ve set the foundation for a robust and scalable app. Whether you're new to MERN or experienced, I hope you find this journey useful and inspiring.

Stay tuned for Day 2, where we bring this app to life with a powerful backend!

If youโ€™d like to collaborate or want the GitHub repo link once itโ€™s live, feel free to reach out! ๐Ÿ’ฌ

Hereโ€™s my social links -

Email - abhimanyug987@gmail.com

LinkedIn - https://www.linkedin.com/in/vishal-gupta-16018719a/

GitHub - https://github.com/vishalgupta-02

0
Subscribe to my newsletter

Read articles from Vishal Gupta directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Vishal Gupta
Vishal Gupta

Hi, I'm Vishal Gupta, a passionate and self-driven Full-Stack Developer with a strong command of the MERN stack (MongoDB, Express.js, React.js, Node.js). I love turning complex problems into clean, scalable solutions through elegant code and user-friendly interfaces. With hands-on experience building real-world applications like MedEase, TripGenius, and now this Expense Tracker, I strive to build software thatโ€™s not only functional but also impactful. Whether it's creating secure authentication systems, responsive UI components, or integrating AI-powered features, I aim to deliver value with every line of code. ๐Ÿ”ง Key Skills: Frontend: React.js, Vite, Tailwind CSS, ShadCN, Context API Backend: Node.js, Express.js, MongoDB, JWT, REST APIs Dev Tools: Git & GitHub, Postman, Firebase, Vercel Soft Skills: Problem-solving, communication, and a strong desire to learn & grow I believe in continuous learning and building meaningful products that solve real-life problems. Currently, Iโ€™m open to opportunities where I can collaborate, innovate, and contribute to exciting web development projects.