# Development Workflow ## Local Development Setup ### Prerequisites ```bash # Install Node.js 20 LTS # Check: node --version (should be 20.x) # Install Docker and Docker Compose # Check: docker --version && docker-compose --version # Install global tools npm install -g @kayvan/markdown-tree-parser # For doc sharding (optional) ``` ### Initial Setup ```bash # Clone repository git clone cd books # Install frontend dependencies cd frontend npm install cd .. # Install backend dependencies cd backend npm install cd .. # Copy environment variables cp .env.example .env cp frontend/.env.example frontend/.env.local cp backend/.env.example backend/.env # Edit .env files with your database credentials # Start database with Docker docker-compose up -d postgres # Run Prisma migrations cd backend npx prisma migrate dev cd .. ``` ### Development Commands ```bash # Start all services (frontend + backend + database) docker-compose up # OR start services individually: # Start database only docker-compose up postgres # Start frontend only (dev server with HMR) cd frontend npm run dev # Runs on http://localhost:5173 # Start backend only (nodemon for auto-reload) cd backend npm run dev # Runs on http://localhost:3000 # Run tests cd frontend npm test cd backend npm test # Build for production cd frontend npm run build cd backend # No build needed (Node.js runs directly) ``` ## Environment Configuration ### Required Environment Variables ```bash # Backend (.env in backend/) DATABASE_URL="postgresql://user:password@localhost:5432/books" API_PORT=3000 NODE_ENV=development OPEN_LIBRARY_API_URL=https://openlibrary.org CORS_ORIGIN=http://localhost:5173 # Frontend (.env.local in frontend/) VITE_API_URL=http://localhost:3000/api # docker-compose.yml uses shared .env at root POSTGRES_USER=postgres POSTGRES_PASSWORD=postgres POSTGRES_DB=books ``` ---