Project Documentation: Implementing Serverless Application Using Wicket
Introduction
The purpose of this documentation is to provide comprehensive knowledge and technical support for individuals working on a project implementing a serverless application using the Wicket technology stack. This document contains detailed information about the tools used, installation processes, project environment configuration, and database migration procedures.
1. Project Architecture
The project is based on the following architecture:
-
Serverless Technology: The project is built on serverless technology, utilizing Python version 3.10 and the Serverless Framework.
-
Amazon Web Services (AWS): The project leverages various AWS services, including ApiGateway, Cognito (SSO), and AWS Lambda functions.
2. Useful Resources
To better understand serverless technology and the project components, it is advisable to explore the following resources:
-
Official AWS Documentation: The AWS documentation provides detailed information about the services used in the project.
-
Serverless Framework Documentation: The Serverless Framework documentation will help you understand how to create and manage serverless applications.
3. Installation Process
3.1. AWS CLI Installation
To install the AWS Command Line Interface (CLI), follow these steps:
-
Go to the AWS CLI download page and download the appropriate version for your operating system.
-
Run the installer and follow the on-screen instructions.
3.2. 1Password CLI Installation
To install the 1Password Command Line Interface (CLI), follow these steps:
-
Go to the 1Password CLI download page and download the appropriate version for your operating system.
-
Run the installer and follow the on-screen instructions.
3.3. AWS Profile Configuration
To configure an AWS profile to be used in the project, follow these steps:
-
Install the AWS CLI.
-
Create a user with security credentials in IAM. Avoid providing more permissions than is necessary.
Configure the CLI using IAM credentials.
$ aws configure
Example:
AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: eu-central-1
Default output format [None]: json
4. Installation of Python Packages
The project uses the Poetry package manager for managing Python packages. To install the necessary packages, follow these steps:
4.1. Poetry Installation
To install Poetry, execute the following command:
pip install poetry
4.2. Package Installation
To install all required packages for the project, navigate to the project directory and execute the following command:
poetry install
5. Database Setup and Migration
To work on the project, it is mandatory to have a locally hosted database that is migrated to the latest version. Here are the steps to set up and migrate the database:
5.1. Database Configuration (.env/.env.dev)
In the .env/.env.dev file, include the following configuration for the local database:
POSTGRES_USER=postgres_user
POSTGRES_PASSWORD=postgres_password
POSTGRES_PORT=5432
POSTGRES_HOST=localhost
LOCAL_DB_URL="postgresql+psycopg2://postgres_user:postgres_password@localhost:6533/fan_users"
DB_URL=${LOCAL_DB_URL}
5.2. Creating a Migration File
To create a migration file, use the following command, replacing "Your comment here" with an appropriate comment:
alembic -n fan_users revision --autogenerate -m "Your comment here"
A new file should appear in the migrations directory. Review it for any necessary corrections, especially imports.
5.3. Testing Database Migrations
To upgrade the local database to the latest version, run the following command:
alembic --name fan_users upgrade head