You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-11Lines changed: 16 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
1
# Golang CRUD Service
2
2
3
-
This is a sample CRUD service built with **Golang**, demonstrating a layered architecture that separates concerns into handler, service, repository, and model layers. The project uses **TiDB** as the relational database, **Redis** for `caching` and `pub/sub` in-memory operations, and **JWT** for authentication.
3
+
This is a sample CRUD service built with **Golang**, demonstrating a layered architecture that separates concerns into handler, service, repository, and model layers. The project uses **TiDB** as the relational database, **Redis** for `caching` and `async tasks` in-memory operations, and **JWT** for authentication.
4
4
5
-
## 🚀 Project Purpose
5
+
## Project Purpose
6
6
7
7
Build a sample CRUD service API with Golang to showcase code structure and common best practices in web API development.
8
8
9
-
## 🛠️ Tech Stack
9
+
## Tech Stack
10
10
11
11
-**[Golang](https://golang.org)** — Core programming language
12
12
-**[Fiber](https://gofiber.io)** — Fast HTTP router
@@ -18,7 +18,7 @@ Build a sample CRUD service API with Golang to showcase code structure and commo
18
18
-**[Redis Stream](https://redis.io/docs/latest/develop/data-types/streams)** — Background task queue using consumer group
19
19
-**[JWT](https://github.com/golang-jwt/jwt)** — JSON Web Token implementation for authentication
20
20
21
-
## 📁 Project Structure
21
+
## Project Structure
22
22
23
23
```
24
24
├── cmd/
@@ -47,22 +47,26 @@ Build a sample CRUD service API with Golang to showcase code structure and commo
47
47
│ └── dto/ # DTOs for transforming request/response data
48
48
```
49
49
50
-
## 📌 Key Concepts
50
+
## Key Concepts
51
51
52
52
-**Layered Architecture**: Divides the project into clear layers for maintainability and scalability.
53
-
-**Goroutines**: Background task workers use `goroutines` to run concurrently and process`redis stream` jobs efficiently.
53
+
-**Goroutines**: Background task workers use `goroutines` to run concurrent`redis stream` jobs efficiently.
54
54
-**Rate Limit**: Failed attempts and request limited using `redis` to prevent abuse `429 Too Many Requests`.
55
55
-**DTO Pattern**: Uses `copier` to map between internal models and request/response structures.
56
56
-**Validation**: Ensures request payloads are validated with `go-playground/validator`.
57
57
-**ORM**: Leverages `GORM` to interact with `TiDB` in a concise and type-safe way.
58
+
-**SMTP**: Standard `net/smtp` package for email sending to SMTP server.
58
59
59
-
## 🧪 Running the Project
60
+
> 💡 Tip: If you're using Gmail SMTP: allow **"Less secure apps"** (not recommended)
61
+
62
+
## Running the Project
60
63
61
64
1.**Configure Environment**
62
65
Create a `.env` file. find in a `.env.example` file for environment:
63
-
- JWT Secret key
64
-
- TiDB connection
65
66
- Redis connection
67
+
- TiDB connection
68
+
- Email configure
69
+
- JWT Secret key
66
70
67
71
2.**Run the App**
68
72
```bash
@@ -79,11 +83,12 @@ Build a sample CRUD service API with Golang to showcase code structure and commo
79
83
docker compose up -d
80
84
```
81
85
82
-
## 🔧 Future Enhancements
86
+
87
+
## Future Enhancements
83
88
84
89
- Add unit tests and integration tests
85
90
- Add Swagger/OpenAPI documentation
86
91
87
-
## 📄 License
92
+
## License
88
93
89
94
This project is open-source and available under the [MIT License]().
0 commit comments