This repository contains the backend for the CMP Notes Client, a multiplatform app built with Compose. It's a modern and secure RESTful API for managing notes, developed with Ktor, Kotlin, and Exposed for type-safe database access.
A modern, robust, and secure RESTful API for managing notes, built with Kotlin and the Ktor framework. This project serves as a powerful backend foundation, demonstrating best practices in API development, authentication, and database interaction.
Visit the client side repo: CMP Notes Client
- User Authentication: Secure user registration and login using Basic Authentication and BCrypt.
- CRUD Operations for Notes: Full Create, Read, Update, and Delete functionality for user-specific notes.
- Dependency Injection: Clean, decoupled architecture powered by Koin.
- Modern Database Access: Type-safe ORM using JetBrains Exposed.
- Asynchronous by Design: Built on Kotlin Coroutines for high-performance, non-blocking I/O.
- Framework: Ktor
- Language: Kotlin
- Authentication: Ktor Basic Auth with BCrypt hashing
- Database: PostgreSQL
- Database Access: JetBrains Exposed
- Dependency Injection: Koin
- Serialization: kotlinx.serialization
Follow these instructions to get a copy of the project up and running on your local machine for development and testing.
- JDK 17 or higher.
- PostgreSQL database server installed and running. or
- Docker Desktop dto run the docker script for the postgresql setup.
- An IDE like IntelliJ IDEA is recommended.
-
Clone the repository:
git clone [https://github.com/laetuz/ktor-notes-api.git](https://github.com/laetuz/ktor-notes-api.git) cd project
-
Set up the PostgreSQL Database:
- Open docker-compose.yml and run services. This will automatically setup the container for postgres.
- Connect to your PostgreSQL instance.
- Create a new database for the project (e.g.,
notes_db
). - The necessary tables will be created automatically by Exposed when the application starts for the first time.
-
Configure Environment Variables: This project uses environment variables to manage sensitive data like database credentials. You can set these in your IDE's run configuration or export them in your terminal.
| Variable | Description | Example Value | | ------------------- | -------------------------------------------------- | ---------------------------------------------- | |
DATABASE_URL
| The JDBC URL for your PostgreSQL database. |jdbc:postgresql://localhost:5432/notes_db
| |DATABASE_USER
| The username for your database. |postgres
| |DATABASE_PASSWORD
| The password for your database user. |your_secure_password
| -
Run the Application: Use the Gradle wrapper to build and run the server.
./gradlew run
The server will start, typically on
http://localhost:8081
.
- I have provided the API documentation in a notebook format here
- or you could go to /notes/src/main/resources/ApiDocs.ipynb in this project scope.
A brief overview of the key directories in the project. ~later lah ya i will update.
Visit our website: Neotica