Skip to content

savoon bank application is a banking application built with some help from amazon@ (claude 3.5 model) as a demo app building an experience with banking apps deployment across the entire deployment lifecycle as a cloud/devops engineer

Notifications You must be signed in to change notification settings

Goziee-git/savoon-bank

Repository files navigation

SAVOON BANK Application đź’´

A full-stack application built with Node.js, Express, React, and SQLite that allows users to manage credits and transactions. This application uses SQLite for its database, making it lightweight and easy to set up with no additional database server required.

Features

  • User Authentication (Register/Login)
  • JWT Token-based Authorization
  • Automatic Credit Bonus on Signup
  • Credit Balance Management
  • Transaction History
  • Protected Routes
  • Responsive Design
  • RESTful API
  • Real-time Balance Updates
  • SQLite Database with Sequelize ORM

Tech Stack

Backend

  • Node.js
  • Express.js
  • SQLite3 (lightweight SQL database)
  • Sequelize ORM
  • JWT for Authentication
  • bcryptjs for Password Hashing
  • Express Validator
  • Cors
  • Dotenv for Environment Variables
  • Morgan for Logging

Frontend

  • React (Create React App)
  • React Router v6
  • Context API for State Management
  • Axios for HTTP Requests
  • Custom CSS

Getting Started

Prerequisites

Before you begin, ensure you have installed:

  • Node.js (v14 or higher)
  • npm (v6 or higher) or yarn
  • Git

Installation Steps

  1. Clone the repository:
git clone <repository-url>
cd finance-app
  1. Set up the Backend:
# Navigate to backend directory
cd backend

# Install dependencies
npm install

# Create database directory
mkdir -p database

# Create .env file
cat > .env << EOL
PORT=5000
JWT_SECRET=your_secure_jwt_secret_here
JWT_EXPIRE=1hr
SIGNUP_CREDIT_AMOUNT=1000
EOL

JWT token for backend access

to generate a JWT token for backend access run the following command

node -e "console.log(require('crypto').randomBytes(64).toString('hex'))"

#navigate to the backend/.env file and edit the JWT_SECRET= <your-generated-jwt-secret>
  1. Set up the Frontend:
# Navigate to frontend directory
cd ../frontend

# Install dependencies
npm install

# Create .env file
cat > .env << EOL
REACT_APP_API_URL=http://localhost:5000
EOL

Database Setup

The SQLite database will be automatically created when you first start the server. The database file will be located at: /backend/database/finance.sqlite

To manually initialize the database:

cd backend
node -e "require('./config/database').sync()"

Running the Application

  1. Start the Backend Server:
# From the backend directory
cd backend
npm run dev

# You should see:
# Database synced successfully
# Server running on port 5000
  1. Start the Frontend Development Server:
# From the frontend directory
cd frontend
npm start

# The application will open in your browser at http://localhost:3000

Verifying the Setup

  1. Check Database Creation:
# From the backend directory
ls database/finance.sqlite
# Should show the SQLite database file
  1. Test API Connection:
# Test the API health endpoint
curl http://localhost:5000/api/health
# Should return: {"status": "ok"}

Database Management

Viewing Database Content

You can use SQLite command line tool to view the database:

# Install SQLite command line tool if needed
# Ubuntu/Debian:
sudo apt-get install sqlite3

# Access the database
sqlite3 backend/database/finance.sqlite

# Common SQLite commands:
.tables                    # List all tables
.schema Users             # Show Users table schema
.schema Transactions      # Show Transactions table schema
SELECT * FROM Users;      # View all users
SELECT * FROM Transactions;  # View all transactions
.quit                     # Exit SQLite CLI

API Endpoints

Authentication Routes

  • POST /api/auth/register - Register a new user

    curl -X POST http://localhost:5000/api/auth/register \\
      -H "Content-Type: application/json" \\
      -d '{"name":"Test User","email":"[email protected]","password":"password123"}'
  • POST /api/auth/login - Login user

    curl -X POST http://localhost:5000/api/auth/login \\
      -H "Content-Type: application/json" \\
      -d '{"email":"[email protected]","password":"password123"}'
  • GET /api/auth/me - Get logged in user info

    curl -X GET http://localhost:5000/api/auth/me \\
      -H "Authorization: Bearer YOUR_JWT_TOKEN"

Transaction Routes

  • GET /api/transactions - Get all transactions
  • GET /api/transactions/:id - Get specific transaction
  • POST /api/transactions/spend - Create a new spending transaction

Troubleshooting

Common Issues and Solutions

  1. Database Connection Issues:
# Check if database file exists
ls backend/database/finance.sqlite

# Check file permissions
ls -l backend/database/finance.sqlite

# Ensure database directory exists
mkdir -p backend/database
  1. Server Won't Start:
# Check if port 5000 is already in use
lsof -i :5000
# Kill process if needed
kill -9 <PID>
  1. Database Reset:
#Remove and recreate database
rm backend/database/finance.sqlite
node -e "require('./config/database').sync()"

Development

Backend Development

To add new features to the backend:

  1. Create new models in /backend/models using Sequelize syntax
  2. Add new controllers in /backend/controllers
  3. Create new routes in /backend/routes
  4. Update server.js if needed

Frontend Development

To add new features to the frontend:

  1. Add new components in /frontend/src/components
  2. Create new pages in /frontend/src/pages
  3. Update context if needed in /frontend/src/context
  4. Modify App.js to include new routes

Testing

Backend Testing

cd backend
npm test

Frontend Testing

cd frontend
npm test

Building for Production

Backend

cd backend
npm run build

Frontend

cd frontend
npm run build

Deployment

  1. Deploy Backend:

    • Configure environment variables
    • Ensure SQLite file permissions are correct
    • Deploy to hosting service (e.g., Heroku, AWS, DigitalOcean)
  2. Deploy Frontend:

    • Build the React application
    • Deploy static files to hosting service
    • Configure environment variables correctly

Support

For support, please open an issue in the repository or contact the development team.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • React Documentation
  • Express.js Documentation
  • Node.js Documentation
  • Sequelize Documentation
  • SQLite Documentation
  • JWT Documentation

About

savoon bank application is a banking application built with some help from amazon@ (claude 3.5 model) as a demo app building an experience with banking apps deployment across the entire deployment lifecycle as a cloud/devops engineer

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •