Express.js backend server for the Spend Wise application, providing API endpoints for transaction management and user authentication.
- 🔐 Firebase Admin SDK integration
- 📊 Transaction management API
- 🔑 API key validation
- 🌐 CORS enabled
- 📝 Request logging with Morgan
- 🔒 Environment-based configuration
- Node.js 18+
- Firebase project with Firestore
- Firebase service account credentials
- Clone the repository:
git clone <your-server-repo-url>
cd spend-wise-server- Install dependencies:
npm install- Set up environment variables:
cp .env.example .env.local- Configure your Firebase credentials in
.env.local:
FIREBASE_CLIENT_EMAIL=your-service-account-email@project.iam.gserviceaccount.com
FIREBASE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nYour Private Key Here\n-----END PRIVATE KEY-----"Start the development server with hot reload:
npm run devThe server will start on http://localhost:3001
Start the production server:
npm startGET /api/health- Server health status
GET /api/transactions- Get user transactionsPOST /api/transactions- Add new transactionDELETE /api/transactions/:id- Delete transaction (soft delete)
POST /api/validate-key- Validate user API key
| Variable | Description | Required |
|---|---|---|
FIREBASE_CLIENT_EMAIL |
Firebase service account email | Yes |
FIREBASE_PRIVATE_KEY |
Firebase service account private key | Yes |
PORT |
Server port (default: 3001) | No |
This server is configured for Vercel deployment. The vercel.json file contains the necessary configuration for serverless functions.
- Install Vercel CLI:
npm i -g vercel- Deploy:
vercel- Set environment variables in Vercel dashboard:
- Go to your project settings
- Add the environment variables from your
.env.local
For other deployment platforms, ensure:
- Environment variables are properly set
- The
server.jsfile is the entry point - CORS is configured for your frontend domain
spend-wise-server/
├── server.js # Main server file
├── firebase-config.js # Firebase configuration
├── package.json # Dependencies and scripts
├── vercel.json # Vercel deployment config
├── .env.local # Environment variables (not in git)
└── README.md # This file
- The server uses Firebase Admin SDK for secure database access
- All transactions are soft-deleted (status set to "deleted")
- API key validation checks against user documents in Firestore
- CORS is configured to allow requests from the frontend domain
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
MIT License - see LICENSE file for details