Here's an example of a folder structure for a TypeScript-based web application using hexagonal architecture and AWS Lambda:
- app
- infrastructure
- aws
- database
- connection.ts
- repository.ts
- core
- domain
- use-cases
- create-user.ts
- delete-user.ts
- update-user.ts
- presentation
- components
- user-list.ts
- user-form.ts
- pages
- store
- tsconfig.json
- package.json
- package-lock.json
Here's a brief explanation of each folder:
app: This is the main folder for your application.
infrastructure: This folder contains all the infrastructure-specific code, such as database connections, AWS Lambda handlers, and resource definitions.
-
aws: This folder contains all the AWS-specific code, including Lambda functions and resource definitions.
-
lambda: This folder contains the code for your Lambda functions. The index.ts file is the entry point for your Lambda function, and it should import and export the handler function that will be called by AWS. The handler.ts file contains the actual implementation of the Lambda function.
-
resources.ts: This file defines the AWS resources that your application needs, such as tables in a database or queues for message passing.
-
database: This folder contains the code for connecting to and interacting with your database. The connection.ts file contains the code for establishing a connection to the database, and the repository.ts file contains the code for interacting with the database, such as saving and retrieving data.
core: This folder contains the core logic of your application, which is domain-specific and not tied to any specific infrastructure.
-
domain: This folder contains the domain-specific models and services. The model.ts file defines the domain models, and the service.ts file defines the domain services that operate on those models.
-
use-cases: This folder contains the code for your use cases, which are the high-level business logic that your application implements. For example, a use case for creating a user might include creating a new user record in the database and sending a welcome email.
presentation: This folder contains the code for the user interface of your application.
-
components: This folder contains the reusable UI components that are used throughout your application.
-
pages: This folder contains the code for the individual pages in your application, such as the home page or the users page.
-
store: This folder contains the code for managing the state of your application, such as the user data or the current page.
tsconfig.json: This file contains the configuration for the TypeScript compiler.
package.json: This file contains the metadata for your application, such as the name, version, and dependencies.
package-lock.json: This file contains the exact versions of the dependencies for your application.
Note that this is just an example structure, and you may need to modify it based on the specific requirements of your application.