mirror of
https://github.com/Viren070/tmdb-addon.git
synced 2025-12-01 23:18:11 +01:00
42d40c1b32
- Rewrite README.md with improved structure and markdown formatting - Add detailed documentation files: - self-hosting.md: Complete guide for deployment (#66) - development.md: Development setup and workflow - contributing.md: Contribution guidelines - api.md: API endpoints and usage The documentation now includes: - Clear local development setup instructions - Detailed deployment guides (Docker and manual) - Step-by-step environment configuration - API reference with examples - Development workflow guidelines - Troubleshooting sections - Best practices and code examples Closes #66
2.9 KiB
2.9 KiB
Development Guide
This guide will help you set up your development environment and understand the project structure.
Prerequisites
- Node.js 20.x or higher
- npm 9.x or higher
- Git
- MongoDB (local or Atlas)
- Basic knowledge of TypeScript and React
Project Structure
tmdb-addon/
├── addon/ # Backend server code
├── configure/ # Frontend configuration UI
├── docs/ # Documentation
├── node_modules/ # Dependencies
└── package.json # Project configuration
Setting Up Development Environment
- 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
Development Workflow
- 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
Code Style
We use ESLint and Prettier for code formatting. Configuration can be found in:
.eslintrc.js.prettierrc
Hot Reload
- Backend uses
nodemonfor automatic reloading - Frontend uses Vite's hot module replacement
Debugging
Backend Debugging
- 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
Frontend Debugging
- Use React Developer Tools browser extension
- Vite's development server includes source maps
Common Development Tasks
Adding New UI Components
- Create component in
configure/components/ - Add styles using Tailwind CSS
- Import and use in relevant pages
Best Practices
-
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