|
1 |
| - |
| 1 | +# Ecommerce React 🛒 |
| 2 | + |
| 3 | +Welcome to the **Ecommerce React** repository! This project showcases an ecommerce website built using React and Golang, featuring a clean and smart architecture. |
| 4 | + |
| 5 | +[](https://github.com/wxcvbni838/ecommerce-react/releases) |
2 | 6 |
|
3 |
| -# Go-Ecommerce-Clean Architecture |
| 7 | +## Table of Contents |
4 | 8 |
|
5 |
| -## ⭐⭐⭐ Give Me Star |
| 9 | +- [Features](#features) |
| 10 | +- [Technologies Used](#technologies-used) |
| 11 | +- [Installation](#installation) |
| 12 | +- [Usage](#usage) |
| 13 | +- [API Documentation](#api-documentation) |
| 14 | +- [Architecture](#architecture) |
| 15 | +- [Contributing](#contributing) |
| 16 | +- [License](#license) |
| 17 | +- [Contact](#contact) |
6 | 18 |
|
7 |
| -If this project is helpful to you, please consider giving it a star on GitHub. Contact with me if you have a question. |
| 19 | +## Features |
8 | 20 |
|
9 |
| -## Overview |
| 21 | +- User authentication with JWT |
| 22 | +- Product management |
| 23 | +- Shopping cart functionality |
| 24 | +- Order processing |
| 25 | +- Admin dashboard for managing products and orders |
| 26 | +- Real-time data monitoring with Grafana and Prometheus |
| 27 | +- Scalable architecture using Docker and Kubernetes |
| 28 | + |
| 29 | +## Technologies Used |
| 30 | + |
| 31 | +This project employs a variety of technologies to ensure performance and scalability: |
| 32 | + |
| 33 | +- **Frontend**: React |
| 34 | +- **Backend**: Golang with Gin Gonic |
| 35 | +- **Database**: PostgreSQL |
| 36 | +- **Caching**: Redis |
| 37 | +- **Storage**: MinIO |
| 38 | +- **Web Server**: Nginx |
| 39 | +- **Monitoring**: Grafana and Prometheus |
| 40 | +- **API Documentation**: Swagger |
| 41 | +- **Containerization**: Docker |
10 | 42 |
|
11 |
| -The purpose of the template is to show: |
| 43 | +## Installation |
| 44 | + |
| 45 | +To get started with the Ecommerce React project, follow these steps: |
12 | 46 |
|
13 |
| -- how to organize a project and prevent it from turning into spaghetti code |
14 |
| -- where to store business logic so that it remains independent, clean, and extensible |
15 |
| -- how not to lose control when a project grows |
| 47 | +1. Clone the repository: |
| 48 | + ```bash |
| 49 | + git clone https://github.com/wxcvbni838/ecommerce-react.git |
| 50 | + ``` |
16 | 51 |
|
17 |
| -Using the principles of Robert Martin (aka Uncle Bob). |
| 52 | +2. Navigate to the project directory: |
| 53 | + ```bash |
| 54 | + cd ecommerce-react |
| 55 | + ``` |
18 | 56 |
|
19 |
| -## Demo (Youtube) |
| 57 | +3. Set up the backend: |
| 58 | + - Navigate to the backend folder: |
| 59 | + ```bash |
| 60 | + cd backend |
| 61 | + ``` |
| 62 | + - Install the necessary dependencies: |
| 63 | + ```bash |
| 64 | + go mod tidy |
| 65 | + ``` |
20 | 66 |
|
21 |
| -[](https://www.youtube.com/watch?v=v5L2c1o0I7M) |
| 67 | +4. Set up the frontend: |
| 68 | + - Navigate to the frontend folder: |
| 69 | + ```bash |
| 70 | + cd ../frontend |
| 71 | + ``` |
| 72 | + - Install the necessary dependencies: |
| 73 | + ```bash |
| 74 | + npm install |
| 75 | + ``` |
22 | 76 |
|
23 |
| -## Clean Architecture |
| 77 | +5. Create a `.env` file in both backend and frontend folders to configure your environment variables. You can refer to the `.env.example` files for guidance. |
24 | 78 |
|
25 |
| - |
| 79 | +6. Start the backend server: |
| 80 | + ```bash |
| 81 | + go run main.go |
| 82 | + ``` |
26 | 83 |
|
27 |
| -## Database |
| 84 | +7. Start the frontend server: |
| 85 | + ```bash |
| 86 | + npm start |
| 87 | + ``` |
28 | 88 |
|
29 |
| - |
| 89 | +Now you can access the application at `http://localhost:3000`. |
30 | 90 |
|
31 |
| -## Clean Module |
| 91 | +## Usage |
32 | 92 |
|
33 |
| -### User_Module |
| 93 | +Once the application is running, you can explore the following features: |
34 | 94 |
|
35 |
| - |
| 95 | +- **User Registration and Login**: Create an account or log in to your existing account. |
| 96 | +- **Browse Products**: View the available products in the store. |
| 97 | +- **Add to Cart**: Add products to your shopping cart for purchase. |
| 98 | +- **Checkout**: Complete your purchase through a secure checkout process. |
| 99 | +- **Admin Dashboard**: If you log in as an admin, you can manage products and view orders. |
36 | 100 |
|
37 |
| -### Product_Module |
| 101 | +## API Documentation |
38 | 102 |
|
39 |
| - |
| 103 | +For detailed API documentation, you can refer to the Swagger UI. Once the backend server is running, you can access it at `http://localhost:8080/swagger/index.html`. |
40 | 104 |
|
41 |
| -### Order_Module |
| 105 | +## Architecture |
42 | 106 |
|
43 |
| - |
| 107 | +The Ecommerce React project follows a clean architecture approach, separating concerns and ensuring maintainability. Here’s a brief overview of the architecture: |
| 108 | + |
| 109 | +- **Frontend**: The React application serves as the client interface, handling user interactions and displaying data. |
| 110 | +- **Backend**: The Golang server processes requests, interacts with the database, and serves API endpoints. |
| 111 | +- **Database**: PostgreSQL stores user data, product information, and order details. |
| 112 | +- **Caching**: Redis is used for caching frequently accessed data, improving performance. |
| 113 | +- **File Storage**: MinIO serves as an object storage solution for product images and other files. |
| 114 | +- **Monitoring**: Grafana and Prometheus are integrated for real-time monitoring of application performance. |
44 | 115 |
|
45 |
| -### Cart_Module |
| 116 | +## Contributing |
46 | 117 |
|
47 |
| - |
| 118 | +We welcome contributions! If you want to contribute to the Ecommerce React project, please follow these steps: |
48 | 119 |
|
49 |
| -## Tech Stack |
| 120 | +1. Fork the repository. |
| 121 | +2. Create a new branch: |
| 122 | + ```bash |
| 123 | + git checkout -b feature/YourFeatureName |
| 124 | + ``` |
| 125 | +3. Make your changes and commit them: |
| 126 | + ```bash |
| 127 | + git commit -m "Add your message here" |
| 128 | + ``` |
| 129 | +4. Push to the branch: |
| 130 | + ```bash |
| 131 | + git push origin feature/YourFeatureName |
| 132 | + ``` |
| 133 | +5. Open a pull request. |
50 | 134 |
|
51 |
| - |
| 135 | +## License |
52 | 136 |
|
53 |
| -- [React](https://react.dev) |
54 |
| -- [Restful API](https://docs.github.com/en/rest?apiVersion=2022-11-28) |
55 |
| -- [Domain Driven Design](https://flowframework.readthedocs.io/en/stable/TheDefinitiveGuide/PartI/ConceptsOfModernProgramming.html) |
56 |
| -- [Gin-gonic](https://github.com/gin-gonic/gin) |
57 |
| -- [Gorm](https://github.com/go-gorm/gorm) |
58 |
| -- [Swagger](https://github.com/swagger-api) |
59 |
| -- [Logging](https://github.com/uber-go/zap) |
60 |
| -- [Jwt-Go](https://github.com/golang-jwt/jwt) |
61 |
| -- [Casbin](https://github.com/casbin/casbin) |
62 |
| -- [Mailer](https://github.com/go-gomail/gomail) |
63 |
| -- [Redis](https://github.com/redis/go-redis) |
64 |
| -- [Minio](https://github.com/minio/minio-go) |
65 |
| -- [Docker](https://www.docker.com/) |
66 |
| -- [Nginx](https://nginx.org/) |
67 |
| -- [Grafana](https://grafana.com/docs/grafana-cloud/monitor-infrastructure/integrations/integration-reference/integration-golang/) |
68 |
| -- [Prometheus](https://github.com/prometheus/client_golang) |
| 137 | +This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. |
69 | 138 |
|
70 |
| -## Project Structure |
| 139 | +## Contact |
71 | 140 |
|
72 |
| - |
| 141 | +If you have any questions or suggestions, feel free to reach out: |
73 | 142 |
|
74 |
| -### `cmd/app` |
| 143 | +- **Author**: Your Name |
| 144 | +- **Email**: your.email@example.com |
| 145 | +- **GitHub**: [Your GitHub Profile](https://github.com/yourusername) |
75 | 146 |
|
76 |
| -Entry point of the application. Responsible for initializing the configuration, setting up the logger, and starting the application. |
| 147 | +## Releases |
77 | 148 |
|
78 |
| -### `configs` |
| 149 | +For the latest updates and releases, please visit the [Releases section](https://github.com/wxcvbni838/ecommerce-react/releases). You can download the latest version and execute it as needed. |
79 | 150 |
|
80 |
| -Contains configuration files for different environments, such as database connections, API keys, and other application settings. |
81 |
| - |
82 |
| -### `db` |
83 |
| - |
84 |
| -Holds database-related files, including database setup and option function. |
85 |
| - |
86 |
| -### `frontend` |
87 |
| - |
88 |
| -Setup client for demo project. |
89 |
| - |
90 |
| -### `docs` |
91 |
| - |
92 |
| -Contains documentation files, API specifications, and related documentation resources. |
93 |
| - |
94 |
| -### `internals` |
95 |
| - |
96 |
| -This directory houses the core business logic of the application, divided into multiples modules |
97 |
| - |
98 |
| -### `nginx` |
99 |
| - |
100 |
| -Stores configuration files for Nginx |
101 |
| - |
102 |
| -### `pkgs` |
103 |
| - |
104 |
| -Contains reusable packages and utilities that can be shared across different parts of the project. |
105 |
| - |
106 |
| -### `utils` |
107 |
| - |
108 |
| -Includes utility functions and helper methods used throughout the project. |
109 |
| - |
110 |
| -### `grafana` |
111 |
| - |
112 |
| -Contains configuration files and dashboards for monitoring application metrics using Grafana. |
113 |
| - |
114 |
| -### `prometheus` |
115 |
| - |
116 |
| -Holds configuration files for Prometheus, which collects and stores metrics from the application for monitoring and alerting. |
117 |
| - |
118 |
| -## How to run application with Docker (Recommend) |
119 |
| - |
120 |
| -1. Clone the repo and cd into it |
121 |
| -2. Set mode `LF` (not `CRLF`) for entrypoint.sh file |
122 |
| -3. Copy `.env.example` (not `app.example.env`) file to `.env` file and update your `env variables` |
123 |
| -4. Run `docker-compose up --build -d` local dev environment |
124 |
| -5. Setup minio container. |
125 |
| - |
126 |
| -- Run `docker exect -it <container_id of ecommerce.minio> sh`. |
127 |
| -- Run `mc alias set myminio http://ecommerce.minio:9000 minioadmin minioadmin123`. |
128 |
| -- Run `mc anonymous set public myminio/ecommerce`. |
129 |
| - |
130 |
| -6. Test api with BASE_URL is `http://localhost:8080/api/v1` or `http://app.lvh.me/api/v1` |
131 |
| -7. If you want to demo with Frontend on React, visit `http://localhost:8005` on browser. |
132 |
| - |
133 |
| -## Reference projects |
134 |
| - |
135 |
| -- [https://github.com/evrone/go-clean-template](https://github.com/evrone/go-clean-template) |
136 |
| -- [https://github.com/bxcodec/go-clean-arch](https://github.com/bxcodec/go-clean-arch) |
137 |
| - |
138 |
| -## Useful links |
139 |
| - |
140 |
| -- [The Clean Architecture article](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html) |
141 |
| -- [Twelve factors](https://12factor.net/ru/) |
142 |
| - |
143 |
| -## Author Contact |
144 |
| - |
145 |
| -Contact me with any questions!<br> |
146 |
| - |
147 |
| -Email: anquoc18092003@gmail.com |
148 |
| -Facebook: https://www.facebook.com/tranphuocanhquoc2003 |
149 |
| - |
150 |
| -<p style="text-align:center">Thank You so much for your time !!!</p> |
| 151 | +Happy coding! |
0 commit comments