Our codebase consists of two main repositories:
- Backend:
test-pilot-server - Frontend:
pilot-client
For detailed information about our tech stack and architecture diagrams, please see tech-stack-diagram.md.
- iTerm2
- OhMyZsh
- Node.js (Download here nodejs.org)
- Nodemon (in terminal run:
sudo npm i -g nodemon, then enter your computer password and hit enter/return) - Git (pre-installed on Mac, verify with
git --version) - Terminal access (
Command + Space, type in Terminal, hit enter/return)
-
Fork both repositories on GitHub:
Fork the backend repository:
- Go to https://github.com/cgodoy720/test-pilot-server
- Click the "Fork" button in the top-right corner
- Click "Create fork" (keep default settings)
Fork the frontend repository:
- Go to https://github.com/cgodoy720/pilot-client
- Click the "Fork" button in the top-right corner
- Click "Create fork" (keep default settings)
Note: This creates your own copies of the repositories that you can modify and submit pull requests from.
-
In the
terminalcreate a parent folder and clone your forked repositories:# Create a parent folder for the project mkdir pilot-agent-project cd pilot-agent-project # Clone YOUR forked repositories (replace YOUR_USERNAME with your GitHub username) git clone https://github.com/YOUR_USERNAME/test-pilot-server.git git clone https://github.com/YOUR_USERNAME/pilot-client.git
Your folder structure should now look like:
pilot-agent-project/ ├── test-pilot-server/ └── pilot-client/ -
Open the parent folder in Cursor:
- Open Cursor IDE
- Go to File → Open Folder (or
Command + Oon Mac) - Select the
pilot-agent-projectfolder you just created - Important: This gives Cursor's AI context of both repositories, making it much more helpful!
-
Set up terminals and create feature branches (never work directly on main):
Open and set up two terminals in Cursor:
- Open a terminal: View → Terminal (or `Control + `` backtick)
- Click the
+button next to the terminal tab to open a second terminal - Right-click the first terminal tab → Rename → type
backend - Right-click the second terminal tab → Rename → type
frontend
In the
backendterminal:cd test-pilot-server git checkout -b replace-with-your-feature-nameIn the
frontendterminal:cd pilot-client git checkout -b replace-with-your-feature-nameNote: Keep these terminals open - you'll use the
backendterminal for all backend commands andfrontendterminal for all frontend commands throughout development! -
Environment Configuration:
In the
backendterminal:# Copy the example file to create your .env file cp .env.example .env- The
.env.examplefile contains actual mock database connection details - Never commit
.envfiles to version control
- The
-
Configure database connection for mock database:
In the
backendterminal, edit the database config file:- Open
db/dbConfig.jsin Cursor - Make sure lines 48-50 are NOT commented out (SSL configuration):
// ssl: { // rejectUnauthorized: true // }
- These lines should already have
//at the beginning - Important: The mock database uses SSL, so these lines must be added back in. Erase the
//from each of those lines to add them in.
In the
frontendterminal:# Copy the example file (if it exists) cp .env.example .env - Open
-
Install dependencies:
In the
backendterminal:npm install
In the
frontendterminal:npm install
-
Database Connection:
- We use a shared mock PostgreSQL database for development
- Connection details are provided in
.env.examplewith actual values - No local database setup required - just use the provided mock database
- To connect manually via terminal (in the
backendterminal):
source .env && PGPASSWORD="$PG_PASSWORD" psql -h "$PG_HOST" -p "$PG_PORT" -U "$PG_USER" -d "$PG_DATABASE"
-
Start the applications:
In the
backendterminal:npm start
You should see:
Server listening on port 4001In the
frontendterminal:npm run dev
You should see:
Local: http://localhost:5173/Note: Both terminals need to stay running while you develop. Keep them open and use them for all future backend/frontend commands!
For Cursor IDE users: See cursor.md for Cursor-specific best practices, AI tips, and keyboard shortcuts.
-
db/: Database configurationdbConfig.js: Main database connection setup
-
queries/: Database query functions organized by feature -
controllers/: API route handlers -
services/: Business logic and external API integrations -
app.js: Main application file -
server.js: Server startup file
- PostgreSQL with pgvector: Enables AI embedding storage and similarity search
- Connection: Configured in
db/dbConfig.js - Mock Database: Shared development environment (no local setup needed)
- All API endpoints use the
/api/prefix - RESTful naming conventions
- Proper HTTP status codes
- Consistent error handling
- JWT authentication for protected routes
- All database operations should be placed in the
queries/folder - Use parameterized queries to prevent SQL injection
- Follow consistent naming conventions for query functions
- Use pgvector for AI-related queries
- Keep controllers focused on request/response handling
- Business logic should be extracted to
services/modules - Use proper error handling and validation
src/components/: Reusable UI componentssrc/pages/: Page-level componentssrc/context/: React context providerssrc/services/: API calls and external integrationssrc/utils/: Helper functions and utilities
- Tailwind CSS utility classes are the primary styling approach
- shadcn/ui components for pre-built, accessible UI components
- Guidelines:
- Use Tailwind utility classes directly in JSX:
className="flex items-center gap-4 p-4" - Use shadcn/ui components from
src/components/ui/for buttons, inputs, dialogs, etc. - Keep custom CSS minimal; prefer Tailwind utilities
- Use
cn()utility fromlib/utilsfor conditional class merging
- Use Tailwind utility classes directly in JSX:
- Examples:
<Button variant="default">Click me</Button>(shadcn button)<div className="flex flex-col gap-2 rounded-lg bg-white p-4 shadow-md">(Tailwind classes)
- Organize components logically by feature
- Use consistent file naming conventions
- Include proper documentation
- Keep components focused and reusable
- Vite: Fast development server and build tool
- Hot Module Replacement: Instant updates during development
- ES6+ Support: Modern JavaScript features
- Never work directly on main branch
- Use feature branches for new development
- Follow naming convention:
feature/descriptionorbugfix/description - Keep branches focused on single features or fixes
-
Pull latest changes in both repositories:
In the
backendterminal:git checkout main git pull origin main
In the
frontendterminal:git checkout main git pull origin main
-
Create feature branches:
In the
backendterminal:git checkout -b feature/your-feature-name
In the
frontendterminal:git checkout -b feature/your-feature-name
-
Make your changes and commit regularly:
When working on backend files, in the
backendterminal:git add . git commit -m "descriptive commit message"
When working on frontend files, in the
frontendterminal:git add . git commit -m "descriptive commit message"
-
Push your branches:
In the
backendterminal:git push origin feature/your-feature-name
In the
frontendterminal:git push origin feature/your-feature-name
-
Create Pull Requests on GitHub:
- Go to your forked repository on GitHub (https://github.com/YOUR_USERNAME/test-pilot-server or pilot-client)
- Click "Compare & pull request" button that appears after pushing
- Make sure the pull request is going from your fork to the original repository (
cgodoy720/test-pilot-serverorcgodoy720/pilot-client) - Add a clear title and description of your changes
- Click "Create pull request"
- Repeat for the other repository if you made changes to both
- All code must be reviewed before merging
- Check for adherence to coding standards
- Verify proper use of Tailwind CSS and shadcn/ui components
- Test functionality thoroughly
- Backend: Uses shared mock PostgreSQL database (no local setup required)
- Frontend: Connects to local backend API
- Use the provided
.env.exampleas a template - Never commit sensitive information
- Document any new environment variables in the README
PG_*: Database connection (actual mock database values provided in.env.example)SECRET: JWT secret for authentication (placeholder in.env.example)OPENROUTER_API_KEY: Required for AI features (ask team lead for actual key)FRONTEND_URL: For CORS configuration (default value in.env.example)
GITHUB_TOKEN: For GitHub integration featuresEMAIL_*: For email notifications (development can work without)
VITE_API_URL: Backend API endpoint (usuallyhttp://localhost:4001)
- Environment variables should be set in deployment environment
- Use proper logging levels
- Implement proper error handling
- Backend: No automated tests currently implemented
- Frontend: No automated tests currently implemented
- Manual Testing: Required for all changes
- Write unit tests for new functionality
- Ensure all tests pass before submitting PR
- Include integration tests for API endpoints
- Test API endpoints with Postman or similar tool
- Verify frontend functionality in browser
- Check database operations don't break existing data
- Test authentication flows
- Write self-documenting code with clear variable names
- Use consistent indentation and formatting
- Remove commented-out code and console.log statements
- Follow established patterns in the codebase
- Use ES6+ features appropriately
- Handle errors properly with try/catch blocks
- Use async/await for asynchronous operations
- Follow consistent function naming conventions
- Use Tailwind CSS utility classes for styling
- Use shadcn/ui components from
src/components/ui/for common UI patterns - Keep component-specific CSS files minimal; prefer Tailwind utilities
- Use CSS variables defined in
index.cssfor theme colors - Follow responsive design patterns:
sm:,md:,lg:breakpoint prefixes
- Always use parameterized queries
- Handle database errors gracefully
- Use transactions for multi-step operations
- Follow naming conventions in
queries/folder
- Validate all input parameters
- Use parameterized queries (prevent SQL injection)
- Implement proper authentication/authorization with JWT
- Never expose sensitive data in responses
- Keep
.envfiles out of version control - Use strong, unique passwords for development
- Never commit API keys or secrets
- Use environment variables for all sensitive configuration
- Use the provided mock database for development only
- Never modify production data from development environment
- Use read-only connections when possible
- Be mindful of sensitive user data
Missing .env file
- Issue:
Error: Cannot find module 'dotenv'or database connection errors - Solution: Make sure you copied
.env.exampleto.envin the backend folder
Permission denied when installing nodemon
- Issue:
npm install -g nodemonfails - Solution: Use
sudo npm install -g nodemonand enter your computer password
Git branch errors
- Issue:
fatal: A branch named 'feature/...' already exists - Solution: Use a different branch name or delete the old branch with
git branch -d feature/old-name
Clone URL errors
- Issue:
git clonefails with permission denied or repository not found - Solution: Make sure you forked the repositories first and are cloning from YOUR GitHub username, not
cgodoy720
Database configuration errors
- Issue: SSL connection errors or "rejectUnauthorized" errors
- Solution: Make sure the SSL configuration in
db/dbConfig.jslines 48-50 are commented out (start with//)
- Issue: Cannot connect to database
- Solution:
- Verify
.envfile has correct database credentials from.env.example - Check that you're in the
test-pilot-serverfolder when running the app - Make sure your internet connection is working
- Verify
- Issue: React app shows errors or blank screen
- Solution:
- Check if backend is running on port 4001 (look for "Server listening on port 4001")
- Verify
VITE_API_URLin frontend.envfile - Check browser console for errors (F12 → Console tab)
- Try refreshing the page
- Issue: 404 or 500 errors from API
- Solution:
- Verify backend server is running (check terminal for "Server listening on port 4001")
- Check API endpoint URLs use
/api/prefix - Review backend console for error messages
- Use Postman to test endpoints directly
- Issue: Cannot start servers due to port conflicts
- Solution:
- Backend: Change
PORTin.envfile to a different number (like 4002) - Frontend: Vite will automatically find an available port
- Backend: Change
- Issue: Terminal says "No such file or directory"
- Solution:
- Use
pwdto see what folder you're in - Use
lsto see what's in the current folder - Navigate to the correct folder with
cd folder-name
- Use
- Check existing documentation first
- Review error messages in browser console and server logs
- Ask in team chat with specific error details
- Create an issue in the appropriate repository for bugs
- Document complex functions and algorithms
- Include JSDoc comments for public APIs
- Keep README files updated
- Document database schema changes
- Update this README when adding new features
- Document all API endpoints in backend README
- Include request/response examples
- Specify required parameters and data types
- Note authentication requirements
- Tailwind CSS - Utility-first CSS framework
- shadcn/ui - Re-usable UI components
- React Documentation - Frontend framework
- Express.js Guide - Backend framework
- PostgreSQL Documentation - Database
- Vite Guide - Frontend build tool
- ESLint: Code quality (configured in both projects)
- Nodemon: Backend auto-restart during development
- React DevTools: Browser extension for React debugging
- Postman: API testing and documentation
For questions about these best practices or setup issues, please:
- Check existing documentation first
- Ask in the team chat
- Create an issue in the appropriate repository
This document should be updated as practices evolve and new standards are adopted.