A backend service for a finance tracking application that provides APIs for Transaction management, budget tracking, and user authentication.
- User authentication and authorization (JWT)
- Transaction tracking and management
- Budget creation and monitoring
- Dashboard analytics and reports
- MongoDB integration for primary data
- PostgreSQL (Supabase) integration for analytics
- RESTful API endpoints
- Node.js (v16 or higher)
- npm or yarn
- MongoDB Atlas account or local MongoDB
- Supabase account for PostgreSQL
- Clone the repository:
git clone https://github.com/DemonicAK/PocketPortrait-backend.git
cd PocketPortrait-backend- Install dependencies:
npm install- Set up environment variables:
cp .env.example .env- Configure your
.envfile with:
PORT=5000
NODE_ENV=development
# MongoDB
MONGODB_URI=your_mongodb_connection_string
# PostgreSQL (Supabase)
SUPABASE_URL=your_supabase_url
SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_key
SUPABASE_DB_URL=your_supabase_db_connection_string
# JWT
JWT_SECRET=your_jwt_secret
JWT_EXPIRES_IN=7d
# Frontend URL (for CORS)
FRONTEND_URL=http://localhost:3000
npm run devnpm run build
npm startnpm run type-checkPOST /api/auth/register- User registrationPOST /api/auth/login- User login
GET /api/transactions- Get all Transactions for user
POST /api/transactions- Create new TransactionPUT /api/transactions/:id- Update TransactionDELETE /api/transactions/:id- Delete TransactionGET /api/transactions/dashboard- Get dashboard statistics
GET /api/budgets- Get budgets for current monthPOST /api/budgets- Create or update budgetGET /api/budgets/alerts- Get budget alerts
GET /health- Server health status
- Users: User authentication data
- Transactions: Transaction records
- Budgets: Budget limits and tracking
- monthly_reports: Aggregated monthly data
- user_summaries: User lifetime statistics
backend/
├── src/
│ ├── config/
│ │ ├── mongodb.ts
│ │ └── postgres.ts
│ ├── middleware/
│ │ └── auth.ts
│ ├── models/
│ │ ├── User.ts
│ │ ├── Transaction.ts
│ │ └── Budget.ts
│ ├── routes/
│ │ ├── auth.ts
│ │ ├── Transactions.ts
│ │ └── budgets.ts
│ ├── types/
│ │ └── index.ts
│ └── server.ts
├── .env
├── package.json
├── tsconfig.json
└── README.md
- Food
- Rent
- Shopping
- Transport
- Entertainment
- Healthcare
- Other
- UPI
- Credit Card
- Debit Card
- Cash
- Net Banking
The server will start on the port specified in your .env file (default: 5000).
The application connects to both MongoDB (primary data) and PostgreSQL/Supabase (analytics) on startup.
All protected routes require a Bearer token in the Authorization header:
Authorization: Bearer <your-jwt-token>
- MongoDB: Create a MongoDB Atlas cluster or use local MongoDB
- Supabase: Create a new Supabase project for PostgreSQL
- JWT Secret: Generate a secure random string for JWT signing
- CORS: Ensure your frontend URL is set in the
.envfile for CORS configuration
- Fork the repository
- Create a feature branch
- Make your changes
- Test your changes
- Submit a pull request
This project is licensed under the MIT License.