Skip to content

This is a template for creating a FastAPI application with Onion Architecture and deploy it to AWS Lambda.

License

Notifications You must be signed in to change notification settings

tamtam-fitness/aws-lambda-fastapi-onion-architecture-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 

Repository files navigation

aws-lambda-fastapi-onion-architecture-template

This is a template for creating a FastAPI application with Onion Architecture and deploy it to AWS Lambda.

Here are the URLs of the articles I wrote based on this repository.

project structure

this is a project structure image in app directory. ※ different from the actual project structure

├── api # presentation layer
│   ├── __init__.py
│   └── v1
│       ├── __init__.py
│       ├── endpoints
│       │   ├── __init__.py
│       │   └── <specific name>
│       └── router.py
├── compose.yml
├── container_config # DI container
│   ├── __init__.py
│   ├── di_container.py
│   └── module
│       ├── __init__.py
│       └── repository_module.py
├── core 
│   ├── __init__.py
│   ├── config.py
│   ├── logger
│   │   ├── __init__.py
│   │   ├── api_logger.py
│   │   └── logging_context_route.py
│   └── singleton.py
├── domain # domain layer
│   └── <specific name>
│       ├── service # business logic which is not written in entity and value object
│       ├── entity # mutable object
│       ├── i_repository # interface for repository(DIP)
│       └── value_object # immutable object
├── exceptions # custom exceptions
│   ├── core.py
│   ├── error_handle_middleware.py
│   └── error_messages.py
├── infrastructure # infrastructure layer
│    ├── repository_impl # implement repository interface
│    ├── model # ORM
├── main.py
├── schemas # DTO for using endpoint
├── scripts
│   └── compose_pytest
├── tests
├── usecase # application layer

If you want to separate command and query in domain layer, you can add CQRS pattern in usecase layer.

this is a ariticle about CQRS pattern.

How to use

1. clone this repository

git clone

2. cd app directory

cd app

3. run container

run container following app/README .

References

About

This is a template for creating a FastAPI application with Onion Architecture and deploy it to AWS Lambda.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published