🌐 Frontend
URL: http://localhost:3000 Tech: React 18 + TypeScript + Vite
This guide helps you set up a development environment and contribute effectively to LeafLock.
git clone <repository-url>cd LeafLockcp .env.example .env# Edit .env with your settings
make up # Start all servicesmake logs # View logsmake down # Stop services
docker compose up -d # Start servicesdocker compose logs -f # View logsdocker compose down # Stop services
🌐 Frontend
URL: http://localhost:3000 Tech: React 18 + TypeScript + Vite
⚡ Backend API
URL: http://localhost:8080 Health: http://localhost:8080/api/v1/health
🔧 Go Backend
Framework: Fiber v2 (Fast HTTP framework)
Database: PostgreSQL 15 with pgx driver
Cache: Redis 7 for sessions
Security: JWT + Argon2id + XChaCha20-Poly1305
Key Files: backend/main.go
(entry point)
Core Dependencies:
github.com/gofiber/fiber/v2 // Web frameworkgithub.com/jackc/pgx/v5 // PostgreSQL drivergithub.com/redis/go-redis/v9 // Redis client
⚛️ React Frontend
Framework: React 18 + TypeScript Build Tool: Vite 5 State: Zustand (lightweight state management) Editor: TipTap (rich text editing) Encryption: libsodium-wrappers (client-side)
Core Dependencies:
"@tanstack/react-query" // Server state management"zustand" // Client state management"libsodium-wrappers" // Encryption library
cd backendgo mod download # Install dependenciesgo run main.go # Start development servergo build -o app . # Build binarygo test -v ./... # Run all tests
# Run tests with coveragemake -C backend test-coverage
# Coverage requirement: 72%make -C backend test-coverage-check
# Local test environmentmake -C backend test-local
# Format codemake -C backend fmt
# Lint codemake -C backend vet
# Run all quality checksmake -C backend lint
cd frontendpnpm install # Install dependenciespnpm run dev # Start dev server (Vite)pnpm run build # Build for productionpnpm test # Run tests (Vitest)
# Watch mode for developmentpnpm test:watch
# Coverage reportpnpm test:coverage
# Run specific testpnpm test -- --run specific-test
# Lint codepnpm run lint
# Auto-fix linting issuespnpm run lint:fix
# Type checkingpnpm run type-check
🎯 Go Conventions
Formatting:
gofmt -s
(automatic via Makefile)Naming:
// Good examplesfunc CreateUser(email string) *User { }type UserService struct { }var defaultTimeout = 30 * time.Second
// File naminguser_service.go // Implementationuser_service_test.go // Tests
⚛️ Frontend Conventions
Formatting:
Components:
// Good examplesexport function UserProfile({ userId }: { userId: string }) { }const UserList = () => { }
// File namingUserProfile.tsx // ComponentUserProfile.test.tsx // Teststypes.ts // Type definitions
🧪 Go Testing Strategy
Test Types:
Coverage Target: 72% minimum (enforced by CI)
// Test file examplefunc TestUserService_CreateUser(t *testing.T) { // Arrange service := NewUserService(mockDB)
// Act user, err := service.CreateUser("test@example.com")
// Assert assert.NoError(t, err) assert.NotNil(t, user)}
🎭 React Testing Strategy
Tools:
Focus Areas:
// Test exampleimport { render, screen } from '@testing-library/react'import { UserProfile } from './UserProfile'
test('displays user name', () => { render(<UserProfile name="John Doe" />) expect(screen.getByText('John Doe')).toBeInTheDocument()})
📝 Conventional Commits
Format: type(scope): description
Types:
feat:
New featuresfix:
Bug fixesdocs:
Documentationrefactor:
Code improvementstest:
Test additionschore:
Maintenance tasks# Good commit examplesfeat(auth): add OAuth Google integrationfix(editor): resolve formatting issue with listsdocs(api): update authentication endpointsrefactor(backend): optimize database queries
🔍 Quality Gates
Setup:
bash scripts/setup-git-hooks.sh
What runs:
📋 PR Checklist
Closes #123
)🔍 Code Review
# Required environment variables for developmentPOSTGRES_PASSWORD=your_local_postgres_passwordREDIS_PASSWORD=your_local_redis_passwordJWT_SECRET=your_64_character_jwt_secret_for_developmentSERVER_ENCRYPTION_KEY=your_32_character_encryption_keyCORS_ORIGINS=http://localhost:3000,http://localhost:5173
🐛 Backend Debugging
Logs: make logs
or docker compose logs backend
Health: curl http://localhost:8080/api/v1/health
Debug: Set LOG_LEVEL=debug
in .env
🌐 Frontend Debugging
Dev Tools: Browser developer console Network: Check API requests in Network tab State: React DevTools for component state
# Build and test locallymake build # Build all container imagesmake status # Check container statusmake clean # Clean up containers and volumes
# Database accessmake -C backend test-db-up # Start test databasemake -C backend test-db-down # Stop test database
🔄 Review Workflow
This development guide provides the foundation for contributing to LeafLock. For deployment-specific information, see the deployment guides.