A full-stack MERN (MongoDB, Express.js, React.js, Node.js) application that visualizes transaction data with search, filtering, and data visualization capabilities.
- Monthly transaction listing with pagination
- Search functionality for transactions
- Monthly statistics overview
- Price range distribution visualization
- Category-wise distribution charts
- Responsive design
- Node.js (v14 or higher)
- MongoDB Atlas account
- npm (Node Package Manager)
mern-transaction-app/ mern-transaction-app/ ├── backend/ │ ├── config/ │ │ └── db.config.js │ ├── models/ │ │ └── Transaction.js │ ├── routes/ │ │ └── api.routes.js │ ├── package.json │ └── server.js └── frontend/ ├── public/ ├── src/ │ ├── components/ │ │ └── TransactionDashboard.js │ ├── App.js │ └── index.js └── package.json
- Navigate to the backend directory:
cd backend - Install dependencies:
npm install express mongoose cors dotenv
- Create a
.envfile in the backend directory:MONGODB_URI=your_mongodb_atlas_connection_string PORT=3000
- Navigate to the frontend directory:
cd frontend - Install dependencies:
npm install react-scripts recharts lucide-react @tailwindcss/forms tailwindcss postcss autoprefixer
- Set up Tailwind CSS:
npx tailwindcss init -p
- express
- mongoose
- cors
- dotenv
- react
- react-dom
- recharts
- lucide-react
- @tailwindcss/forms
- tailwindcss
- postcss
- autoprefixer
if you are trying to restart and run again make sure to kill the ports via cmd
- go to cmd - >administration
- enter the commands
- netstat -ano |findstr :3000
- find the pid which is at the right of listening paste it in the below code
- taskkill /PID XXXX /F (where xxx is the id)
- Navigate to the backend directory:
cd backend - Start the server:
The server will run on
npm start
http://localhost:3000.
- Navigate to the frontend directory:
cd frontend - Start the development server:
The frontend will run on
npm start
http://localhost:3001.
Query Parameters:
month(1-12)search(optional)page(default: 1)perPage(default: 10)
Returns monthly statistics.
Returns price range distribution data.
Returns category distribution data.
module.exports = {
content: ["./src/**/*.{js,jsx,ts,tsx}"],
theme: {
extend: {},
},
plugins: [
require('@tailwindcss/forms'),
],
}
postcss.config.js
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
Production Build
To create an optimized production build:
cd frontend
npm run build
Additional Notes
Ensure MongoDB Atlas is properly configured and accessible.
The backend expects a specific data structure in MongoDB.
The frontend uses Tailwind CSS for styling.
Charts are implemented using the Recharts library.
Troubleshooting
If MongoDB connection fails, check your connection string in .env.
If charts don't load, verify the data format in MongoDB.
For CORS issues, verify the frontend URL in backend CORS configuration.
License
This project is licensed under the MIT License.