Investfolio is a modern Progressive Web App (PWA) built using Angular 20 for the frontend and Next.js for the backend (purely API-based).
It integrates Google Sheets (powered by Google Finance API) for live stock data and uses Firebase Authentication for secure login and user management.
Investfolio connects Google Sheets, Firebase, and a Next.js backend API to deliver real-time portfolio tracking.
The Google Sheet acts as the dynamic data source where the Google Finance API fetches real-time market prices.
The Next.js backend reads, processes, and exposes that data through APIs for the Angular frontend, which displays it beautifully with a responsive dashboard.
| Layer | Technology |
|---|---|
| Frontend | Angular 20 (Standalone Components, SCSS, PWA) |
| Backend (API) | Next.js 14 (App Router, REST APIs) |
| Authentication | Firebase Auth (Email/Password + Google OAuth) |
| Data Source | Google Sheets + Google Finance API |
| Hosting | Frontend: Vercel • Backend: Render |
| Database | MongoDB |
- Live Investment Tracking via Google Finance API
- Firebase Authentication (Email, Google Login, Forgot Password)
- Google Sheets Integration for portfolio data
- Dark Mode Modern UI
- Responsive PWA (Installable on desktop and mobile)
- Next.js APIs for clean backend structure
- Offline Support via Angular Service Worker
┌────────────────────────────────────────┐
│ Angular Frontend │
│----------------------------------------│
│ • PWA + Service Worker │
│ • Firebase Auth │
│ • Portfolio Dashboard UI │
│ • Calls Backend APIs │
└────────────────────────────────────────┘
│
▼
┌────────────────────────────────────────┐
│ Next.js Backend API │
│----------------------------------------│
│ • Firebase Token Verification │
│ • Reads Google Sheets Data │
│ • Exposes REST Endpoints │
└────────────────────────────────────────┘
│
▼
┌────────────────────────────────────────┐
│ Google Sheets + Finance API │
│----------------------------------------│
│ • GOOGLEFINANCE() for live data │
│ • Source for backend API responses │
└────────────────────────────────────────┘
- Email / Password Authentication
- Password Reset via Email
- Google Sign-In
- Go to Firebase Console
- Create a new project
- Enable Email/Password and Google in Authentication → Sign-in method
- Copy your app’s configuration into your environment file
export const environment = {
production: false,
firebaseConfig: {
apiKey: "YOUR_API_KEY",
authDomain: "YOUR_PROJECT_ID.firebaseapp.com",
projectId: "YOUR_PROJECT_ID",
storageBucket: "YOUR_PROJECT_ID.appspot.com",
messagingSenderId: "YOUR_SENDER_ID",
appId: "YOUR_APP_ID"
}
};The app integrates Google Sheets as a dynamic data source for market prices and portfolio data.
Each stock entry in your sheet uses the built-in GOOGLEFINANCE() function to fetch live data directly from Google Finance.
- Google Sheets holds stock tickers and investment data
- Each row uses
GOOGLEFINANCE()for real-time market prices:=GOOGLEFINANCE("NASDAQ:AAPL", "price") - The Next.js backend connects via Google Sheets API
- Data is formatted and returned to the Angular frontend through the /api/sheets/getData endpoint
- Create a Google Cloud Project in Google Cloud Console
- Enable the Google Sheets API
- Create a Service Account
- Share your Google Sheet with the service account email (as Editor)
- Save your service account credentials
- Add these environment variables to your backend .env.local file:
GOOGLE_SHEETS_ID=your_google_sheet_id
GOOGLE_CLIENT_EMAIL=your_service_account_email
GOOGLE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nYOUR_KEY\n-----END PRIVATE KEY-----\n"MongoDB serves as the primary database for storing all user and investment-related data.
It offers flexibility and scalability, allowing efficient handling of dynamic portfolio data.
MongoDB is used to store:
- User profiles and authentication metadata
- Portfolio details and stock holdings
- Transaction history (buy/sell records)
- Performance analytics and user preferences
Typical collections used in this project include:
| Collection | Description |
|---|---|
users |
Stores Firebase user IDs and basic profile info |
portfolios |
Contains user stock holdings, average price, quantity, etc. |
transactions |
Tracks buy/sell activity for analytics |
watchlists |
Optional: user-saved tickers to monitor |
{
"userId": "8dFfQbL1jAbcdE34sT",
"symbol": "AAPL",
"quantity": 12,
"avgBuyPrice": 184.23,
"currentPrice": 188.90,
"totalValue": 2266.80,
"lastUpdated": "2025-11-01T13:00:00.000Z"
}This section walks you through setting up both the frontend (Angular 20) and backend (Next.js API) of your Investfolio project. You’ll also configure Firebase, Google Sheets API, and MongoDB for full integration.
Before you begin, make sure you have installed:
- Node.js (v18 or above)
- npm
- Angular CLI
- A Firebase project for authentication
- A Google Cloud project with Sheets API enabled
- A MongoDB Atlas database (or local MongoDB instance)
Clone the project from your GitHub repository:
git clone https://github.com/MisterStranger03/Investfolio.git
cd InvestfolioNavigate to the frontend directory and install dependencies:
cd investfolio-frontend
npm installRun the Angular development server:
npm startFrontend will run at: http://localhost:4200
- Setup Backend (Next.js API Server)
Navigate to your backend folder:
cd investfolio-backend
npm installRun the backend server:
npm run devBackend will run at: http://localhost:3000
- Configure Environment Files
🧩 Frontend – src/environments/environment.ts
Add your Firebase configuration here:
export const environment = {
production: false,
firebaseConfig: {
apiKey: "YOUR_FIREBASE_API_KEY",
authDomain: "YOUR_FIREBASE_AUTH_DOMAIN",
projectId: "YOUR_FIREBASE_PROJECT_ID",
storageBucket: "YOUR_FIREBASE_STORAGE_BUCKET",
messagingSenderId: "YOUR_FIREBASE_SENDER_ID",
appId: "YOUR_FIREBASE_APP_ID"
}
};Backend – .env.local
Create a file named .env.local inside your Next.js backend directory and add:
# Google Sheets API Configuration
GOOGLE_SHEETS_ID=YOUR_SHEET_ID
GOOGLE_CLIENT_EMAIL=YOUR_SERVICE_ACCOUNT_EMAIL
GOOGLE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nYOUR_KEY\n-----END PRIVATE KEY-----\n"
# MongoDB Configuration
MONGODB_URI=mongodb+srv://<username>:<password>@cluster.mongodb.net/myportfolio
# Optional: Firebase Token Verification
FIREBASE_PROJECT_ID=YOUR_FIREBASE_PROJECT_ID-
Connect Google Sheets
-
Open your Google Sheet containing stock tickers
-
Use the GOOGLEFINANCE() formula for real-time prices:
=GOOGLEFINANCE("NASDAQ:GOOG", "price")
-
Share the sheet with your service account email (Editor role)
-
Copy the Sheet ID from the URL and add it to .env.local
-
Connect MongoDB Atlas
-
Go to MongoDB Atlas
-
Create a free cluster
-
Whitelist your IP (or allow 0.0.0.0/0)
-
Copy your connection URI and replace and in .env.local
-
Firebase Setup
-
Go to Firebase Console
-
Enable Email/Password and Google Sign-In under Authentication → Sign-in Method
-
Copy your Firebase config credentials and paste them into environment.ts
- Build for Production
Frontend:
npm run buildBuilds optimized static files in dist/my-portfolio-frontend/.
Backend:
npm run build
npm startStarts the production server.
- Deployment (Optional)
Layer Platform Description
Frontend Vercel / Firebase Hosting Deploy built Angular app (Angular)
Backend (Next.js) Render / Vercel Deploy API routes
Database MongoDB Atlas Cloud-hosted MongoDB
- Run the Full Application
Start both servers simultaneously:
Frontend:
cd investfolio-frontend
npm startBackend:
cd investfolio-backend
npm run devThen open:
Frontend → http://localhost:4200
Backend → http://localhost:3000Summary
Component Technology Purpose
Frontend Angular 20 (PWA) Modern UI, offline-ready
Backend Next.js (API Routes) Data bridge between Firebase, MongoDB & Sheets
Database MongoDB Atlas Persistent user & portfolio data
Auth Firebase Secure authentication
✅ Your Investfolio app is now set up and running locally! You can now log in using Firebase, fetch live data from Google Sheets, and manage your portfolio seamlessly.