|
| 1 | +# Contributing to Vesting Vault |
| 2 | + |
| 3 | +Thank you for your interest in contributing to Vesting Vault! This guide will help you get the development environment set up and running quickly. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +Before you begin, ensure you have the following installed: |
| 8 | + |
| 9 | +- [Docker](https://docs.docker.com/get-docker/) (v20.10 or later) |
| 10 | +- [Docker Compose](https://docs.docker.com/compose/install/) (v2.0 or later) |
| 11 | +- [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) |
| 12 | + |
| 13 | +## Quick Start (Recommended) |
| 14 | + |
| 15 | +The fastest way to get started is using Docker Compose: |
| 16 | + |
| 17 | +1. **Clone the repository** |
| 18 | + ```bash |
| 19 | + git clone <repository-url> |
| 20 | + cd Vesting-Vault |
| 21 | + ``` |
| 22 | + |
| 23 | +2. **Start all services** |
| 24 | + ```bash |
| 25 | + docker-compose up -d |
| 26 | + ``` |
| 27 | + |
| 28 | +3. **Verify services are running** |
| 29 | + ```bash |
| 30 | + # Check backend health |
| 31 | + curl http://localhost:3000/health |
| 32 | + |
| 33 | + # Check all services status |
| 34 | + docker-compose ps |
| 35 | + ``` |
| 36 | + |
| 37 | +That's it! Your development environment is now running with: |
| 38 | +- Backend API: http://localhost:3000 |
| 39 | +- PostgreSQL Database: localhost:5432 |
| 40 | +- Redis Cache: localhost:6379 |
| 41 | + |
| 42 | +## Development Workflow |
| 43 | + |
| 44 | +### Running Services |
| 45 | + |
| 46 | +```bash |
| 47 | +# Start all services in detached mode |
| 48 | +docker-compose up -d |
| 49 | + |
| 50 | +# Start services with logs |
| 51 | +docker-compose up |
| 52 | + |
| 53 | +# Stop all services |
| 54 | +docker-compose down |
| 55 | + |
| 56 | +# Stop services and remove volumes (clean slate) |
| 57 | +docker-compose down -v |
| 58 | +``` |
| 59 | + |
| 60 | +### Viewing Logs |
| 61 | + |
| 62 | +```bash |
| 63 | +# View all logs |
| 64 | +docker-compose logs |
| 65 | + |
| 66 | +# View specific service logs |
| 67 | +docker-compose logs backend |
| 68 | +docker-compose logs db |
| 69 | +docker-compose logs redis |
| 70 | + |
| 71 | +# Follow logs in real-time |
| 72 | +docker-compose logs -f backend |
| 73 | +``` |
| 74 | + |
| 75 | +### Backend Development |
| 76 | + |
| 77 | +The backend service is configured for development with hot-reloading: |
| 78 | + |
| 79 | +```bash |
| 80 | +# Access the backend container |
| 81 | +docker-compose exec backend sh |
| 82 | + |
| 83 | +# Install new dependencies |
| 84 | +docker-compose exec backend npm install <package-name> |
| 85 | + |
| 86 | +# Run tests |
| 87 | +docker-compose exec backend npm test |
| 88 | + |
| 89 | +# Access database directly |
| 90 | +docker-compose exec db psql -U postgres -d vesting_vault |
| 91 | +``` |
| 92 | + |
| 93 | +### Database Management |
| 94 | + |
| 95 | +```bash |
| 96 | +# Connect to PostgreSQL |
| 97 | +docker-compose exec db psql -U postgres -d vesting_vault |
| 98 | + |
| 99 | +# Create database migrations (if using Sequelize) |
| 100 | +docker-compose exec backend npx sequelize-cli migration:create --name migration_name |
| 101 | + |
| 102 | +# Run migrations |
| 103 | +docker-compose exec backend npx sequelize-cli db:migrate |
| 104 | +``` |
| 105 | + |
| 106 | +## Environment Configuration |
| 107 | + |
| 108 | +### Backend Environment Variables |
| 109 | + |
| 110 | +Copy the example environment file and customize as needed: |
| 111 | + |
| 112 | +```bash |
| 113 | +cp backend/.env.example backend/.env |
| 114 | +``` |
| 115 | + |
| 116 | +Key environment variables: |
| 117 | +- `PORT`: Backend server port (default: 3000) |
| 118 | +- `NODE_ENV`: Environment (development/production) |
| 119 | +- `DB_HOST`: Database host (default: db for Docker) |
| 120 | +- `DB_PORT`: Database port (default: 5432) |
| 121 | +- `DB_NAME`: Database name (default: vesting_vault) |
| 122 | +- `DB_USER`: Database user (default: postgres) |
| 123 | +- `DB_PASSWORD`: Database password (default: password) |
| 124 | +- `STELLAR_RPC_URL`: Stellar RPC endpoint (e.g., https://soroban-testnet.stellar.org) |
| 125 | +- `STELLAR_NETWORK_PASSPHRASE`: Passphrase for the configured network |
| 126 | + |
| 127 | +## Project Structure |
| 128 | + |
| 129 | +``` |
| 130 | +Vesting-Vault/ |
| 131 | +├── backend/ # Node.js backend application |
| 132 | +│ ├── src/ |
| 133 | +│ │ ├── index.js # Application entry point |
| 134 | +│ │ └── database/ # Database configuration |
| 135 | +│ ├── Dockerfile # Backend Docker configuration |
| 136 | +│ ├── package.json # Node.js dependencies |
| 137 | +│ └── .env.example # Environment variables template |
| 138 | +├── docker-compose.yml # Docker services configuration |
| 139 | +└── CONTRIBUTING.md # This file |
| 140 | +``` |
| 141 | + |
| 142 | +## Common Issues & Solutions |
| 143 | + |
| 144 | +### Port Conflicts |
| 145 | + |
| 146 | +If you encounter port conflicts, modify the port mappings in `docker-compose.yml`: |
| 147 | + |
| 148 | +```yaml |
| 149 | +ports: |
| 150 | + - "3001:3000" # Change host port from 3000 to 3001 |
| 151 | +``` |
| 152 | +
|
| 153 | +### Database Connection Issues |
| 154 | +
|
| 155 | +1. Ensure the database service is healthy: |
| 156 | + ```bash |
| 157 | + docker-compose ps |
| 158 | + ``` |
| 159 | + |
| 160 | +2. Check database logs: |
| 161 | + ```bash |
| 162 | + docker-compose logs db |
| 163 | + ``` |
| 164 | + |
| 165 | +3. Verify environment variables in your `.env` file match the database configuration. |
| 166 | + |
| 167 | +### Permission Issues (Linux/Mac) |
| 168 | + |
| 169 | +If you encounter permission errors, run: |
| 170 | + |
| 171 | +```bash |
| 172 | +sudo chown -R $USER:$USER . |
| 173 | +``` |
| 174 | + |
| 175 | +## Development Tips |
| 176 | + |
| 177 | +1. **Use meaningful commit messages** following conventional commit format |
| 178 | +2. **Run tests before committing** changes |
| 179 | +3. **Check logs** when services don't start properly |
| 180 | +4. **Use `docker-compose down -v`** for a completely fresh start |
| 181 | +5. **Monitor resource usage** with `docker stats` |
| 182 | + |
| 183 | +## API Endpoints |
| 184 | + |
| 185 | +Once the backend is running, you can access: |
| 186 | + |
| 187 | +- `GET /` - Welcome message |
| 188 | +- `GET /health` - Health check endpoint |
| 189 | + |
| 190 | +## Getting Help |
| 191 | + |
| 192 | +If you encounter issues: |
| 193 | + |
| 194 | +1. Check the troubleshooting section above |
| 195 | +2. Review service logs: `docker-compose logs` |
| 196 | +3. Ensure Docker and Docker Compose are up to date |
| 197 | +4. Check that ports 3000, 5432, and 6379 are available |
| 198 | + |
| 199 | +## Code Style Guidelines |
| 200 | + |
| 201 | +- Use ESLint for JavaScript code formatting |
| 202 | +- Follow conventional commit message format |
| 203 | +- Write meaningful variable and function names |
| 204 | +- Add comments for complex logic |
| 205 | + |
| 206 | +Thank you for contributing to Vesting Vault! 🚀 |
0 commit comments