A comprehensive maintenance tracking system designed to streamline equipment service management with real-time monitoring, detailed service records, and user-friendly analytics.
maintenance-tracker-demo.mp4
- React 19 - Modern React with latest features
- TypeScript - Type-safe development
- Vite - Fast build tool and dev server
- TailwindCSS - Utility-first CSS framework
- Framer Motion - Smooth animations and transitions
- React Router DOM - Client-side routing
- Axios - HTTP client with interceptors
- React Icons - Comprehensive icon library
- Node.js - JavaScript runtime
- Express - Web framework
- TypeScript - Type-safe server development
- PostgreSQL - Robust relational database
- Prisma - Modern database ORM
- Better Auth - Secure authentication system
- CORS - Cross-origin resource sharing
- Jest - Testing framework
- ESLint - Code linting
- TSX - TypeScript execution
- Supertest - API testing
- 🔐 Secure Authentication - Email‑based auth with session management
- 📊 Real‑time Dashboard - Overview of service metrics and statistics
- 🔧 Service Record Management - Complete CRUD operations for maintenance records
- 📅 Advanced Filtering - Search and date‑range filters with server‑side processing
- 🤖 AI Assistant - Natural language queries over your service data
- 📱 Responsive Design - Mobile‑friendly interface with dark theme
- ⚡ Fast Performance - Optimized data fetching and smooth animations
- 🛡️ Protected Routes - Authentication‑gated access to sensitive data
- 📈 Analytics - Track total service hours, last service dates, and equipment statistics
User {
id: UUID (Primary Key)
email: String (Unique)
name: String
emailVerified: Boolean
serviceRecords: ServiceRecord[]
}
ServiceRecord {
id: UUID (Primary Key)
date: DateTime
serviceType: String
serviceTime: Float
equipmentId: String
equipmentType: String
technician: String
partsUsed: String?
serviceNotes: String
userId: UUID (Foreign Key)
}(see above for frontend and backend flows)
- Docker:
client/Dockerfile,server/Dockerfile, anddocker-compose.ymlenable one‑command local development and production builds. - GitHub Actions: CI pipeline runs tests, linting, builds, and Docker image creation on push/PR.
- Environment Variables:
.envholdsDATABASE_URL,OPENAI_API_KEY,BASE_URL, etc.
- Clone the repo and run
npm installin bothclientandserver. - Set up PostgreSQL and configure
DATABASE_URL. - Add your OpenAI API key to
.env(OPENAI_API_KEY=). - Run
npm run devin each folder ordocker-compose up --build. - Visit
http://localhost:5173for the frontend.
Enjoy!
- Entry Point - User lands on login page (
/) - Authentication - Login via email/password using Better Auth
- Protected Routes - Authenticated users access dashboard and service records
- Navigation - Sidebar navigation between Dashboard and Service Records
- Data Fetching - Axios interceptors handle API calls with automatic credentials
- AI Chat – Ask questions about your data with the integrated assistant
- State Management - React hooks manage local component state
- UI Updates - Framer Motion provides smooth transitions between views
- Server Initialization - Express server starts on port 3000
- Middleware Setup - CORS, JSON parsing, and request logging
- Auth Routes - Better Auth handles
/api/auth/*endpoints - Protected Routes -
requireAuthmiddleware validates sessions - Database Operations - Prisma ORM handles all database interactions
- Response Handling - JSON responses with proper error handling
POST /api/auth/sign-up/email- Create new user accountPOST /api/auth/sign-in/email- User loginPOST /api/auth/sign-out- User logoutGET /api/auth/get-session- Get current session
GET /api/service-records- Get all user's service recordsGET /api/service-records/:id- Get specific service recordPOST /api/service-records- Create new service recordPUT /api/service-records/:id- Update existing service recordDELETE /api/service-records/:id- Delete service record
ProtectedRoute- Authentication wrapper for protected pagesProtectedLayout- Main layout with sidebar and top barSidebar- Navigation menu with user infoTopBar- Header with logout functionalityDashboard- Overview cards and service statisticsServiceRecords- Full CRUD interface for maintenance records, filters, and AI chat
auth.ts- Better Auth configurationserviceRecord.controller.ts- Business logic for service records (includes date filtering)serviceRecord.routes.ts- Route definitions and middlewareai.controller.ts- AI assistant logic with OpenAI integrationrequireAuth.ts- Authentication middlewarePrisma Client- Database connection and queries
- Node.js (v18+)
- PostgreSQL database
- npm or yarn
- Clone the repository
git clone <repository-url>
cd maintenance-tracker- Install dependencies
# Root dependencies
npm install
# Client dependencies
cd client
npm install
# Server dependencies
cd ../server
npm install- Environment Setup
# In server directory
cp .env.example .env
# Configure DATABASE_URL and other environment variables- Database Setup
# In server directory
npx prisma migrate dev
npx prisma generate- Start Development Servers
# Terminal 1 - Backend (server directory)
npm run dev
# Terminal 2 - Frontend (client directory)
npm run dev- Access Application
- Frontend: http://localhost:5173
- Backend API: http://localhost:3000
# Backend tests (server directory)
npm test
# Test with coverage
npm run test:coverage
# Watch mode
npm run test:watch- Total Records - Count of all service records
- Total Service Hours - Sum of all service time
- Last Service Date - Most recent maintenance activity
- Equipment Overview - Statistics by equipment type
- Create - Add new maintenance records with detailed information
- Read - View all records with sorting and filtering options
- Update - Edit existing records with real-time validation
- Delete - Remove records with confirmation prompts
- Session-based auth - Secure cookie-based sessions
- CSRF protection - Built-in security measures
- Route protection - Server-side authentication checks
- Automatic logout - Session expiration handling
- Dark Theme - Easy on the eyes professional interface
- Responsive Design - Works seamlessly on desktop and mobile
- Smooth Animations - Framer Motion enhances user experience
- Loading States - Proper feedback during data operations
- Error Handling - User-friendly error messages and recovery
- Type Safety - Full TypeScript coverage across frontend and backend
- Code Quality - ESLint configuration for consistent code style
- Performance - Optimized database queries and efficient React rendering
- Scalability - Modular architecture supports future feature additions
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License.
Built with ❤️ for efficient maintenance management