Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mollybeach/backend-management-system

A scalable and efficient backend management system built with **Scala** and **Akka HTTP**. This project aims to provide a robust infrastructure for managing backend services, including user authentication, data processing, and API management. It is designed to be extendable, secure, and optimized for performance.
https://github.com/mollybeach/backend-management-system

akka-http docker flyway postgresql sbt scala slick

Last synced: 12 days ago
JSON representation

A scalable and efficient backend management system built with **Scala** and **Akka HTTP**. This project aims to provide a robust infrastructure for managing backend services, including user authentication, data processing, and API management. It is designed to be extendable, secure, and optimized for performance.

Awesome Lists containing this project

README

        

# Backend Management System

A scalable and efficient backend management system built with **Scala** and **Akka HTTP**. This project aims to provide a robust infrastructure for managing backend services, including user authentication, data processing, and API management. It is designed to be extendable, secure, and optimized for performance.

## Features

- **User Authentication & Authorization**: Secure user management with roles and permissions.
- **RESTful API**: Structured API for seamless frontend and third-party integration.
- **Data Processing**: Real-time and batch data processing with **Akka Streams**.
- **Database Integration**: Scalable data storage using **PostgreSQL**.
- **Error Handling & Logging**: Comprehensive logging and error tracking with **Logback** and **Akka's supervision strategy**.
- **Configuration Management**: Flexible configurations with **Typesafe Config**.

## Technology Stack Details

### Scala 2.13
- A modern, multi-paradigm programming language that runs on the JVM
- Key features:
- Strong static typing with powerful type inference
- Both object-oriented and functional programming capabilities
- Pattern matching and case classes for elegant data handling
- Immutable data structures by default
- Actor-based concurrency model
- Compatible with existing Java libraries

### Akka HTTP
- Built on top of Akka Streams and provides a high-level HTTP server and client API
- Features:
- Non-blocking, asynchronous HTTP processing
- Streaming-first architecture for handling large data
- DSL for routing and handling HTTP requests
- Built-in support for WebSocket and Server-Sent Events
- JSON marshalling/unmarshalling with Spray JSON
- Request/response compression
- CORS support

### Slick (Scala Language-Integrated Connection Kit)
- Modern database query and access library for Scala
- Capabilities:
- Type-safe SQL queries written in Scala
- Functional programming approach to database access
- Support for multiple database backends (PostgreSQL, MySQL, H2, etc.)
- Connection pooling with HikariCP
- Asynchronous execution of database operations
- Composable queries using monadic operations

### Akka Streams
- Implementation of Reactive Streams for building streaming applications
- Features:
- Back-pressure handling out of the box
- Rich DSL for stream processing
- Integration with various protocols and technologies
- Built-in stream operators (map, filter, groupBy, etc.)
- Error handling and recovery strategies
- Monitoring and testing capabilities

### PostgreSQL
- Advanced open-source relational database
- Strengths:
- ACID compliance for data integrity
- Advanced indexing capabilities (B-tree, Hash, GiST, SP-GiST)
- Support for JSON and JSONB data types
- Full-text search functionality
- Concurrent access handling
- Extensible with custom functions and data types

### Docker
- Platform for developing, shipping, and running applications in containers
- Benefits:
- Consistent environments across development and production
- Isolated application dependencies
- Easy scaling and deployment
- Resource efficiency
- Version control for infrastructure
- Integration with orchestration tools like Kubernetes

### Flyway
- Database migration and version control tool
- Features:
- Version control for database schemas
- Support for SQL and Java-based migrations
- Clean and repeatable migrations
- Command-line and API interfaces
- Integration with build tools (SBT, Maven)
- Validation of migration checksums

## Integration Example

Here's how these technologies work together:

```scala
// Example of Akka HTTP with Slick and PostgreSQL
def userRoute = {
path("users") {
get {
// Slick query
val usersQuery = TableQuery[Users].filter(_.active === true)

// Akka Streams integration
complete {
db.stream(usersQuery.result)
.via(Flow[User].map(_.toJson))
.via(StreamCompression.gzip)
.runWith(StreamConverters.asOutputStream())
}
}
}
}

// Example of Flyway migration
// V1__Create_Users_Table.sql
CREATE TABLE users (
id SERIAL PRIMARY KEY,
email VARCHAR(255) NOT NULL UNIQUE,
password_hash VARCHAR(255) NOT NULL,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);
```

## Performance Characteristics

- **Concurrent Users**: Can handle thousands of concurrent connections
- **Response Time**: Sub-millisecond response times for simple queries
- **Throughput**: Capable of processing thousands of requests per second
- **Scalability**: Horizontal scaling through Docker containerization
- **Data Volume**: PostgreSQL can handle databases up to several terabytes

## Getting Started

### Prerequisites

- **Scala** 2.13+
- **SBT** (Scala Build Tool)
- **PostgreSQL** (Ensure a PostgreSQL instance is running and accessible)
- **Docker** (optional, for containerization)

### Setup

1. **Clone the repository**:
```bash
git clone https://github.com/mollybeach/backend-management-system.git
cd backend-management-system
```

2. **Configure environment variables**:
- Copy the example environment file to create your local configuration:
```bash
cp .env.example .env
```
- Update `.env` with your credentials:
```properties
# Database Configuration
DB_HOST=localhost
DB_PORT=5432
DB_NAME=backend_management
DB_USER=your_username
DB_PASSWORD=your_password

# Server Configuration
SERVER_HOST=0.0.0.0
SERVER_PORT=8080

# JWT Configuration
JWT_SECRET=your_jwt_secret_key
JWT_EXPIRATION=24h
```

3. **Run database migrations**:
```bash
sbt flywayMigrate
```