E-Gommerce is a powerful and comprehensive Go-based web API for building scalable e-commerce applications. The primary objective of this project is to serve as a valuable resource for developers learning Go, providing a well-structured template for building APIs while adhering to best practices and Go idioms. The project aims to strike a balance between being approachable for beginners and offering in-depth insights into creating robust APIs.
If you feel the project is not approachable or could be improved in any way, please open an issue. I am always looking for ways to improve the project and make it more accessible to developers of all skill levels.
- Browse products and retrieve detailed product information.
- User-friendly error handling and messaging.
- Detailed API documentation using Swagger.
Coming Soon:
- Create a user account and perform user authentication.
- Favorite items for future reference.
- Add items to the cart for purchase.
E-Gommerce is designed for developers who are learning Go and want to explore real-world project structures, idiomatic practices, and essential considerations when building scalable APIs. While not intended as a standalone e-commerce site, it serves as a starting point for those interested in learning how to create feature-rich APIs.
- Routing: Chi
- Middleware: httprate, Logger, Heartbeat, CleanPath, AllowContentType, Recoverer, RedirectSlashes, Limit (See Chi Middleware)
- Database: MariaDB with go-sql-driver/mysql.
- Environment Variables: joho/godotenv
- Swagger Documentation: swaggo/swag and swaggo/http-swagger
- Task Automation: Taskfile
- Linting: golangci-lint
- Live Reloading: Air
- Database: Azure Database for MariaDB
To run the project locally, follow these steps:
- Clone the repository:
git clone https://github.com/YourUsername/e-gommerce.git
- Navigate to the project directory:
cd e-gommerce
- Install Go, and Task (optional, but recommended for task automation)
- Build and run the project:
task run
orgo run .
. See usage for more details.
E-Gommerce uses Task for task automation. Alternatively, you can use the standard Go commands to build and run the project.
To enable live reloading, install Air and run air
in the project directory. This will automatically rebuild and restart the project when changes are detected. It is configured to put the build in the tmp
directory, which is ignored by Git and destroyed when it stops running. Configuration for Air is stored in the .air.toml
file.
Available tasks include:
task run
: Builds and runs the project.task build
: Creates a build of the project.task lint
: Runs golangci-lint for code linting.task test
: Runs tests with coverage.task swag
: Generates Swagger documentation using swag.task pcc
: Runs Pre-Commit Checks (PCCs). This performs linting, testing, and Swagger documentation generation in the correct order.
Configuration for Task is stored in the Taskfile.yml file.
- Build:
mkdir -p build
thengo build -o ./build/ .
- Test:
go test ./... -cover
- Lint:
golangci-lint run
- Generate Swagger Docs:
swag init -o './api' -g './cmd/web/server.go' --parseDependency
, thenswag fmt
to format
E-Gommerce welcomes contributions from the community. You can contribute by:
- Providing feedback and suggestions
- Implementing new features and functionalities
- Enhancing project documentation
- Assisting with testing and quality assurance
- Improving project structure, performance, and security
To contribute:
- Fork the repository using the fork button at the top of the page or by running
git clone https://github.com/Broderick-Westrope/e-gommerce
. - Create a new branch for your feature or improvement:
git checkout -b feature/<your-feature-name>
- Make your changes and commit them.
- Push your changes to your fork.
- Create a pull request to the main repository.
If you are unsure about any of these please reach out to me at [email protected].
- Implement Vue 3 frontend for a user-friendly browsing experience.
- Implement authentication and authorization mechanisms.
- Finalize core functionalities for the cart, favorites, and user actions.
- Implement automated deployment strategies.
- Establish a vibrant open-source community around the project.
- Create educational blog posts and documentation to guide developers in using and contributing to the project, and replicating its features.
For detailed information about API endpoints and usage, please refer to the Swagger Documentation.
For any questions, suggestions, or collaboration opportunities, you can reach out to the project owner, Broderick Westrope, at [email protected].
E-Gommerce is licensed under the GNU General Public License v3.0. Please review the license for detailed terms and conditions.