A comprehensive payroll management system built with Go, designed to handle employee salary calculations, deductions, and payroll processing efficiently.
- Payroll Software
- Employee management
- Salary calculation and processing
- Tax and deduction management
- Payroll report generation
- User authentication and authorization
- RESTful API endpoints
- Database migration support
- Comprehensive testing suite
This project follows a Clean Architecture pattern with clear separation of concerns. The architecture choice is based on several key principles:
-
Familiarity and Experience: This architecture pattern has been proven effective in previous projects, ensuring faster development and maintenance.
-
Separation of Concerns: Each layer has a specific responsibility, making the codebase more maintainable and testable.
-
Scalability: The modular structure allows easy addition of new features without affecting existing functionality.
-
Testability: Clear boundaries between layers make unit testing and integration testing straightforward.
-
Dependency Inversion: Business logic doesn't depend on external frameworks or databases, making the system more flexible.
┌─────────────────────────────────────────┐
│ Controllers │ ← HTTP Handlers
├─────────────────────────────────────────┤
│ Services │ ← Business Logic
├─────────────────────────────────────────┤
│ Repositories │ ← Data Access Layer
├─────────────────────────────────────────┤
│ Database │ ← Data Storage
└─────────────────────────────────────────┘
payroll-software/
├── cmd/ # Application entry points
│ ├── main.go # Main application
│ └── seed/ # Database seeding
│ └── seed.go
├── internal/ # Private application code
│ ├── controllers/ # HTTP request handlers
│ ├── models/ # Data models and entities
│ ├── dto/ # Data Transfer Objects
│ ├── services/ # Business logic layer
│ ├── repositories/ # Data access layer
│ ├── utils/ # Utility functions
│ └── response/ # API response structures
├── database/
│ └── migrations/ # Database migration files
├── tests/
│ └── e2e/ # End-to-end tests
├── .env # Environment variables
├── .env.example # Environment variables template
├── Makefile # Build and deployment commands
├── go.mod # Go module dependencies
├── go.sum # Go module checksums
└── README.md # Project documentation
-
cmd/: Contains the main applications for this project. The main.go file is the entry point of the application, while seed/ contains database seeding utilities.
-
internal/: Houses the private application code that shouldn't be imported by other applications.
- controllers/: HTTP handlers that process incoming requests and return responses
- models/: Domain entities and data structures
- dto/: Data Transfer Objects for API communication
- services/: Business logic and core application functionality
- repositories/: Data access layer that interacts with the database
- utils/: Shared utility functions and helpers
- response/: Standardized API response structures
- Go 1.19 or higher
- PostgreSQL 12 or higher
- Goose (for database migrations)
- Clone the repository:
git clone <repository-url>
cd payroll-software- Install dependencies:
go mod download- Install Goose for database migrations:
go install github.com/pressly/goose/v3/cmd/goose@latest- Copy the environment variables template:
cp .env.example .env- Update the
.envfile with your database configuration:
DATABASE_URL=postgres://username:password@localhost:5432/payroll_db?sslmode=disable
DATABASE_URL_TEST=postgres://username:password@localhost:5432/payroll_test_db?sslmode=disableThe project uses Goose for database migrations. Use the following Makefile commands:
# Run all pending migrations
make up
# Run migrations for test database
make up_test
# Rollback the last migration
make down
# Create a new migration file
make new name=create_employees_tablePopulate the database with initial data:
make seedStart the development server:
make runThe application will start on the configured port (default: 8080).
make run- Start the applicationmake test- Run end-to-end testsmake up- Run database migrationsmake up_test- Run migrations for test databasemake down- Rollback last migrationmake new name=<migration_name>- Create new migrationmake seed- Seed database with initial data
Run the test suite:
make testThe project includes:
- Unit tests for individual components
- Integration tests for API endpoints
- End-to-end tests for complete workflows
The application uses PostgreSQL with the following main entities:
- Users (authentication)
- Employees (employee information)
- Payroll (salary calculations)
- Deductions (tax and other deductions)
- Reports (payroll reports)
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions, please open an issue in the GitHub repository.