Expense Tracker
Overview
The Expense Tracker application allows users to manage their expenses and view them in a dashboard with visual representations using charts. It includes functionality for user registration, login, and expense management.
Table of Contents
Prerequisites
- Node.js: Download and install Node.js
- MySQL: Download and install MySQL
- npm: Comes with Node.js installation
Installation
-
Clone the Repository git clone cd
-
Install Dependencies
Install the necessary Node.js modules:
npm install
-
Set Up the Database
- Ensure MySQL is installed and running.
- Create a new database for the application or use an existing one.
Database Configuration:
-
Copy the example environment file and update the database credentials:
-
Edit .env file with your database credentials:
DATABASE_HOST=localhost DATABASE_USER=root DATABASE_PASSWORD=your_password DATABASE=expense_tracker SESSION_SECRET=your_session_secret
-
Create the database and tables by running the SQL commands provided.
Configuration
-
Environment Variables
The application relies on environment variables for configuration. Ensure you have a .env file in the root directory with the following variables:
DATABASE_HOST=your_database_host DATABASE_USER=your_database_user DATABASE_PASSWORD=your_database_password DATABASE=your_database_name SESSION_SECRET=your_session_secret
-
Static Files
Place your static HTML, CSS, and JavaScript files in the public directory. Ensure that home.html, login.html, register.html, and dashboard.html are present.
Running the Application
-
Start the Server
Run the following command to start the server: npm start
By default, the server will start on http://localhost:3000.
-
Access the Application
- Home Page: http://localhost:3000/
- Login Page: http://localhost:3000/login
- Registration Page: http://localhost:3000/register
- Dashboard Page: http://localhost:3000/dashboard
Endpoints
- POST /login: Authenticate a user and start a session.
- POST /register: Register a new user.
- POST /expense: Add a new expense.
- DELETE /expense/:id: Delete an existing expense.
- GET /categories: Fetch all expense categories.
- POST /logout: Log out the current user.
Troubleshooting
- 404 Errors: Ensure the path in your HTML links is correct. They should point to the root (e.g., Home).
- Database Connection Issues: Verify your .env file for correct database credentials and ensure MySQL is running.
- Session Issues: Check if cookies are enabled in your browser and ensure the session configuration is correct.
License
This project is licensed under the MIT License. See the LICENSE file for details.