- Kotlin - our language of choice
- Gradle - our build system of choice (using groovy)
- Ktor - for creating web application
- ExposedSQL - to access database
- HikariCP - for high-performance JDBC connection pool
- Koin - for dependency injection
- PostgreSQL - for database
- HOCON - for application configuration
- Gson - for JSON serialization/deserialization
You can get the .env file from pm Muslim or directly from draft repository. (Don't ask me why I did this and not this. I don't know myself)
- backend: 7000
- database: 7100
Just type one simple command for up whole server (Currently unstable, if do nothing or exit with error see full instruction section)
muslim do-magic
gradlew clean build
gzip -d -k assets/*.gz OR manually unzip
docker compose create --build
docker compose start tms-database
cat assets/*sql | docker exec -i tms-database psql -U seasky-developer -d tms
docker compose start tms-backend
Explanation of each row
- Build fat.jar
- Unzip database dump
- Create services from zero
- Run database
- Copy all data from sql file and put it on psql as dev to insert dump to tms database
- Run backend
create extension "uuid-ossp" //Extension for generate uuid's
create extension "pgcrypto" //Extension for encode values especially passwords
gradlew clean build -x test //Exclude test task when build
docker exec -i $container pg_dump -U $user -d $database -p $port > dump.sql //Create db dump from container. Passed options (-U user; -d database; -p listen port)
docker exec -i $container pg_dump -U $user -d $database -p $port | gzip -9 > dump.sql.gz //With compress. Passed option (-9 or --best best compress value)
docker exec -i $container pg_dump -U $user -d $database -p $port > dump_�te%_%time:~0,8%.sql //With current datetime.
docker exec -i tms-database pg_dump -U seasky-developer -d tms | gzip -9 > assets/dump_�te%.sql.gz
cat *.sql | docker exec -i $container psql -U $user -d $database //Restore db dump into container
-
Name of the tables in the singular.
-
For multiple words use
snake_case
for both table and column names. -
Override default constraint names, ex. in table below.
Name Value Example Primary Key pk_$tableName_$columnName constraint pk_user
primary key(id)Foreign Key fk_$tableName_$columnName_$referenceColumnName constraint fk_user_role_id_id
foreign key(role_id)
references role(id)Unique uq_$tableName_$columnName constraint uq_user_username
unique(username)Check ch_$tableName_$columnName constraint ch_user_username
check(length(username) >= 4)For multiple definitions separate column name with '_' sign, ex.
pk_$tableName_$columnName0_$columnName1_#columnNameN
-
For UUID tables use extension
uuid-ossp
, for default value use a fourth version of uuid generator.Ex.
create extension if not exists "uuid-ossp"; create table user( id uuid default uuid_generate_v4(), ... )
-
For a password storing use
pgcrypto
extension.Ex.
create extension if not exists "pgcrypto"; create table "user"( ... "password" text not null, ... ) insert into "user"(username, password) values('username', crypt('pass', gen_salt('bf'))) select username, (password = crypt('pass', password)) as password_match from "user"