A full-stack TypeScript application for managing cold storage facilities with role-based dashboards for Owners and Customers.
Frontend:
- React 18
- TypeScript
- Vite
- Axios
Backend:
- Node.js
- Express
- TypeScript
- PostgreSQL (Aiven)
- View all storage units with capacity, temperature, humidity, and current load
- Monitor unit utilization with visual progress bars
- Access all bills with customer information
- View financial summary (total revenue, active customers, average utilization)
- View all stored products with quantities
- Access detailed product information including storage location and conditions
- View bills history
- See summary statistics
ColdBox/
├── client/ # React frontend
│ ├── src/
│ │ ├── components/ # React components
│ │ │ ├── Header.tsx
│ │ │ ├── OwnerDashboard.tsx
│ │ │ └── CustomerDashboard.tsx
│ │ ├── services/ # API service layer
│ │ │ └── api.ts
│ │ ├── types/ # TypeScript types
│ │ │ └── index.ts
│ │ ├── App.tsx # Main app component
│ │ ├── App.css # Styles
│ │ └── main.tsx # Entry point
│ ├── package.json
│ ├── tsconfig.json
│ └── vite.config.ts
│
├── server/ # Express backend
│ ├── src/
│ │ ├── config/ # Configuration files
│ │ │ └── database.ts
│ │ ├── routes/ # API routes
│ │ │ ├── user.ts
│ │ │ ├── owner.ts
│ │ │ └── customer.ts
│ │ ├── types/ # TypeScript types
│ │ │ └── index.ts
│ │ └── index.ts # Entry point
│ ├── package.json
│ ├── tsconfig.json
│ └── .env.example
│
└── package.json # Root package.json
GET /api/user/:userId- Get user by IDGET /api/user- Get all users
GET /api/owner/:ownerId/storage-units- Get all storage unitsGET /api/owner/:ownerId/bills- Get all bills with customer infoGET /api/owner/:ownerId/financial-summary- Get financial summary
GET /api/customer/:customerId/products- Get all productsGET /api/customer/:customerId/products/:productId/details- Get product storage detailsGET /api/customer/:customerId/bills- Get all billsGET /api/customer/:customerId/summary- Get customer summary
- Clean, modern design with a professional color scheme
- Responsive layout that works on different screen sizes
- Role-based views that automatically adapt based on user role
- Interactive elements (expandable product details)
- Visual indicators for storage unit utilization
This application is configured to deploy as a single web service on Render, serving both the backend API and frontend static files.
- A Render account (https://render.com)
- PostgreSQL database (Aiven or Render's managed PostgreSQL)
- GitHub/GitLab repository with your code
-
Push your code to GitHub/GitLab
-
Create a new Web Service on Render:
- Connect your repository
- Use the following settings:
- Build Command:
npm install && npm run build - Start Command:
npm start - Environment:
Node
- Build Command:
-
Set Environment Variables: Add these environment variables in Render dashboard:
NODE_ENV=production PORT=5000 DB_HOST=your-database-host DB_PORT=5432 DB_NAME=defaultdb DB_USER=avnadmin DB_PASSWORD=your-password -
Deploy:
- Render will automatically build and deploy your application
- The build process will:
- Install all dependencies
- Build the React frontend
- Build the TypeScript backend
- Start the server which serves both API and frontend
-
Access your app:
- Your app will be available at
https://your-app-name.onrender.com - The frontend will be served from the root path
- API endpoints will be available at
/api/*
- Your app will be available at
You can also use the included render.yaml file for automated deployment:
- Push the
render.yamlfile to your repository - In Render dashboard, select "New > Blueprint"
- Connect your repository
- Render will automatically detect and use the configuration
- In production (
NODE_ENV=production), the Express server serves the React build files as static assets - All routes starting with
/apiare handled by the backend API - All other routes serve the React app (for client-side routing)
- The build process compiles both frontend and backend before deployment
If you encounter TypeScript errors during Render build:
- Ensure
.npmrcis committed: The.npmrcfile ensures devDependencies are installed (required for TypeScript compilation) - Check Build Command: Use
npm install && npm run build(not justnpm run build) - Verify Environment Variables: Make sure all database credentials are set correctly
- Check Build Logs: Look for "npm ci --include=dev" in the logs to confirm devDependencies are being installed
Common error: Could not find a declaration file for module 'react'
- Cause: devDependencies not installed
- Fix: Ensure
.npmrccontainsproduction=false
- The application uses SSL for PostgreSQL connections
- Currently uses a simple user selection for demo purposes
- In production, implement proper authentication (JWT, OAuth, etc.)
- Add authorization middleware to protect routes
- Validate and sanitize all user inputs
- Backend: Add routes in
server/src/routes/ - Frontend: Add components in
client/src/components/ - Types: Update TypeScript interfaces in both
server/src/types/andclient/src/types/
- Use TypeScript for type safety
- Follow React best practices
- Use async/await for asynchronous operations
- Handle errors gracefully with try-catch blocks
ISC
Your Name
Contributions, issues, and feature requests are welcome!