Plamatio is a production-ready E-commerce store focused on Llama-inspired products. This e-commerce store was built as part of my portfolio projects for demonstration of some cutting-edge technologies in building a highly performant, scalable, and resilient backend that composes of a robust Go-lang written REST API with PostgreSQL databases, Kafka-based real-time data streaming, Redis cache system, backend system monitoring and observability through Grafana, and more.
Plamatio Backend Documentation
To learn more about Plamatio frontend, backend, and data streaming pipeline, check the blog post on Introduction to Plamatio.
- Distributed REST API: Plamatio backend consists of multiple distributed modularized REST API services, each with its Redis cache and PostgreSQL database. This distributed architecture allows for maximal scalability, reduced development and maintenance complexity, and increased productivity in fixing issues and releasing feature updates.
- PostgreSQL Database + Redis Cache: Low-latency request processing pipeline architected with a robust PostgreSQL database (with special indexes) and a distributed, responsive and scalable Redis-based cache for frequently accessed API endpoints.
- API-key Authenticated Endpoints: Simple API-key based authentication for most of the endpoints, reducing overhead and request processing time for both frontends and the backend, without compromise on security.
- Kafka-powered Real-time Data Streaming: Using Confluent-based Kafka services for architecting a real-time data streaming pipeline to not only provide a scalable solution for real-time updates on data mutations but also to enhance capturing of interactions and events on any number of frontends.
- Grafana: Using Grafana Cloud for enchanced monitoring and observability going beyond basic logging, metrics collection and analysis, and API request tracing.
- Encore Cloud: Using Encore Cloud for hosting backend application, secrets management, PostgreSQL database hosting, Redis hosting, and resource provisioning.
Below image provides a high-level overview of the overall architecture of the Plamatio project.
Plamatio backend is built using the Encore.go Backend Framework.
Project is structured in a way that reduces complexity and increases productivity. Since, Encore enables you to build distributed API services, dependency between each service is minimal.
There are five key services that Plamatio Backend exposes: Products, Categories, Cart, Orders, Users.
For each of these services, there are four key folders:
api
: contains the core REST API endpoints defintions and code.db
: contains and abstracts methods required to interact with the required table(s) in the PostgreSQL database.models
: defines the data models used by the service.utils
: provides any utility functions used across the code of the service.
Basic workflow when adding a new API service would look like:
- Define Data Models: Define data models required by the service. For example, Products service may require a
Product
type definition to store and work with products. - Define Utility Functions: Define data validation functions for validating data for creating instances for your defined data models. For example, for Products service, you may define a method to validate data received in a request to create a new product.
- Define Database Methods: Define methods to interact with the appropriate table in the PostgreSQL database for the service. You might start by defining the SQL statements, followed by defining the methods that handle the execution of these statements.
- Define Service API: Define the API endpoint methods for the service. This may involve use of the database methods you defined earlier. Moreover, at this stage, you may also configure cache for storing data for frequently accessed API endpoints, and auth handler for authenticated API endpoints.
Please refer to Plamatio Backend REST API Specifications for more information on the REST API endpoints and their specifications.
Below image presents a high-level overview of the distributed and scalable REST API architecture of the Plamatio Backend.
To keep a scalable amounts of frontend interfaces in sync with data mutations, Plamatio uses a Confluent-based Kafka Service architecture to listen to and stream real-time data updates.
Feel free to use this project as basis for developing your own high-quality scalable backend systems.
Below are some sections to assist in you in this.
To develop this project locally, you will need to install the Encore CLI.
Once you have Encore CLI installed, you can use the below command to clone this project.
encore app clone plamantio-backend-hoki [directory]
Before running your application, make sure you have Docker installed and running. It's required to locally run Encore applications with databases.
encore run
While encore run
is running, open http://localhost:9400/ to access Encore's local developer dashboard.
Here you can see API docs, make requests in the API explorer, and view traces of the responses.
Deploy your application to a staging environment in Encore cloud:
git add -A .
git commit -m 'Commit message'
git push encore
Then head over to the Cloud Dashboard to monitor your deployment and find your production URL.
From there you can also connect your own AWS or GCP account to use for deployment.
encore test ./...
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
If you encounter any issues or bugs while using Plamatio Backend, please report them by following these steps:
- Check if the issue has already been reported by searching our issue tracker.
- If the issue hasn't been reported, create a new issue and provide a detailed description of the problem.
- Include steps to reproduce the issue and any relevant error messages or screenshots.