This guide will help you set up your development environment and understand the project structure.
- Node.js 20.x or higher
- npm 9.x or higher
- Git
- MongoDB (local or Atlas)
- Basic knowledge of TypeScript and React
tmdb-addon/
├── addon/ # Backend server code
├── configure/ # Frontend configuration UI
├── docs/ # Documentation
├── node_modules/ # Dependencies
└── package.json # Project configuration
- Clone the repository:
git clone https://github.com/mrcanelas/tmdb-addon.git
cd tmdb-addon
- Install dependencies:
npm install
- Set up environment variables:
cp .env.example .env
Edit .env
with your development credentials:
MONGODB_URI=your_mongodb_uri
FANART_API=your_fanart_key
TMDB_API=your_tmdb_key
HOST_NAME=http://localhost:1337
PORT=1337
- Start development server:
# Terminal 1 - Backend
npm run dev:server
# Terminal 2 - Frontend
npm run dev
- Create a new branch:
git checkout -b feature/your-feature-name
- Make your changes:
- Backend changes go in the
addon/
directory - Frontend changes go in the
configure/
directory
- Testing:
# Run tests
npm test
# Run linter
npm run lint
- Building:
npm run build
We use ESLint and Prettier for code formatting. Configuration can be found in:
.eslintrc.js
.prettierrc
- Backend uses
nodemon
for automatic reloading - Frontend uses Vite's hot module replacement
- Using VS Code:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug Server",
"program": "${workspaceFolder}/addon/server.js",
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
}
]
}
- Using Chrome DevTools:
node --inspect addon/server.js
- Use React Developer Tools browser extension
- Vite's development server includes source maps
- Create component in
configure/components/
- Add styles using Tailwind CSS
- Import and use in relevant pages
-
Code Organization:
- Keep components small and focused
- Use TypeScript interfaces for type safety
- Follow the Single Responsibility Principle
-
Performance:
- Implement caching where appropriate
- Use pagination for large datasets
- Optimize API calls
-
Security:
- Validate all user inputs
- Use environment variables for secrets
- Implement rate limiting
-
Testing:
- Write unit tests for critical functions
- Test edge cases
- Use meaningful test descriptions