diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..d3c4b3e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,80 @@ +name: CI/CD Pipeline + +on: + push: + branches: [ main, develop ] + pull_request: + branches: [ main, develop ] + +jobs: + lint-and-test: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [18.x, 20.x] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + + - name: Install dependencies + run: | + npm ci + cd client && npm ci + cd ../server && npm ci + + - name: Run linting + run: | + npm run lint + + - name: Run formatting check + run: | + npm run format:check + + - name: Run tests + run: | + npm run test + + - name: Build project + run: | + npm run build + + - name: Upload coverage reports + uses: codecov/codecov-action@v3 + with: + directory: ./coverage + flags: unittests + name: codecov-umbrella + fail_ci_if_error: false + + security-audit: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20.x' + cache: 'npm' + + - name: Install dependencies + run: | + npm ci + cd client && npm ci + cd ../server && npm ci + + - name: Run security audit + run: | + npm audit --audit-level=moderate + cd client && npm audit --audit-level=moderate + cd ../server && npm audit --audit-level=moderate diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..5504a54 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,64 @@ +name: Deploy + +on: + push: + branches: [ main ] + +jobs: + deploy-client: + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20.x' + cache: 'npm' + + - name: Install dependencies + run: | + cd client && npm ci + + - name: Build client + run: | + cd client && npm run build + + - name: Deploy to Vercel + uses: amondnet/vercel-action@v25 + with: + vercel-token: ${{ secrets.VERCEL_TOKEN }} + vercel-org-id: ${{ secrets.VERCEL_ORG_ID }} + vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} + working-directory: ./client + vercel-args: '--prod' + + deploy-server: + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20.x' + cache: 'npm' + + - name: Install dependencies + run: | + cd server && npm ci + + - name: Deploy to Render + env: + RENDER_TOKEN: ${{ secrets.RENDER_TOKEN }} + RENDER_SERVICE_ID: ${{ secrets.RENDER_SERVICE_ID }} + run: | + curl -X POST "https://api.render.com/v1/services/$RENDER_SERVICE_ID/deploys" \ + -H "Authorization: Bearer $RENDER_TOKEN" \ + -H "Content-Type: application/json" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4009c91 --- /dev/null +++ b/.gitignore @@ -0,0 +1,169 @@ +# Dependencies +node_modules/ +*/node_modules/ +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Coverage directory used by tools like istanbul +coverage/ +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test +.env.production +.env.local +.env.development.local +.env.test.local +.env.production.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +# Build outputs +dist/ +build/ +*/dist/ +*/build/ + +# Logs +logs +*.log + +# Editor directories and files +.vscode/ +.idea/ +*.swp +*.swo +*~ + +# OS generated files +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db + +# Temporary folders +tmp/ +temp/ + +# Test coverage +coverage/ +*.lcov + +# Vite +.vite/ + +# Vitest +coverage/ +*.lcov + +# Jest +coverage/ +*.lcov + +# Storybook build outputs +.out +.storybook-out + +# Temporary folders +tmp/ +temp/ + +# Local development +.local/ diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..e6f0335 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,104 @@ +# Dependencies +node_modules/ +*/node_modules/ + +# Build outputs +dist/ +build/ +*/dist/ +*/build/ + +# Environment files +.env +.env.local +.env.development.local +.env.test.local +.env.production.local + +# Logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Coverage directory used by tools like istanbul +coverage/ +*.lcov + +# nyc test coverage +.nyc_output + +# Dependency directories +jspm_packages/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next + +# Nuxt.js build / generate output +.nuxt + +# Gatsby files +.cache/ +public + +# Storybook build outputs +.out +.storybook-out + +# Temporary folders +tmp/ +temp/ + +# Editor directories and files +.vscode/ +.idea/ +*.swp +*.swo +*~ + +# OS generated files +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db + +# Git +.git/ + +# Package lock files +package-lock.json +yarn.lock diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..91ab843 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,15 @@ +{ + "semi": true, + "trailingComma": "es5", + "singleQuote": true, + "printWidth": 80, + "tabWidth": 2, + "useTabs": false, + "bracketSpacing": true, + "bracketSameLine": false, + "arrowParens": "avoid", + "endOfLine": "lf", + "quoteProps": "as-needed", + "jsxSingleQuote": true, + "proseWrap": "preserve" +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 26a4e13..dfd2fb6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,148 +1,144 @@ -# Contributing to FinTrack +# Contributing to Refixly -Thank you for your interest in contributing to FinTrack!. We welcome contributions from developers of all skill levels. This guide will help you get started. +We love your input! We want to make contributing to Refixly as easy and transparent as possible, whether it's: -## How to Contribute +- Reporting a bug +- Discussing the current state of the code +- Submitting a fix +- Proposing new features +- Becoming a maintainer -### 1. Fork and Clone -1. Fork the repository on GitHub -2. Clone your fork locally: -```bash -git clone https://github.com/Bavanetha27/Refixly -cd Refixly -``` - -### 2. Set Up Development Environment -1. Install Node.js (version 16 or higher) -2. Install dependencies: -```bash -npm install -``` -3. Create a `.env` file with the required environment variables see [`.env.example`](.env.example) -4. Start the development server: -```bash -npm run dev -``` +## ๐Ÿš€ Quick Start -### 3. Create a Branch -Create a new branch for your feature or bug fix: -```bash -git checkout -b feature/your-feature-name -# or -git checkout -b fix/bug-description -``` +### Prerequisites +- Node.js 18+ and npm 8+ +- Git -## Types of Contributions +### Setup Development Environment -### ๐Ÿ› Bug Fixes -- Look for issues labeled `bug` or `good first issue` -- Include steps to reproduce the bug in your PR description -- Add tests if applicable +1. **Fork and Clone** + ```bash + git clone https://github.com/YOUR_USERNAME/refixly.git + cd refixly + ``` -### โœจ New Features -- Check existing issues or create a new issue to discuss the feature -- Follow the existing code patterns and architecture -- Update documentation as needed +2. **Install Dependencies** + ```bash + npm run install:all + ``` -### ๐Ÿ“š Documentation -- Improve README.md, code comments, or inline documentation -- Add examples and use cases -- Fix typos and grammar issues +3. **Environment Setup** + ```bash + cp env.example .env + # Edit .env with your configuration + ``` -### ๐ŸŽจ UI/UX Improvements -- Look for issues labeled `design-needed` or `ui/ux` -- Ensure changes are responsive and accessible -- Follow the existing Tailwind CSS patterns +4. **Start Development Servers** + ```bash + npm run dev + ``` -### ๐Ÿงช Testing -- Add unit tests for new features -- Improve test coverage -- Fix failing tests +## ๐Ÿงช Testing -## Code Style Guidelines +### Run All Tests +```bash +npm run test +``` -### JavaScript/React -- Use functional components with hooks -- Follow ESLint rules (run `npm run lint`) -- Use descriptive variable and function names -- Add comments for complex logic +### Run Tests with Coverage +```bash +npm run test:coverage +``` -### CSS/Styling -- Use Tailwind CSS classes -- Follow mobile-first responsive design -- Maintain consistent spacing and typography +### Run Tests in Watch Mode +```bash +# Client tests +npm run test:client -### File Structure -- Place components in appropriate directories -- Use clear, descriptive file names -- Keep components small and focused +# Server tests +npm run test:server +``` -## Commit Message Guidelines +## ๐Ÿ” Code Quality -Use clear and descriptive commit messages: +### Linting +```bash +# Check for linting issues +npm run lint +# Fix auto-fixable issues +npm run lint:fix ``` -feat: add QR scan component -fix: resolve technician dashboard issue -docs: update contributing guidelines -style: refactor layout with Tailwind CSS -test: add unit test for booking form + +### Formatting +```bash +# Format all files +npm run format + +# Check formatting +npm run format:check ``` -Types: -- `feat`: New feature -- `fix`: Bug fix -- `docs`: Documentation -- `style`: UI/UX changes -- `test`: Adding tests -- `refactor`: Code refactoring +## ๐Ÿ“ Development Workflow -## Pull Request Process +### 1. Create a Feature Branch +```bash +git checkout -b feature/your-feature-name +``` -### Before Submitting -1. Test your changes thoroughly -2. Run `npm run lint` and fix any issues -3. Update documentation if needed -4. Ensure your branch is up to date with main -5. **Include a screenshot or screen recording of your changes** when submitting a PR. This helps us review and merge your work more efficiently. +### 2. Make Your Changes +- Write your code +- Add tests for new functionality +- Update documentation if needed -### PR Description Template -```markdown -## Description -Brief description of changes - -## Type of Change -- [ ] Bug fix -- [ ] New feature -- [ ] Documentation update -- [ ] UI/UX improvement - -## Testing -- [ ] Tested locally -- [ ] No console errors -- [ ] Responsive design verified - -## Screenshots (if applicable) -Add screenshots for UI changes - -## Checklist -- [ ] Code follows project style guidelines -- [ ] Self-review completed -- [ ] Documentation updated +### 3. Quality Checks +```bash +# Run all quality checks +npm run lint +npm run test +npm run format:check +``` + +### 4. Commit Your Changes +```bash +git add . +git commit -m "feat: add your feature description" ``` -### Review Process -1. Maintainers will review your PR -2. Address any requested changes -3. Once approved, your PR will be merged +### 5. Push and Create PR +```bash +git push origin feature/your-feature-name +``` -## Issue Guidelines +## ๐Ÿ“‹ Pull Request Guidelines -### Reporting Bugs -Use the following template: +### Before Submitting +- [ ] All tests pass +- [ ] Code is linted and formatted +- [ ] Documentation is updated +- [ ] No console.log statements in production code +- [ ] Environment variables are properly configured + +### PR Template +Use the provided PR template and fill in all sections: +- Description of changes +- Type of change (bug fix, feature, etc.) +- Testing instructions +- Screenshots (if applicable) + +## ๐Ÿ› Bug Reports + +### Creating a Bug Report +1. Use the bug report template +2. Provide detailed reproduction steps +3. Include expected vs actual behavior +4. Add screenshots/videos if applicable +5. Specify your environment (OS, browser, Node version) + +### Example Bug Report ```markdown **Bug Description** -A clear description of the bug +Brief description of the issue **Steps to Reproduce** 1. Go to '...' @@ -152,56 +148,141 @@ A clear description of the bug **Expected Behavior** What should happen -**Screenshots** -If applicable +**Actual Behavior** +What actually happens **Environment** -- OS: [e.g., Windows, macOS, Linux] -- Browser: [e.g., Chrome, Firefox] -- Version: [e.g., 22] +- OS: Windows 10 +- Browser: Chrome 120 +- Node: 18.17.0 ``` -### Feature Requests -```markdown -**Feature Description** -Clear description of the proposed feature +## โœจ Feature Requests -**Problem it Solves** -What problem does this solve? +### Creating a Feature Request +1. Use the feature request template +2. Describe the problem you're solving +3. Propose a solution +4. Consider implementation complexity +5. Discuss alternatives -**Proposed Solution** -How should this be implemented? +## ๐Ÿ—๏ธ Project Structure -**Additional Context** -Any other relevant information ``` +refixly/ +โ”œโ”€โ”€ client/ # React Frontend +โ”‚ โ”œโ”€โ”€ src/ +โ”‚ โ”‚ โ”œโ”€โ”€ components/ # Reusable components +โ”‚ โ”‚ โ”œโ”€โ”€ Pages/ # Page components +โ”‚ โ”‚ โ”œโ”€โ”€ hooks/ # Custom React hooks +โ”‚ โ”‚ โ””โ”€โ”€ test/ # Test files +โ”‚ โ”œโ”€โ”€ vitest.config.js # Test configuration +โ”‚ โ””โ”€โ”€ package.json +โ”œโ”€โ”€ server/ # Node.js Backend +โ”‚ โ”œโ”€โ”€ Controllers/ # Route controllers +โ”‚ โ”œโ”€โ”€ routes/ # API routes +โ”‚ โ”œโ”€โ”€ test/ # Test files +โ”‚ โ”œโ”€โ”€ jest.config.js # Test configuration +โ”‚ โ””โ”€โ”€ package.json +โ”œโ”€โ”€ .github/ # GitHub workflows +โ”œโ”€โ”€ .prettierrc # Code formatting +โ”œโ”€โ”€ package.json # Root package.json +โ””โ”€โ”€ README.md +``` + +## ๐ŸŽฏ Good First Issues + +Look for issues labeled with: +- `good first issue` +- `help wanted` +- `beginner-friendly` + +### Suggested First Contributions +- Add unit tests for existing components +- Improve documentation +- Fix minor UI issues +- Add error handling +- Implement accessibility improvements + +## ๐Ÿ”ง Development Tools + +### Recommended VS Code Extensions +- ESLint +- Prettier +- Jest Runner +- GitLens +- Auto Rename Tag + +### VS Code Settings +```json +{ + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.fixAll.eslint": true + }, + "eslint.validate": ["javascript", "javascriptreact"] +} +``` + +## ๐Ÿ“š Code Style Guide + +### JavaScript/React +- Use functional components with hooks +- Prefer const over let +- Use template literals for string interpolation +- Use destructuring for props and state +- Add PropTypes or TypeScript for type checking + +### Naming Conventions +- Components: PascalCase (e.g., `UserProfile`) +- Files: PascalCase for components, camelCase for utilities +- Variables: camelCase +- Constants: UPPER_SNAKE_CASE + +### Comments +- Use JSDoc for function documentation +- Add inline comments for complex logic +- Keep comments up to date with code changes + +## ๐Ÿšจ Common Issues + +### Build Failures +- Check Node.js version compatibility +- Clear node_modules and reinstall +- Verify environment variables + +### Test Failures +- Run tests locally before pushing +- Check for flaky tests +- Verify test environment setup -## Development Tips +### Linting Errors +- Use `npm run lint:fix` for auto-fixable issues +- Check ESLint configuration +- Verify Prettier integration -### Firebase Configuration -- Do not commit any API keys or credentials -- Use your own Firebase project while developing -- Follow security rules and permissions +## ๐Ÿค Community Guidelines -### AI/ML Features (Future Scope) -- Test AI features like model predictions thoroughly -- Ensure fallback UI when APIs fail -- Optimize loading for AI-based components +### Communication +- Be respectful and inclusive +- Use clear, constructive language +- Ask questions when unsure +- Help others learn -### Performance -- Use lazy loading where applicable -- Avoid unnecessary re-renders -- Optimize API calls and state updates +### Code Reviews +- Be constructive and specific +- Focus on the code, not the person +- Suggest improvements respectfully +- Celebrate good work -## Getting Help +## ๐Ÿ“„ License -- Check existing issues and documentation first -- Ask questions in GitHub issues +By contributing, you agree that your contributions will be licensed under the MIT License. -## Code of Conduct +## ๐Ÿ™ Acknowledgments -Please read and follow our [Code of Conduct](CODE_OF_CONDUCT.md). +Thank you for contributing to Refixly! Your efforts help make this project better for everyone. --- -Thank you for contributing to FinTrack! Your contributions help make personal finance management accessible to everyone. +**Need Help?** Open an issue or reach out to the maintainers! diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md new file mode 100644 index 0000000..f656b1f --- /dev/null +++ b/DEVELOPMENT.md @@ -0,0 +1,424 @@ +# Development Guide + +This document provides detailed information for developers working on the Refixly project. + +## ๐Ÿ—๏ธ Architecture Overview + +Refixly is a full-stack web application with the following architecture: + +### Frontend (React + Vite) +- **Framework**: React 19 with Vite +- **Styling**: Tailwind CSS +- **State Management**: React hooks and context +- **Testing**: Vitest + React Testing Library +- **Build Tool**: Vite + +### Backend (Node.js + Express) +- **Runtime**: Node.js +- **Framework**: Express.js +- **Database**: MongoDB (planned) +- **Testing**: Jest + Supertest +- **Authentication**: Firebase Auth + +## ๐Ÿš€ Getting Started + +### Prerequisites +- Node.js 18+ +- npm 8+ +- Git +- MongoDB (for local development) + +### Initial Setup + +1. **Clone the repository** + ```bash + git clone https://github.com/Bavanetha27/refixly.git + cd refixly + ``` + +2. **Install dependencies** + ```bash + npm run install:all + ``` + +3. **Environment configuration** + ```bash + cp env.example .env + # Edit .env with your configuration + ``` + +4. **Start development servers** + ```bash + npm run dev + ``` + +This will start both the client (port 5173) and server (port 5000) in development mode. + +## ๐Ÿ“ Project Structure + +``` +refixly/ +โ”œโ”€โ”€ client/ # React Frontend +โ”‚ โ”œโ”€โ”€ src/ +โ”‚ โ”‚ โ”œโ”€โ”€ components/ # Reusable UI components +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ AIDamageDetection.jsx +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ AIResponseSection.jsx +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ FAQAccordion.jsx +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ FluidCursor.jsx +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ Footer.jsx +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ HomeFAQ.jsx +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ NavBar.jsx +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ ProtectedRoute.jsx +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ ScrollTop.jsx +โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ Tour.jsx +โ”‚ โ”‚ โ”œโ”€โ”€ Pages/ # Page components +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ Community.jsx +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ Contact.jsx +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ Home.jsx +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ LandingPage.jsx +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ Login.jsx +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ ProfilePage.jsx +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ ScanPage.jsx +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ Signup.jsx +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ Tutorial.jsx +โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ TutorialsPage.jsx +โ”‚ โ”‚ โ”œโ”€โ”€ hooks/ # Custom React hooks +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ useAuth.js +โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ useFluidCursor.js +โ”‚ โ”‚ โ”œโ”€โ”€ assets/ # Static assets +โ”‚ โ”‚ โ”œโ”€โ”€ test/ # Test files +โ”‚ โ”‚ โ”œโ”€โ”€ App.jsx # Main App component +โ”‚ โ”‚ โ”œโ”€โ”€ main.jsx # Entry point +โ”‚ โ”‚ โ””โ”€โ”€ firebase.js # Firebase configuration +โ”‚ โ”œโ”€โ”€ public/ # Public assets +โ”‚ โ”œโ”€โ”€ vitest.config.js # Test configuration +โ”‚ โ”œโ”€โ”€ vite.config.js # Vite configuration +โ”‚ โ”œโ”€โ”€ tailwind.config.js # Tailwind configuration +โ”‚ โ””โ”€โ”€ package.json +โ”œโ”€โ”€ server/ # Node.js Backend +โ”‚ โ”œโ”€โ”€ Controllers/ # Route controllers +โ”‚ โ”‚ โ”œโ”€โ”€ aidamdet.Conrtroller.js +โ”‚ โ”‚ โ””โ”€โ”€ tutorialController.js +โ”‚ โ”œโ”€โ”€ routes/ # API routes +โ”‚ โ”‚ โ”œโ”€โ”€ aidamdet.route.js +โ”‚ โ”‚ โ””โ”€โ”€ tutorials.js +โ”‚ โ”œโ”€โ”€ test/ # Test files +โ”‚ โ”œโ”€โ”€ server.js # Main server file +โ”‚ โ”œโ”€โ”€ jest.config.js # Jest configuration +โ”‚ โ”œโ”€โ”€ .eslintrc.js # ESLint configuration +โ”‚ โ””โ”€โ”€ package.json +โ”œโ”€โ”€ .github/ # GitHub workflows +โ”‚ โ””โ”€โ”€ workflows/ +โ”‚ โ”œโ”€โ”€ ci.yml # CI pipeline +โ”‚ โ””โ”€โ”€ deploy.yml # Deployment pipeline +โ”œโ”€โ”€ .prettierrc # Prettier configuration +โ”œโ”€โ”€ .gitignore # Git ignore rules +โ”œโ”€โ”€ package.json # Root package.json +โ”œโ”€โ”€ README.md # Project documentation +โ”œโ”€โ”€ CONTRIBUTING.md # Contribution guidelines +โ”œโ”€โ”€ CODE_OF_CONDUCT.md # Community guidelines +โ””โ”€โ”€ DEVELOPMENT.md # This file +``` + +## ๐Ÿงช Testing + +### Frontend Testing (Vitest) + +```bash +# Run all tests +npm run test:client + +# Run tests in watch mode +npm run test:client -- --watch + +# Run tests with coverage +npm run test:client -- --coverage + +# Run tests with UI +npm run test:client -- --ui +``` + +### Backend Testing (Jest) + +```bash +# Run all tests +npm run test:server + +# Run tests in watch mode +npm run test:server -- --watch + +# Run tests with coverage +npm run test:server -- --coverage +``` + +### Test Structure + +#### Frontend Tests +- **Location**: `client/src/test/` +- **Framework**: Vitest + React Testing Library +- **Coverage**: Components, hooks, utilities + +#### Backend Tests +- **Location**: `server/test/` +- **Framework**: Jest + Supertest +- **Coverage**: Controllers, routes, utilities + +## ๐Ÿ” Code Quality + +### Linting + +```bash +# Check for linting issues +npm run lint + +# Fix auto-fixable issues +npm run lint:fix +``` + +### Formatting + +```bash +# Format all files +npm run format + +# Check formatting +npm run format:check +``` + +### Configuration Files + +- **ESLint**: `.eslintrc.js` (server), `eslint.config.js` (client) +- **Prettier**: `.prettierrc` +- **Git Hooks**: Configured via package.json scripts + +## ๐Ÿš€ Development Workflow + +### 1. Feature Development + +```bash +# Create feature branch +git checkout -b feature/your-feature-name + +# Make changes +# ... your code changes ... + +# Run quality checks +npm run lint +npm run test +npm run format:check + +# Commit changes +git add . +git commit -m "feat: add your feature" + +# Push and create PR +git push origin feature/your-feature-name +``` + +### 2. Bug Fixes + +```bash +# Create fix branch +git checkout -b fix/bug-description + +# Fix the bug +# ... your fixes ... + +# Add tests for the fix +# ... test code ... + +# Commit and push +git add . +git commit -m "fix: resolve bug description" +git push origin fix/bug-description +``` + +## ๐Ÿ”ง Development Tools + +### VS Code Extensions + +Recommended extensions for development: + +```json +{ + "recommendations": [ + "esbenp.prettier-vscode", + "dbaeumer.vscode-eslint", + "ms-vscode.vscode-typescript-next", + "bradlc.vscode-tailwindcss", + "formulahendry.auto-rename-tag", + "christian-kohler.path-intellisense", + "ms-vscode.vscode-json" + ] +} +``` + +### VS Code Settings + +Create `.vscode/settings.json`: + +```json +{ + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.fixAll.eslint": true + }, + "eslint.validate": ["javascript", "javascriptreact"], + "tailwindCSS.includeLanguages": { + "javascript": "javascript", + "html": "HTML" + }, + "emmet.includeLanguages": { + "javascript": "javascriptreact" + } +} +``` + +## ๐ŸŒ Environment Configuration + +### Required Environment Variables + +#### Client (.env) +```env +VITE_FIREBASE_API_KEY=your_firebase_api_key +VITE_FIREBASE_AUTH_DOMAIN=your_firebase_auth_domain +VITE_FIREBASE_PROJECT_ID=your_firebase_project_id +VITE_FIREBASE_STORAGE_BUCKET=your_firebase_storage_bucket +VITE_FIREBASE_MESSAGING_SENDER_ID=your_firebase_messaging_sender_id +VITE_FIREBASE_APP_ID=your_firebase_app_id +VITE_MEASUREMENT_ID=your_measurement_id +``` + +#### Server (.env) +```env +PORT=5000 +MONGO_URI=your_mongodb_connection_string +YOUTUBE_API_KEY=your_youtube_api_key +``` + +### Development vs Production + +- **Development**: Uses local environment variables +- **Production**: Uses deployment platform environment variables +- **Testing**: Uses test-specific environment variables + +## ๐Ÿ“ฆ Build and Deployment + +### Local Build + +```bash +# Build both client and server +npm run build + +# Build client only +npm run build:client + +# Build server only +npm run build:server +``` + +### Deployment + +The project uses GitHub Actions for CI/CD: + +1. **CI Pipeline** (`.github/workflows/ci.yml`) + - Runs on every push and PR + - Lints code + - Runs tests + - Checks formatting + - Builds project + +2. **Deployment Pipeline** (`.github/workflows/deploy.yml`) + - Deploys to Vercel (frontend) + - Deploys to Render (backend) + - Runs on main branch pushes + +## ๐Ÿ” Debugging + +### Frontend Debugging + +1. **Browser DevTools** + - React Developer Tools + - Network tab for API calls + - Console for errors + +2. **Vite DevTools** + - Hot module replacement + - Build analysis + - Performance profiling + +### Backend Debugging + +1. **Node.js Debugging** + ```bash + # Start server in debug mode + node --inspect server.js + ``` + +2. **Logging** + - Use console.log for development + - Implement proper logging for production + +## ๐Ÿšจ Common Issues and Solutions + +### Build Issues + +**Problem**: Build fails with dependency errors +**Solution**: +```bash +npm run clean +npm run install:all +``` + +**Problem**: ESLint configuration conflicts +**Solution**: +```bash +npm run lint:fix +``` + +### Test Issues + +**Problem**: Tests fail in CI but pass locally +**Solution**: +- Check environment variables +- Verify Node.js version +- Clear test cache + +**Problem**: Coverage reports not generating +**Solution**: +```bash +npm run test:coverage +``` + +### Development Server Issues + +**Problem**: Port conflicts +**Solution**: +- Change ports in environment variables +- Kill processes using the ports + +**Problem**: Hot reload not working +**Solution**: +- Check file watching limits +- Restart development server + +## ๐Ÿ“š Additional Resources + +### Documentation +- [React Documentation](https://react.dev/) +- [Vite Documentation](https://vitejs.dev/) +- [Tailwind CSS Documentation](https://tailwindcss.com/docs) +- [Express.js Documentation](https://expressjs.com/) +- [Jest Documentation](https://jestjs.io/docs/getting-started) +- [Vitest Documentation](https://vitest.dev/) + +### Community +- [GitHub Issues](https://github.com/Bavanetha27/refixly/issues) +- [Discussions](https://github.com/Bavanetha27/refixly/discussions) + +--- + +**Need Help?** +- Check the [CONTRIBUTING.md](CONTRIBUTING.md) for contribution guidelines +- Open an issue for bugs or feature requests +- Join the community discussions diff --git a/client/package.json b/client/package.json index c2435c3..eecb0a5 100644 --- a/client/package.json +++ b/client/package.json @@ -6,8 +6,14 @@ "scripts": { "dev": "vite", "build": "vite build", - "lint": "eslint .", - "preview": "vite preview" + "lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0", + "lint:fix": "eslint . --ext js,jsx --fix", + "preview": "vite preview", + "test": "vitest", + "test:ui": "vitest --ui", + "test:run": "vitest run", + "test:coverage": "vitest run --coverage", + "type-check": "tsc --noEmit" }, "dependencies": { "@react-spring/web": "^10.0.1", @@ -33,16 +39,22 @@ }, "devDependencies": { "@eslint/js": "^9.29.0", + "@testing-library/jest-dom": "^6.4.2", + "@testing-library/react": "^14.2.1", + "@testing-library/user-event": "^14.5.2", "@types/react": "^19.1.8", "@types/react-dom": "^19.1.6", "@vitejs/plugin-react": "^4.7.0", + "@vitest/ui": "^2.1.8", "autoprefixer": "^10.4.21", "eslint": "^9.29.0", "eslint-plugin-react-hooks": "^5.2.0", "eslint-plugin-react-refresh": "^0.4.20", "globals": "^16.2.0", + "jsdom": "^24.0.0", "postcss": "^8.5.6", "tailwindcss": "^3.4.17", - "vite": "^7.0.5" + "vite": "^7.0.5", + "vitest": "^2.1.8" } } diff --git a/client/src/test/App.test.jsx b/client/src/test/App.test.jsx new file mode 100644 index 0000000..90c734c --- /dev/null +++ b/client/src/test/App.test.jsx @@ -0,0 +1,16 @@ +import { describe, it, expect } from 'vitest'; +import { render, screen } from '@testing-library/react'; +import App from '../App'; + +describe('App', () => { + it('renders without crashing', () => { + render(); + expect(screen.getByRole('main')).toBeInTheDocument(); + }); + + it('contains navigation elements', () => { + render(); + // Check if navigation elements are present + expect(screen.getByRole('navigation')).toBeInTheDocument(); + }); +}); diff --git a/client/src/test/setup.js b/client/src/test/setup.js new file mode 100644 index 0000000..7290f85 --- /dev/null +++ b/client/src/test/setup.js @@ -0,0 +1,35 @@ +import '@testing-library/jest-dom'; + +// Mock IntersectionObserver +global.IntersectionObserver = class IntersectionObserver { + constructor() {} + disconnect() {} + observe() {} + unobserve() {} +}; + +// Mock ResizeObserver +global.ResizeObserver = class ResizeObserver { + constructor() {} + disconnect() {} + observe() {} + unobserve() {} +}; + +// Mock matchMedia +Object.defineProperty(window, 'matchMedia', { + writable: true, + value: vi.fn().mockImplementation(query => ({ + matches: false, + media: query, + onchange: null, + addListener: vi.fn(), // deprecated + removeListener: vi.fn(), // deprecated + addEventListener: vi.fn(), + removeEventListener: vi.fn(), + dispatchEvent: vi.fn(), + })), +}); + +// Mock scrollTo +window.scrollTo = vi.fn(); diff --git a/client/vitest.config.js b/client/vitest.config.js new file mode 100644 index 0000000..200dda9 --- /dev/null +++ b/client/vitest.config.js @@ -0,0 +1,23 @@ +import { defineConfig } from 'vitest/config'; +import react from '@vitejs/plugin-react'; + +export default defineConfig({ + plugins: [react()], + test: { + globals: true, + environment: 'jsdom', + setupFiles: ['./src/test/setup.js'], + css: true, + coverage: { + provider: 'v8', + reporter: ['text', 'json', 'html'], + exclude: [ + 'node_modules/', + 'src/test/', + '**/*.d.ts', + '**/*.config.js', + '**/*.config.ts', + ], + }, + }, +}); diff --git a/env.example b/env.example new file mode 100644 index 0000000..a889e6c --- /dev/null +++ b/env.example @@ -0,0 +1,23 @@ +# Root environment variables +NODE_ENV=development + +# Client Environment Variables +VITE_FIREBASE_API_KEY=your_firebase_api_key +VITE_FIREBASE_AUTH_DOMAIN=your_firebase_auth_domain +VITE_FIREBASE_PROJECT_ID=your_firebase_project_id +VITE_FIREBASE_STORAGE_BUCKET=your_firebase_storage_bucket +VITE_FIREBASE_MESSAGING_SENDER_ID=your_firebase_messaging_sender_id +VITE_FIREBASE_APP_ID=your_firebase_app_id +VITE_MEASUREMENT_ID=your_measurement_id + +# Server Environment Variables +PORT=5000 +MONGO_URI=your_mongodb_connection_string +YOUTUBE_API_KEY=your_youtube_api_key + +# CI/CD Environment Variables (for GitHub Actions) +VERCEL_TOKEN=your_vercel_token +VERCEL_ORG_ID=your_vercel_org_id +VERCEL_PROJECT_ID=your_vercel_project_id +RENDER_TOKEN=your_render_token +RENDER_SERVICE_ID=your_render_service_id diff --git a/package.json b/package.json new file mode 100644 index 0000000..8a3e03c --- /dev/null +++ b/package.json @@ -0,0 +1,61 @@ +{ + "name": "refixly", + "version": "1.0.0", + "description": "AI + AR Powered DIY Repair Assistant", + "private": true, + "workspaces": [ + "client", + "server" + ], + "scripts": { + "dev": "concurrently \"npm run dev:client\" \"npm run dev:server\"", + "dev:client": "cd client && npm run dev", + "dev:server": "cd server && npm run dev", + "build": "npm run build:client && npm run build:server", + "build:client": "cd client && npm run build", + "build:server": "cd server && npm run build", + "test": "npm run test:client && npm run test:server", + "test:client": "cd client && npm run test", + "test:server": "cd server && npm run test", + "lint": "npm run lint:client && npm run lint:server", + "lint:client": "cd client && npm run lint", + "lint:server": "cd server && npm run lint", + "lint:fix": "npm run lint:fix:client && npm run lint:fix:server", + "lint:fix:client": "cd client && npm run lint:fix", + "lint:fix:server": "cd server && npm run lint:fix", + "format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,md}\"", + "format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,json,md}\"", + "install:all": "npm install && cd client && npm install && cd ../server && npm install", + "clean": "npm run clean:client && npm run clean:server", + "clean:client": "cd client && rm -rf node_modules dist", + "clean:server": "cd server && rm -rf node_modules dist" + }, + "devDependencies": { + "concurrently": "^8.2.2", + "prettier": "^3.2.5" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "keywords": [ + "ai", + "ar", + "repair", + "diy", + "computer-vision", + "tensorflow", + "react", + "nodejs" + ], + "author": "Bavanetha M R", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/Bavanetha27/refixly.git" + }, + "bugs": { + "url": "https://github.com/Bavanetha27/refixly/issues" + }, + "homepage": "https://github.com/Bavanetha27/refixly#readme" +} diff --git a/server/.eslintrc.js b/server/.eslintrc.js new file mode 100644 index 0000000..68728f7 --- /dev/null +++ b/server/.eslintrc.js @@ -0,0 +1,28 @@ +module.exports = { + env: { + node: true, + es2021: true, + jest: true, + }, + extends: [ + 'eslint:recommended', + 'airbnb-base', + ], + parserOptions: { + ecmaVersion: 'latest', + sourceType: 'module', + }, + rules: { + 'indent': ['error', 2], + 'linebreak-style': ['error', 'unix'], + 'quotes': ['error', 'single'], + 'semi': ['error', 'always'], + 'no-unused-vars': ['error', { argsIgnorePattern: '^_' }], + 'no-console': 'off', // Allow console.log for server logging + 'import/extensions': 'off', + 'import/prefer-default-export': 'off', + 'class-methods-use-this': 'off', + 'no-underscore-dangle': 'off', + }, + ignorePatterns: ['node_modules/', 'coverage/', 'dist/'], +}; diff --git a/server/jest.config.js b/server/jest.config.js new file mode 100644 index 0000000..39aed8f --- /dev/null +++ b/server/jest.config.js @@ -0,0 +1,15 @@ +module.exports = { + testEnvironment: 'node', + testMatch: ['**/__tests__/**/*.js', '**/?(*.)+(spec|test).js'], + collectCoverageFrom: [ + '**/*.js', + '!**/node_modules/**', + '!**/coverage/**', + '!jest.config.js', + '!server.js', + ], + coverageDirectory: 'coverage', + coverageReporters: ['text', 'lcov', 'html'], + setupFilesAfterEnv: ['/test/setup.js'], + testTimeout: 10000, +}; diff --git a/server/package.json b/server/package.json index fd02526..46f5b99 100644 --- a/server/package.json +++ b/server/package.json @@ -5,8 +5,13 @@ "main": "server.js", "type": "commonjs", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "start": "node server.js" + "test": "jest", + "test:watch": "jest --watch", + "test:coverage": "jest --coverage", + "start": "node server.js", + "dev": "nodemon server.js", + "lint": "eslint . --ext .js", + "lint:fix": "eslint . --ext .js --fix" }, "keywords": [], "author": "", @@ -17,5 +22,13 @@ "dotenv": "^17.2.1", "express": "^5.1.0", "multer": "^2.0.2" + }, + "devDependencies": { + "eslint": "^9.29.0", + "eslint-config-airbnb-base": "^15.0.0", + "eslint-plugin-import": "^2.29.1", + "jest": "^29.7.0", + "nodemon": "^3.0.3", + "supertest": "^7.0.0" } } diff --git a/server/test/server.test.js b/server/test/server.test.js new file mode 100644 index 0000000..bf26a03 --- /dev/null +++ b/server/test/server.test.js @@ -0,0 +1,24 @@ +const request = require('supertest'); +const express = require('express'); + +// Create a simple test app +const app = express(); +app.use(express.json()); + +// Add a test route +app.get('/test', (req, res) => { + res.json({ message: 'Server is running' }); +}); + +describe('Server', () => { + it('should respond to test endpoint', async () => { + const response = await request(app).get('/test'); + expect(response.status).toBe(200); + expect(response.body).toEqual({ message: 'Server is running' }); + }); + + it('should handle 404 for unknown routes', async () => { + const response = await request(app).get('/unknown'); + expect(response.status).toBe(404); + }); +}); diff --git a/server/test/setup.js b/server/test/setup.js new file mode 100644 index 0000000..27ea37a --- /dev/null +++ b/server/test/setup.js @@ -0,0 +1,15 @@ +// Global test setup for server tests +process.env.NODE_ENV = 'test'; + +// Increase timeout for all tests +jest.setTimeout(10000); + +// Mock console methods to reduce noise in tests +global.console = { + ...console, + log: jest.fn(), + debug: jest.fn(), + info: jest.fn(), + warn: jest.fn(), + error: jest.fn(), +};