Skip to content

Performant, Scalable, and Resilient Backend for Plamatio E-Commerce.

License

Notifications You must be signed in to change notification settings

pranav-kural/plamatio-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Plamatio Backend

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

Plamatio Backend Deployment - Staging Plamatio Backend Deployment - Production

To learn more about Plamatio frontend, backend, and data streaming pipeline, check the blog post on Introduction to Plamatio.

Primary Features

  • 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 Overall Architecture

Project Structure

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:

  1. 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.
  2. 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.
  3. 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.
  4. 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.

API Specifications

Please refer to Plamatio Backend REST API Specifications for more information on the REST API endpoints and their specifications.

REST API Architecture

Below image presents a high-level overview of the distributed and scalable REST API architecture of the Plamatio Backend.

Plamatio Backend REST API Architecture

Real-time Data Streaming

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.

Plamatio Backend Real-time Data Streaming

Local Development

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.

Developing locally

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]

Running locally

Before running your application, make sure you have Docker installed and running. It's required to locally run Encore applications with databases.

encore run

Open the developer dashboard

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.

Deployment

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.

Testing

encore test ./...

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Issues

If you encounter any issues or bugs while using Plamatio Backend, please report them by following these steps:

  1. Check if the issue has already been reported by searching our issue tracker.
  2. If the issue hasn't been reported, create a new issue and provide a detailed description of the problem.
  3. Include steps to reproduce the issue and any relevant error messages or screenshots.

Open Issue

About

Performant, Scalable, and Resilient Backend for Plamatio E-Commerce.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages