A modern analytics dashboard built with React, Node.js, and PostgreSQL, featuring real-time data visualization, order management, and comprehensive analytics.
- 📊 Real-time analytics visualization
- 📦 Order management system
- 📈 Revenue tracking by state
- 🌍 Multi-currency support (Default: INR)
- 🔐 Secure authentication system
- 📱 Responsive design
- 🎨 Modern UI with Tailwind CSS
- 🐳 Docker support for easy deployment
- Clone the repository:
git clone <repository-url>
cd analytics-dashboard
- Make the Docker script executable:
chmod +x docker.sh
- Start the application:
./docker.sh start
The application will be available at:
- Frontend: http://localhost
- Backend API: http://localhost:5001
- Make the startup script executable:
chmod +x start.sh
- Run the startup script:
./start.sh
- Node.js (v14 or higher)
- npm (v6 or higher)
- PostgreSQL (v12 or higher)
- Docker and Docker Compose (for Docker setup)
Copy the example environment file:
cp server/.env.example server/.env
Update the following variables in server/.env
:
PORT=5001
JWT_SECRET=your_jwt_secret_key
DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_HOST=localhost
DB_PORT=5432
DB_NAME=analytics_dashboard
./docker.sh start # Start all services
./docker.sh stop # Stop all services
./docker.sh restart # Restart all services
./docker.sh build # Rebuild all services
./docker.sh logs # Show logs
./docker.sh ps # Show running services
./docker.sh clean # Remove all containers and volumes
./docker.sh db-reset # Reset the database
./start.sh # Start both client and server
npm run dev # Start development server
npm run build # Build for production
npm run test # Run tests
analytics-dashboard/
├── client/ # React frontend
│ ├── src/
│ │ ├── components/ # Reusable components
│ │ ├── pages/ # Page components
│ │ ├── store/ # State management
│ │ └── utils/ # Utility functions
│ ├── public/ # Static files
│ └── Dockerfile # Client Docker configuration
├── server/ # Node.js backend
│ ├── config/ # Configuration files
│ ├── database/ # Database schemas and migrations
│ ├── middleware/ # Express middleware
│ ├── routes/ # API routes
│ └── Dockerfile # Server Docker configuration
├── docker-compose.yml # Docker composition
├── start.sh # Local startup script
└── docker.sh # Docker management script
Create a new migration:
cd server
node database/migrate.js create add-new-table
Run migrations:
node database/migrate.js up
Run server tests:
cd server
npm test
Run client tests:
cd client
npm test
- Build the images:
./docker.sh build
- Start the services:
./docker.sh start
- Build the client:
cd client
npm run build
- Start the server:
cd server
NODE_ENV=production npm start
- JWT authentication
- Rate limiting
- CORS protection
- SQL injection prevention
- XSS protection
- Security headers
- Input validation
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- If containers fail to start:
./docker.sh logs
- Reset the environment:
./docker.sh clean
./docker.sh start
- Reset the database:
./docker.sh db-reset
- Check database logs:
docker-compose logs db
-
Port conflicts:
- Ensure ports 80, 5001, and 5432 are available
- Change ports in docker-compose.yml if needed
-
Permission issues:
- Ensure scripts are executable:
chmod +x *.sh
- Run with sudo if needed (Docker commands)
- Ensure scripts are executable:
-
Database connection fails:
- Check PostgreSQL credentials in .env
- Ensure database service is running