A full-stack personal expense management application built with React and FastAPI, featuring JWT authentication, secure password hashing, user-isolated expense management, income tracking, and dashboard visualization.
Expense Pro was built to explore how a complete web application can be structured across a modern frontend, REST API, authentication layer, database, and containerized development environment.
Rather than treating the project as a collection of frontend pages and database operations, the system is structured around a clear separation between client, API, authentication, business logic, and persistence.
Managing personal expenses involves more than simply storing numbers.
A useful expense management system needs to ensure that:
- Users can securely authenticate
- Users can only access their own financial records
- Expenses can be created, updated, and deleted
- Income can be tracked alongside expenses
- Data can be categorized and visualized
- The frontend and backend remain separated
- The application can be reproduced consistently across environments
Expense Pro addresses these requirements through a React frontend communicating with a FastAPI backend over HTTP.
The backend handles authentication, validation, business logic, and database operations while the frontend focuses on user interaction and visualization.
Expense Pro
│
┌──────────────┴──────────────┐
│ │
▼ ▼
┌─────────────────┐ ┌─────────────────┐
│ React + Vite │ │ FastAPI Backend │
│ │ HTTP │ │
│ Dashboard │─────────▶│ REST API │
│ Authentication │ Axios │ JWT Auth │
│ Expense UI │ │ Validation │
│ Charts │ │ Business Logic │
└─────────────────┘ └────────┬────────┘
│
SQLAlchemy ORM
│
▼
┌─────────────────┐
│ SQLite │
│ │
│ Users │
│ Expenses │
│ Categories │
└─────────────────┘
The application is also containerized using Docker Compose:
┌────────────────────────────────────────────────────┐
│ Docker Compose │
│ │
│ ┌──────────────┐ ┌────────────────┐ │
│ │ Caddy edge │───▶│ nginx + static │ │
│ │ HTTPS :443 │ │ React build │ │
│ └──────┬───────┘ └────────────────┘ │
│ │ │
│ └───────────▶ FastAPI :8000 │
│ │ │
│ SQLite │
└────────────────────────────────────────────────────┘
Expense Pro provides account-based authentication using:
- User registration
- Email validation
- Password hashing with bcrypt
- JWT-based authentication
- Protected API endpoints
- Current-user resolution from JWT identity
Authentication flow:
User
│
▼
Login
│
▼
FastAPI
│
├── Find user
├── Verify password
└── Generate JWT
│
▼
Frontend
│
▼
Protected API requests
│
▼
JWT verification
│
▼
Authenticated user
Authenticated users can manage their own expenses.
Record:
- Amount
- Description
- Category
Retrieve expenses belonging to the authenticated user.
Modify an existing expense.
Remove an expense belonging to the authenticated user.
The backend verifies ownership using the authenticated user's identity before modifying or deleting records.
JWT
↓
Current User
↓
User ID
↓
Expense.user_id
↓
Authorized operation
This prevents one authenticated user from directly accessing another user's expense records through the API.
Users can:
- View their stored income
- Update their income
Income is associated with the authenticated user and stored in the database.
This provides the foundation for comparing income and spending within the dashboard.
The frontend includes dashboard components for presenting financial information visually.
The application uses:
- Chart.js
- react-chartjs-2
This allows expense data to be transformed from raw database records into visual summaries.
The current database contains models for users, expenses, and categories.
User
├── id
├── name
├── email
├── password_hash
├── income
└── created_at
Expense
├── id
├── amount
├── description
├── category
├── date
└── user_id
Category
├── id
├── name
└── user_id
SQLAlchemy is used as the ORM between the FastAPI application and the SQLite database.
Security is handled primarily at the backend layer.
Passwords are never stored as plaintext.
They are hashed using bcrypt before being stored in the database.
Authenticated requests use JSON Web Tokens.
The backend validates the token and resolves the associated user before allowing access to protected endpoints.
Expense queries are scoped to the authenticated user's ID.
For example:
GET /api/expenses
│
▼
JWT verification
│
▼
Current user identified
│
▼
Query expenses for that user
Sensitive configuration such as the JWT signing secret is provided through environment variables rather than being committed to source control.
The current configuration is intended for development and learning. Production deployment would require additional hardening such as restricted CORS origins, HTTPS, stronger secret management, rate limiting, and more robust token lifecycle management.
- Python
- FastAPI
- Uvicorn
- SQLAlchemy
- Pydantic
- Python-JOSE
- Passlib
- bcrypt
- React
- Vite
- Axios
- React Router
- Chart.js
- react-chartjs-2
- SQLite
- Docker
- Docker Compose
- Git
- GitHub
ExpensePro/
│
├── backend/
│ ├── app/
│ │ ├── auth.py
│ │ ├── database.py
│ │ ├── main.py
│ │ │
│ │ ├── models/
│ │ │ ├── category.py
│ │ │ ├── expense.py
│ │ │ └── user.py
│ │ │
│ │ └── schemas/
│ │ ├── expense.py
│ │ └── user.py
│ │
│ ├── Dockerfile
│ └── requirements.txt
│
├── frontend/
│ ├── public/
│ ├── src/
│ │ ├── components/
│ │ │ ├── Navbar.jsx
│ │ │ └── PieChart.jsx
│ │ │
│ │ ├── pages/
│ │ │ ├── Dashboard.jsx
│ │ │ └── Login.jsx
│ │ │
│ │ ├── api.js
│ │ ├── App.jsx
│ │ └── main.jsx
│ │
│ ├── Dockerfile
│ ├── package.json
│ └── vite.config.js
│
├── docs/
│ └── api.md
│
├── docker-compose.yml
├── .env.example
├── .gitignore
└── README.md
You can run Expense Pro either locally or through Docker.
Install:
- Docker
- Docker Compose
Install:
- Python 3.11+
- Node.js 20+
- npm
Clone the repository:
git clone https://github.com/shubham-kain07/ExpensePro.git
cd ExpenseProCreate a .env file from the example:
cp .env.example .envSet a secure value for:
SECRET_KEY=replace_with_a_long_random_secretStart the application:
docker compose up --build -dThe edge proxy serves the production static build and the API through Caddy:
Application → https://localhost
Health → https://localhost/health
The backend and frontend containers are internal-only; they are not published directly.
Caddy uses its internal CA for local HTTPS, so the browser will warn about the
self-signed certificate. For a real deployment, point Caddy at your domain and
replace tls internal with a trusted certificate configuration.
To stop the application:
docker compose downThis preserves the persistent database volume and the host backups/ directory.
Do not use docker compose down -v unless you intend to delete the database.
Create an on-demand backup:
docker compose exec backend python scripts/backup_db.pyBackups are written to ./backups/ and pruned to the last 7 by default.
For production, copy backups to storage outside the Docker host.
Create a virtual environment:
python -m venv venvActivate it on Linux/macOS:
source venv/bin/activateFor Fish shell:
source venv/bin/activate.fishInstall dependencies:
pip install -r backend/requirements.txtCreate .env:
SECRET_KEY=replace_with_a_long_random_secretStart FastAPI:
uvicorn backend.app.main:app --reloadDepending on the local working directory and Python import configuration, the application may instead be started from inside backend/:
cd backend
uvicorn app.main:app --reloadOpen another terminal:
cd frontend
npm install
npm run devThe frontend will be available at:
http://localhost:5173
For local Vite development against the backend on port 8000, explicitly allow
the Vite origins in .env:
CORS_ORIGINS=http://localhost:5173,http://127.0.0.1:5173The Docker production path is same-origin and leaves CORS_ORIGINS empty.
The backend exposes REST endpoints for authentication, users, expenses, and income.
POST /api/auth/signup
POST /api/auth/login
GET /api/me
GET /api/user/income
PUT /api/user/income
GET /api/expenses
POST /api/expenses
PUT /api/expenses/{expense_id}
DELETE /api/expenses/{expense_id}
Detailed API information is available in:
docs/api.md
FastAPI also provides interactive API documentation when the backend is running:
http://localhost:8000/docs
Expense Pro was built as a practical exploration of full-stack application architecture.
The project focuses on keeping responsibilities separated:
React
↓
HTTP / API
↓
FastAPI
↓
Authentication
↓
Business Logic
↓
SQLAlchemy
↓
SQLite
This separation makes it possible to change individual layers without requiring the entire application to be rewritten.
The Docker setup further allows the frontend and backend environments to be reproduced consistently.
Potential future improvements include:
- PostgreSQL support
- Refresh-token authentication
- Improved token lifecycle management
- Server-side pagination
- Advanced expense filtering
- Dedicated category management
- Recurring expenses
- Monthly financial reports
- Export to CSV/PDF
- Improved dashboard analytics
- Automated backend tests
- Production deployment configuration
- More restrictive production CORS configuration
These are planned improvements and are not represented as currently implemented functionality.
Expense Pro was built to explore practical software engineering concepts including:
- REST API design
- Authentication and authorization
- JWT-based security
- Password hashing
- Database modelling
- SQLAlchemy ORM
- Pydantic validation
- User-level data isolation
- React application architecture
- API integration
- Data visualization
- Docker containerization
- Docker Compose
- Technical documentation
The project is intentionally structured as a complete application rather than a collection of isolated frontend and backend exercises.
Shubham Kain
Computer Science & Technology
GitHub: @shubham-kain07
This project is currently developed as a personal and academic software engineering project.
License information will be added when the project reaches its first public release.