Ecomora Server is a modern backend solution for ecommerce platforms, built with Kotlin and Ktor. It provides robust RESTful APIs to support scalable online store applications, with a secure, modular, and production-ready codebase.
- Introduction
- Technologies Used
- Features
- Installation
- Setup
- Usage
- API Endpoints
- Contributing
- License
- About
Ecomora Server is designed to streamline backend ecommerce development. It leverages industry best-practices for security, validation, and database management using Ktor, Exposed ORM, HikariCP, and JWT authentication—all written in idiomatic Kotlin.
- Kotlin (JVM) — Main programming language
- Ktor — Modern Kotlin framework for server APIs
- Gradle (Kotlin DSL) — Build and dependency management
- Exposed ORM — ORM for SQL databases in Kotlin
- HikariCP — JDBC connection pool
- PostgreSQL (for production)
- H2 Database (for development)
- SLF4J — Logging API
- auth0/java-jwt (JWT) — Secure JWT-based authentication
- Kotlinx Serialization — JSON serialization/deserialization
- User authentication and robust JWT authorization
- CRUD endpoints for users, categories, products, orders, carts, promotions, services, and more
- Strong validation and error handling
- Secure, production-ready JWT security with environment configuration
- Modular structure and clean code separation (logging, validation, serialization, etc.)
- PostgreSQL for production, H2 for development (auto-configured)
- Highly configurable via environment variables
- Development-ready API collection (Postman)
- Extensible for new features and plugins
Clone the repository:
git clone https://github.com/your-username/ecomora-server.git
cd ecomora-serverEnsure you have JDK 17+ installed. Use the included Gradle wrapper:
./gradlew buildFor Windows:
gradlew.bat build-
Set Environment Variables
- Create a
.envor add to your environment; required variables:JWT_SECRET,JWT_AUDIENCE,JWT_DOMAIN,JWT_REALMIS_PRODUCTION(trueuses PostgreSQL, otherwise H2 embedded)- If using PostgreSQL:
DB_URL,DB_USERNAME,DB_PASSWORD - (Optional)
H2_PATHfor custom H2 DB path
- Create a
-
Set up PostgreSQL for production:
- Install PGAdmin4 or another Postgres client.
- Create a new database.
- Set JDBC connection variables as above in your run configuration.
-
Start the server
./gradlew run # or: gradlew.bat run
- Once running, the server listens on
localhost:8080by default. - Explore endpoints and test requests with the included Postman collection:
EcomoraServer.postman_collection.json
Update your applications’ base URL as needed.
Core endpoints (replace {id} as needed):
- Get all:
GET /v1/users - Get single:
GET /v1/users/{id} - Create:
POST /v1/users - Login:
GET /v1/login - Delete:
DELETE /v1/users/{id} - Update:
PUT /v1/users/{id}
- Get all:
GET /v1/categories - Get by ID:
GET /v1/categories/{id} - Create:
POST /v1/categories - Delete:
DELETE /v1/categories/{id} - Update:
PUT /v1/categories/{id}
- Get all:
GET /v1/products - Get by ID:
GET /v1/products/{id} - Create:
POST /v1/products - Delete:
DELETE /v1/products/{id} - Update:
PUT /v1/products/{id}
- Get all:
GET /v1/promotions - Get single:
GET /v1/promotions/{id} - Create:
POST /v1/promotions - Delete:
DELETE /v1/promotions/{id} - Update:
PUT /v1/promotions/{id}
Contributions are welcome!
- Please follow Kotlin idiomatic style.
- Open issues or pull requests for bugs/features.
--
This project is licensed under the MIT License.
Ecomora is a feature-complete ecommerce server compatible with multiple frontend clients (including Kotlin Multiplatform).