Welcome Contributors!
Thank you for your interest in contributing to POS Kasir! This guide will help you set up your development environment and understand the development workflow.Prerequisites
Before you begin, ensure you have the following installed:Required
Optional but Recommended
- Docker & Docker Compose - Install
- sqlc - Install
- golang-migrate - Install
- Air (Go hot reload) - Install
- Make (usually pre-installed on Linux/macOS)
Development Tools
IDE Recommendations: Useful VS Code Extensions:- Go (golang.go)
- PostgreSQL (ckolkman.vscode-postgres)
- Docker (ms-azuretools.vscode-docker)
- Thunder Client (REST API testing)
Getting Started
1. Clone the Repository
2. Set Up Environment Variables
Backend Configuration
.env with your settings:
- Midtrans: Sign up → Dashboard → Settings → Access Keys
- Cloudflare R2: Cloudflare Dashboard → R2 → Create Bucket → API Tokens
Frontend Configuration
web/.env:
3. Database Setup
Option A: Using Docker (Recommended)
Option B: Local PostgreSQL
Run Migrations
Seed Database (Optional)
- Admin:
[email protected]/password123 - Manager:
[email protected]/password123 - Cashier:
[email protected]/password123
4. Install Backend Dependencies
5. Install Frontend Dependencies
6. Generate Code
Generate sqlc Code (Type-Safe Queries)
sqlc/queries/ → internal/*/repository/
Generate Swagger Documentation
- Scans Go code for Swagger annotations
- Generates OpenAPI spec to
docs/andweb/api-docs/ - Generates TypeScript API client for frontend
- Generates RBAC types for frontend
Development Workflow
Running the Backend
Option 1: Using Docker Compose (Full Stack)
Option 2: Local Development with Hot Reload
http://localhost:8080
Swagger UI: http://localhost:8080/swagger/index.html
Running the Frontend
http://localhost:3000
Full Stack Development
Run backend and frontend simultaneously in separate terminals: Terminal 1 (Backend):Makefile Commands Reference
Database Migrations
Code Generation
Database Seeding
Docker
Help
Project Structure
Adding New Features
Backend: Add a New Module
Example: Adding a “Suppliers” module1. Create Migration
sqlc/migrations/<version>_create_suppliers_table.up.sql:
sqlc/migrations/<version>_create_suppliers_table.down.sql:
2. Write SQL Queries
Createsqlc/queries/suppliers.sql:
3. Create Module Structure
dto.go:
service.go:
handler.go:
4. Register in Container
Editserver/server.go - add to AppContainer:
server/server.go - add to BuildAppContainer():
5. Add Routes
Editserver/routes.go:
6. Generate Swagger Docs
- Backend Swagger UI
- Frontend TypeScript API client
Frontend: Add a New Page
Example: Adding a Suppliers management page1. Create Route File
suppliers/index.tsx:
2. Add Navigation Link
Editweb/app/components/Sidebar.tsx:
3. Test
Visithttp://localhost:3000/suppliers
Testing
Backend Tests
Run All Tests
Writing Tests
Example:internal/products/service_test.go
Frontend Tests
Run Tests
Writing Component Tests
Example:web/app/components/ProductCard.test.tsx
Code Style & Best Practices
Go Code Style
- Follow Effective Go
- Use
gofmtfor formatting:go fmt ./... - Use
golangci-lintfor linting - Write clear comments for exported functions
- Keep functions small and focused
TypeScript Code Style
- Use functional components with hooks
- Prefer
constoverlet - Use TypeScript types (avoid
any) - Name event handlers with
handleprefix:handleSubmit - Use async/await over promises
Commit Messages
Follow Conventional Commits:<type>: <description>
Types:
feat- New featurefix- Bug fixdocs- Documentationstyle- Formattingrefactor- Code refactoringtest- Testschore- Maintenance
Debugging
Backend Debugging
Using Delve (Go Debugger)
Using VS Code
Create.vscode/launch.json:
Logging
Use the logger:Frontend Debugging
Browser DevTools
- React DevTools - Inspect component tree
- TanStack Query DevTools - View query cache
- Network Tab - Monitor API calls
Console Logging
Common Issues & Solutions
Migration Errors
Issue: “Dirty database version” Solution:Port Already in Use
Issue:bind: address already in use
Solution:
Database Connection Failed
Issue:connection refused
Solutions:
- Ensure PostgreSQL is running:
docker psorpg_isready - Check
.envcredentials - Verify database exists:
psql -U postgres -l
CORS Errors
Issue:blocked by CORS policy
Solution: Update .env:
sqlc Generation Fails
Issue:column "deleted_at" does not exist
Solution: Run migrations first:
Deployment
Building for Production
Backend
Frontend
Docker Deployment
Getting Help
Resources
- Documentation: POS Kasir Docs (if available)
- API Reference:
http://localhost:8080/swagger/index.html - GitHub Issues: Report bugs or request features
Community
- GitHub Discussions: Ask questions and share ideas
- Pull Requests: Contribute code improvements
Reporting Bugs
When reporting bugs, please include:- Description of the issue
- Steps to reproduce
- Expected behavior
- Actual behavior
- Environment (OS, Go version, PostgreSQL version)
- Logs (if applicable)
License
POS Kasir is open-source software licensed under the MIT License.Next Steps
Now that you have your development environment set up:- Explore the codebase - Read through different modules
- Run the app - Test the features
- Pick an issue - Find a “good first issue” on GitHub
- Make changes - Implement your feature or fix
- Submit PR - Share your contribution
See Also
- Architecture - System design overview
- Tech Stack - Technologies used
- Database Schema - Database structure