A web application designed to track day-to-day expenses
This web app provides an easy and interactive way to upload and track expenses
- Shows total spent for custom durations of time
- A graph gives a visual representation of the expenditure
- Gives the option to view past transactions
- Provides the option to download transaction history
- Download all files in the repository and save them in the same folder
- Open index.html using localhost (Usage of localhost is REQUIRED for the login authentication to work correctly)
NOTE: Any form of hosting will work
- Install the "Live Server" extension available on VS Code
- Keeping index.html open, click on the button with the text "Go Live" present at the bottom left side of VS Code
This will be the main container for your app's backend services
-
You can just navigate to the Firebase Console and sign in with your Google account
-
Click on "Add project" or "Create a project"
-
Enter a name for your project (eg, "Expenso") and click "Continue"
-
You can disable Google Analytics for this project to simplify the setup process
-
Click "Create project" Firebase will provision your project, which may take a moment
Here, you will register your web application with Firebase to get the necessary configuration keys that link your code to the project
-
From your project's dashboard, click the Web icon (</>) to start the setup process
-
Enter an app nickname (eg, "Expenso")
-
Click "Register app"
-
Firebase will display your unique firebaseConfig object This is critical Copy the entire object and save it temporarily in a text editor
-
After copying the configuration, click "Continue to console"
This allows users to sign up and log in securely using their email and password
-
In the left-hand menu, navigate to Build > Authentication
-
Click the "Get started" button
-
Select the "Sign-in method" tab
-
From the list of providers, click on "Email/Password"
-
Enable the "Email/Password" provider and click "Save"
Firestore is the cloud database where all your expense data will be stored
-
In the left-hand menu, navigate to Build > Firestore Database
-
Click the "Create database" button
-
In the setup wizard, select "Start in test mode." This allows initial access while you set up the project We will secure it in the next step
-
Click "Next"
-
Choose a Cloud Firestore location (select a region geographically close to you)
-
Click "Enable"
These rules are essential for security. They ensure that users can only read, write, and delete their own expense data
-
In the Firestore Database section, select the "Rules" tab
-
Delete the existing rules in the editor
-
Copy and paste the following security rules into the editor:
rules_version = '2.';
service cloudfirestore {
match /databases/{database}/documents {
// This rule targets the 'users' collection
match /users/{userId} {
// A user can only access their own document
allow read, write: if requestauth != null && requestauthuid == userId;
// This rule targets the 'expenses' collection inside a user's document
match /expenses/{expenseId} {
// A user can manage expenses only if they are logged in
// and the data belongs to them
allow read, write, create, delete: if requestauth != null && requestauthuid == userId;
}
}
}
}
- Click "Publish" to save the new rules
To allow the app to work on your local machine, you must add your local development address to Firebase's list of trusted domains
-
Go back to the Authentication section
-
Click on the "Settings" tab
-
Under the "Authorized domains" section, click "Add domain"
-
Enter 1.2.7001. and click Add
-
Click "Add domain" again and also add localhost
This is the final step to connect your application to the Firebase backend
-
Open your JavaScript files: scriptjs, viewer_scriptjs, and download_scriptjs
-
At the top of each file, locate the placeholder firebaseConfig object
-
Replace the entire placeholder object with the unique firebaseConfig object you copied in Step 2.
-
Your Firebase backend is now fully configured and secure. Your application should now be able to handle user sign-ups, logins, and data storage correctly