Quick Setup Guide
Get Rainfall-Learning running on your local machine in minutes with this step-by-step guide.
Project Overview
Rainfall-Learning is a monorepo containing:
- Backend: Node.js API with Prisma ORM
- Frontend: React/Vite application with Material-UI
- Shared: TypeScript types and utilities shared between packages
Project Structure
packages/
├── backend/ # Node.js API with Prisma
├── frontend/ # React/Vite application
└── shared/ # Shared types and utilities
Prerequisites
Before you begin, ensure you have the following installed:
- Node.js v18.0.0 or higher
- npm v9.0.0 or higher
- Docker (for database and services)
- Git for version control
Verify Prerequisites
# Check Node.js version
node --version # Should output v18.0.0 or higher
# Check npm version
npm --version # Should output 9.0.0 or higher
# Check Docker
docker --version
Quick Start
1. Clone the Repository
git clone https://github.com/Aryan0102/Rainfall-Learning.git
cd Rainfall-Learning
2. Install Dependencies
# Install all dependencies for the monorepo
npm install
# This automatically installs dependencies for:
# - Root workspace
# - packages/backend
# - packages/frontend
# - packages/shared
3. Start Development Environment
# Start all containers (auto-builds if needed)
npm run docker:start
# This automatically:
# - Builds Docker containers if they don't exist
# - Starts PostgreSQL database with health monitoring
# - Starts backend (waits for healthy database)
# - Starts frontend with shared packages
# - Handles all migrations automatically
Note: The --build flag ensures containers are built if they don't exist, so developers don't need to remember to run docker:build first.
That's it! Your application should now be running:
- Frontend: http://localhost:5173
- Backend API: http://localhost:3000
- Database: localhost:5432 (PostgreSQL)
4. Run Tests
# Run all tests (backend + frontend)
npm run test
# This runs tests inside Docker containers:
# - Backend tests with database access
# - Frontend tests with DOM environment (jsdom)
# - All shared package imports work correctly
# - Tests are located in packages/*/tests/ directories
Testing Notes:
- Tests run inside Docker containers for consistency
- Database is automatically set up when you start Docker
- No need to rebuild containers for test file changes
- Tests have access to the same environment as your application
- Frontend tests are located in
packages/frontend/tests/ - Backend tests are located in
packages/backend/tests/ - Test configuration uses Vitest with proper path mapping for shared packages
Available Scripts
Docker Development
| Command | Description |
|---|---|
npm run docker:build | Build all Docker containers |
npm run docker:start | Start all services (auto-builds) |
npm run docker:stop | Stop all services |
npm run docker:logs | View logs from all containers |
npm run docker:rebuild | Rebuild containers from scratch |
Traditional Development (Alternative)
| Command | Description |
|---|---|
npm run dev | Start both frontend and backend in development mode |
npm run dev:backend | Start only the backend server |
npm run dev:frontend | Start only the frontend application |
npm run build | Build all packages for production |
Code Quality
| Command | Description |
|---|---|
npm run lint | Run ESLint on all packages |
npm run lint:fix | Auto-fix ESLint issues |
npm run format | Format code with Prettier |
npm run format:check | Check if code is formatted |
npm run typecheck | Run TypeScript type checking |
Testing
| Command | Description |
|---|---|
npm run test | Run all tests (backend + frontend) |
npm run test:watch | Run backend tests in watch mode |
npm run test:backend | Test only backend (Docker container) |
npm run test:frontend | Test only frontend (Docker container) |
npm run test:shared | Test shared package (Docker container) |
npm run test:coverage | Generate test coverage report |
npm run test:coverage:backend | Backend coverage only |
npm run test:coverage:frontend | Frontend coverage only |
npm run test:coverage:shared | Shared package coverage only |
Note: All tests run inside Docker containers for consistency with the development environment.
Documentation
| Command | Description |
|---|---|
npm run docs:build | Build all documentation |
npm run docs:typedoc | Generate TypeDoc API docs |
npm run docs:swagger | Generate Swagger API docs |
Container Independence
The Docker setup provides complete container independence:
✅ Automatic Setup
- Database: PostgreSQL with persistent storage
- Backend: Node.js API with Prisma client generation
- Frontend: React/Vite with shared package building
✅ No Manual Intervention
- Dependencies install automatically
- Database schema resets and migrates automatically
- Shared packages build automatically
- Hot reloading works out of the box
✅ Development Workflow
- Start:
npm run docker:start - Make changes: Edit files in
packages/backendorpackages/frontend - See changes: Hot reloading reflects immediately
- Test:
npm run test(runs inside Docker containers) - Stop:
npm run docker:stop
Common Setup Issues
Docker Not Running
# Start Docker Desktop
# Then try again:
npm run docker:start
Port Conflicts
# Check what's using the ports
lsof -i :3000 # Backend
lsof -i :5173 # Frontend
lsof -i :5432 # Database
# Kill processes if needed
kill -9 <PID>
Container Build Issues
# Clean everything and rebuild
npm run docker:clean
npm run docker:rebuild
Database Connection Issues
# Check container logs
npm run docker:logs
# Restart containers
npm run docker:restart
Verify Installation
Run these commands to ensure everything is working:
# Check container status
docker-compose ps
# Check logs
npm run docker:logs
# Test backend API
curl http://localhost:3000/health
## Next Steps
1. **Explore the Documentation**
2. **Understand the Architecture**: Read the [Architecture Guide](/docs/General Important Info/architecture)
3. **Docker Setup**: Read the [Docker Guide](/docs/docker.md) for detailed configuration
4. **Set Up Your IDE**: Install recommended VS Code extensions
## Getting Help
- **Internal Discord**: #general or ping a tech lead
- **Documentation**: Check `/documentation/`
- **Docker Guide**: [Docker Setup Documentation](/docs/docker.md)
- **TypeScript IntelliSense**: Your IDE will provide hints for all shared types