CGWallet is a basic implementation of a digital wallet system similar to PayTM. This project includes both backend and frontend functionalities, allowing users to sign up, sign in, view their account balance, and transfer money to other users.
- User Authentication (Sign up, Sign in)
- Account Balance Inquiry
- Money Transfer between Users
- Backend: Node.js, Express.js, MongoDB, Mongoose, JSON Web Tokens (JWT)
- Frontend: React, Vite, Tailwind CSS
- Node.js (v14 or higher)
- MongoDB
-
Clone the repository
git clone https://github.com/ozearkhan/cgwallet.git cd cgwallet/backend
-
Install dependencies
npm install
-
Create a
.env
file and add your MongoDB connection string and JWT secretJWT_SECRET=your_jwt_secret_key DB_KEY=mongodb+srv://admin:password@cluster0.mongodb.net/paytm_basic
-
Start the backend server
npm start
-
Navigate to the frontend directory
cd ../frontend
-
Install dependencies
npm install
-
Start the frontend server
npm run dev
- Open your browser and go to
http://localhost:3000
for the backend andhttp://localhost:5173
for the frontend. - Sign up for a new account or sign in if you already have one.
- Use the dashboard to check your balance and transfer money to other users.
cgwallet
├── backend
│ ├── config.js
│ ├── db.js
│ ├── index.js
│ ├── package.json
│ └── routes
│ ├── account.js
│ ├── index.js
│ ├── middleware.js
│ └── user.js
└── frontend
├── index.html
├── package.json
├── postcss.config.js
├── public
├── src
│ ├── App.jsx
│ ├── index.css
│ ├── main.jsx
│ └── pages
│ ├── Dashboard.jsx
│ ├── SendMoney.jsx
│ ├── Signin.jsx
│ └── Signup.jsx
└── tailwind.config.js
Feel free to contribute to this project by submitting a pull request or opening an issue.
This project is licensed under the MIT License.
-
Configuration
- config.js: Stores sensitive information like the JWT secret and MongoDB connection string.
-
Database
- db.js: Connects to MongoDB and defines the schema for
User
andAccount
.
- db.js: Connects to MongoDB and defines the schema for
-
Server Setup
- index.js: Sets up the Express server with middleware (CORS, body-parser) and routes.
-
Routes
- routes/index.js: Main router file.
- routes/account.js: Handles account-related routes for balance inquiry and money transfer.
- routes/user.js: Manages user authentication routes (signup, signin).
-
Authentication
- middleware.js: Contains middleware functions for protecting routes with JWT authentication.
-
React and Vite Setup
- App.jsx: Configures routing for different pages using React Router.
- main.jsx: Entry point for the React application.
-
Pages
- Dashboard.jsx: Displays user dashboard with balance and user list.
- LandingPage.jsx: Home page displaying account overview, actions, and user list.
- SendMoney.jsx: Page for transferring money between accounts.
- Signin.jsx: Sign-in page for user authentication.
- Signup.jsx: Sign-up page for user registration.
-
Components
- Various components like Appbar, Balance, Users, Button, InputBox, etc., are used across different pages for UI consistency.