53 lines
1020 B
Markdown
Raw Normal View History

2025-01-24 09:39:17 +01:00
# API template with Clean Architecture
This is a template for building APIs with Clean Architecture. It contains two examples of APIs built with FastAPI and Flask.
- `src` contains the source code.
2025-01-24 09:42:52 +01:00
- `src/core`: business logic (use cases, entities, decorators...).
- `src/infra`: implementations of the interfaces defined in the core.
- `src/infra/api/fastapi`: FastAPI implementation.
- `src/infra/api/flask`: Flask implementation.
- `src/infra/storage/`: Fake storage implementation.
2025-01-24 09:39:17 +01:00
2025-01-24 09:42:52 +01:00
## Requirements
- Docker
2025-01-24 09:39:17 +01:00
## Prepare
```bash
2025-02-07 08:28:39 +01:00
cp envExample .env
2025-01-24 09:39:17 +01:00
make build network
```
## Run FastAPI
```bash
make api.fastapi.run
```
2025-02-07 08:28:39 +01:00
## Run Flask
2025-01-24 09:39:17 +01:00
```bash
2025-02-07 08:28:39 +01:00
make api.flask.run
2025-01-24 09:39:17 +01:00
```
2025-02-07 08:28:39 +01:00
## API
2025-01-24 09:39:17 +01:00
2025-02-07 08:28:39 +01:00
### Welcome
2025-01-24 09:39:17 +01:00
```bash
2025-02-07 08:28:39 +01:00
curl -X 'GET' 'http://localhost:5000' -H 'accept: application/json'
```
### Documents
```bash
curl -X 'GET' 'http://localhost:5000/api/v1/documents/?appName=app_test&clientId=client_test' -H 'accept: application/json'
2025-01-24 09:39:17 +01:00
```
2025-02-07 08:28:39 +01:00
## SEE
2025-01-24 09:39:17 +01:00
```bash
2025-02-07 08:28:39 +01:00
curl -N -H "Accept:text/event-stream" http://localhost:5000/sse/alerts/
2025-01-24 09:39:17 +01:00
```