Skip to content

Commit 0893d55

Browse files
authored
Add plantuml diagram and rewrite README parts, add Credits part (#9)
* Add puml diagram to md * Some tests * Remove md and switch to puml to svg generator * Improve doc * Update README and plantUML schema
1 parent 77dea25 commit 0893d55

File tree

5 files changed

+139
-17
lines changed

5 files changed

+139
-17
lines changed

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ env-prod: ## Up container with prod env vars
2828
cp docker-compose.yml.prod docker-compose.yml
2929
cp .env.prod .env
3030

31+
generate-plantUML: ## Generate plantUML diagrams
32+
cd ./docs/plantUML && sh generate.sh && cd ../..
33+
3134
help:
3235
@grep -E '(^[0-9a-zA-Z_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-25s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/'
3336

README.md

+34-17
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,26 @@
55
2. [Environment variables](#environment-variables)
66
2.1. [Required variables](#required-variables)
77
2.2. [Optional variables](#optional-variables)
8-
3. [Cache system](#cache-system)
9-
4. [Exemples](#exemples)
10-
4.1. [Træfik container](#træfik-container)
11-
5. [SSL](#ssl)
12-
5.1. [Træfik](#træfik)
8+
3. [Diagrams](#diagrams)
9+
3.1. [Sequence diagram](#sequence-diagram)
10+
4. [Cache systems](#cache-systems)
11+
5. [Examples](#examples)
12+
5.1. [Træfik container](#træfik-container)
13+
6. [SSL](#ssl)
14+
6.1. [Træfik](#træfik)
1315

1416
[![Travis CI](https://travis-ci.com/Darkweak/Souin.svg?branch=master)](https://travis-ci.com/Darkweak/Souin)
1517

1618
# <img src="docs/img/logo.svg?sanitize=true" alt="Souin logo" width="30" height="30">ouin reverse-proxy cache
1719

1820
## Project description
19-
Souin is a new cache system any every reverse-proxy. It will be placed on top of your current reverse-proxy whether it's Apache, nginx or Traefik.
20-
Since it's written in go, it can be deployed on any server and thantks docker integration, it will be easy to install it on top of a Swarm or a kubernetes instance.
21+
Souin is a new cache system suitable for every reverse-proxy. It will be placed on top of your current reverse-proxy whether it's Apache, Nginx or Traefik.
22+
As it's written in go, it can be deployed on any server and thanks docker integration, it will be easy to install it on top of a Swarm or a kubernetes instance.
2123

2224
## Environment variables
2325

2426
### Required variables
25-
| Variable | Description | Value exemple |
27+
| Variable | Description | Value example |
2628
|:---:|:---:|:---:|
2729
|`CACHE_PORT`|The HTTP port Souin will be listening on |`80`|
2830
|`CACHE_TLS_PORT`|The TLS port Souin will be listening on|`443`|
@@ -31,21 +33,26 @@ Since it's written in go, it can be deployed on any server and thantks docker in
3133
|`REVERSE_PROXY`|The reverse-proxy's instance URL (Apache, Nginx, Træfik...)|- `http://yourservice` (Container way)<br/>`http://localhost:81` (Local way)|
3234

3335
### Optional variables
34-
| Variable | Description | Value exemple |
36+
| Variable | Description | Value example |
3537
|:---:|:---:|:---:|
3638
|`REGEX`|The regex that matches URLs not to store in cache|`http://domain.com/mypath`|
3739

38-
## Cache system
39-
The cache sits into a Redis instance, because setting, getting, updating and deleting keys in Redis is as easy as it gets.
40-
In order to do that, Redis should be on the same network than the Souin instance when using docker-compose. When yousing binaries, then both should be on the same server.
41-
Souin will return the redis instance when it gives a valid answer, or fallback to the reverse proxy otherwise.
40+
## Diagrams
41+
42+
### Sequence diagram
43+
<img src="docs/plantUML/sequenceDiagram.svg?sanitize=true" alt="Sequence diagram">
44+
45+
## Cache systems
46+
The cache system sits on two providers at the moment. It provides an in-memory and redis cache systems because setting, getting, updating and deleting keys in Redis is as easy as it gets.
47+
In order to do that, Redis could be on the same network than the Souin instance when using docker-compose or over the internet then it will use by default in-memory to avoid network latency as much as possible.
48+
Souin will return at first the in-memory response when it gives a non-empty response, then the redis one will be used with same condition, or fallback to the reverse proxy otherwise.
4249

4350
### Cache invalidation
4451
The cache invalidation is made for CRUD requests, if you're doing a GET HTTP request, it will serve the cached response when it exists, otherwise the reverse-proxy response will be served.
4552
If you're doing a POST, PUT, PATCH or DELETE HTTP request, the related cache GET request will be dropped and the list endpoint will be dropped too
4653
It works very well with plain [API Platform](https://api-platform.com) integration (not for custom actions for now) and CRUD routes.
4754

48-
## Exemples
55+
## Examples
4956

5057
### Træfik container
5158
[Træfik](https://traefik.io) is a modern reverse-proxy and help you to manage full container architecture projects.
@@ -67,6 +74,7 @@ services:
6774
command: --providers.docker
6875
volumes:
6976
- /var/run/docker.sock:/var/run/docker.sock
77+
- /anywhere/traefik.json:/acme.json
7078
<<: *networks
7179

7280
# your other services here...
@@ -103,7 +111,7 @@ services:
103111
GOPATH: /app
104112
volumes:
105113
- ./cmd:/app/cmd
106-
- ./acme.json:/app/src/github.com/darkweak/souin/acme.json
114+
- /anywhere/traefik.json:/ssl/traefik.json
107115
<<: *networks
108116

109117
redis:
@@ -125,16 +133,25 @@ To provide, acme, use just have to map volume as above
125133
- /anywhere/traefik.json:/ssl/traefik.json
126134
```
127135
### Apache
128-
Souin will listen `apache.json` file. You have to setup your own way to agregate your SSL cert files and keys. Alternatively you can use a side project called [dob](https://github.com/darkweak/dob), it's open-source and written in go too
136+
Souin will listen `apache.json` file. You have to setup your own way to aggregate your SSL cert files and keys. Alternatively you can use a side project called [dob](https://github.com/darkweak/dob), it's open-source and written in go too
129137
```yaml
130138
volumes:
131139
- /anywhere/apache.json:/ssl/apache.json
132140
```
133141
### Nginx
134-
Souin will listen `nginx.json` file. You have to setup your own way to agregate your SSL cert files and keys. Alternatively you can use a side project called [dob](https://github.com/darkweak/dob), it's open-source and written in go too
142+
Souin will listen `nginx.json` file. You have to setup your own way to aggregate your SSL cert files and keys. Alternatively you can use a side project called [dob](https://github.com/darkweak/dob), it's open-source and written in go too
135143
```yaml
136144
volumes:
137145
- /anywhere/nginx.json:/ssl/nginx.json
138146
```
139147
At the moment you can't choose the path for the `*.json` in the container, they have to be placed in the `/ssl` folder. In the future you'll be able to do that just setting one env var
140148
If none `*.json` is provided to container, a default cert will be served.
149+
150+
151+
## Credits
152+
153+
Thanks to these users for contributing or helping this project in any way
154+
* [oxodao](https://github.com/oxodao)
155+
* [Deuchnord](https://github.com/deuchnord)
156+
* [Sata51](https://github.com/sata51)
157+
* [Pierre Diancourt](https://github.com/pierrediancourt)

docs/plantUML/generate.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
3+
for FILE in *.puml; do
4+
cat $FILE | docker run --rm -i think/plantuml > "${FILE%.puml}.svg"
5+
done
6+
echo Done

docs/plantUML/sequenceDiagram.puml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
@startuml
2+
actor User
3+
actor System
4+
activate System
5+
participant Souin
6+
collections Providers
7+
participant Memory
8+
participant Redis
9+
participant ReverseProxy
10+
System -> ReverseProxy ++ : run()
11+
System -> Souin ++ : main()
12+
Souin -> Providers : Init()
13+
activate Providers
14+
Providers -> Memory ++ : MemoryConnectionFactory()
15+
Providers <-- Memory : *AbstractProvider
16+
Providers -> Redis ++ : RedisConnectionFactory()
17+
Providers <-- Redis : *AbstractProvider
18+
Souin <-- Providers : AbstractProvider[]
19+
... Waiting for user request ...
20+
loop User requests
21+
User -> Souin : request
22+
activate User
23+
par Request providers content
24+
Souin -> Memory: GetRequestInCache()
25+
else
26+
Souin -> Redis: GetRequestInCache()
27+
else
28+
Souin -> ReverseProxy: GetRequestInReverseProxy()
29+
end
30+
par Response providers content
31+
Souin <-- Memory: *Response
32+
else
33+
Souin <-- Redis: *Response
34+
else
35+
Souin <-- ReverseProxy: *Response
36+
Souin -> Memory: SetRequestInCache()
37+
Souin -> Redis: SetRequestInCache()
38+
end
39+
Souin -> User : response
40+
deactivate User
41+
end
42+
@enduml

docs/plantUML/sequenceDiagram.svg

+54
Loading

0 commit comments

Comments
 (0)