A powerful backend ready for your next app 🚀
Hatem Hosny
Posted on November 28, 2020
I am a primarily frontend developer.
Whenever I start a new project I keep going into the dilemma of:
- Which backend?
- Which database?
- Which hosting provider?
- Which complexity for the cloud service provider will I have to go through this time?
- What if I need later on to move to another provider?
- Should I go serverless?
- Do I need authentication? should I use a 3rd party service for that?
- How to handle HTTPS certificates issuing and renewal?
- How about the CI/CD setup?
- How to get a convenient local development environment that also matches production deployment?
Services like Firebase and AWS Amplify, have always been appealing. However, I felt uncomfortable with having marked restrictions on the database design (with lots of de-normalization) because of pay-per-read model. I know, I know, this is how NoSQL works, but still I was not happy. In addition, I do not want to pay $30K in 72 hours because of a coding mistake. And then not be able to do a basic full-text search!
Serverless can be very cost-effective on small scale but can be quite expensive on large scales. I want to have a predictable budget.
In addition, the ease of local development with a cloud backend was concerning. There are many good solutions or workarounds for all of these questions, but none felt as easy and flexible for the requirements of different projects.
All of that, and we have not even started talking about what I care about most, my app!
Frontend development has become complex enough to also get distracted by all of these questions.
Recently, I have come across Parse server. It is a project that was acquired by Facebook (parse.com) and was later open-sourced when they decided to stop providing the cloud service. It is such a nice project that ticks nearly all my boxes.
So, I created a monorepo starter project that is managed by Docker Compose which runs the feature-rich ready-to-use setup that works out of the box for local development and can be easily deployed.
You can find it on github:
hatemhosny / parse-starter
A powerful backend ready for your next app 🚀
Feature Summary
-
Parse server: Backend-as-a-Service (BaaS) that features:
- SDKs for popular platforms
- REST API
- Graphql API
- LiveQuery for realtime apps
- Security features including authentication, users, roles, access control lists (ACL) and class-level permissions (CLP)
- 3rd party authentication
- Push notifications
- Adapters for file storage and caching
- Analytics
- Cloud code for custom server-side logic
- Web hooks
- Runs on top of Express allowing the use of Express middleware
- Comprehensive documentation
- Large community
- MongoDB database.
- Parse dashboard (optional): a powerful dashboard for managing the parse server.
- API-First Headless CMS (optional): using chisel-cms.
- A sample realtime frontend app.
- Automatic HTTPS for the frontend and backend using Caddy server.
- Reproducible setup using Docker containers managed by a single Docker Compose file.
- Local development workflow with hot reload for frontend and backend.
- Easy deployment.
- CI/CD (continuous integration and deployment): using github actions.
- Optional deployment to multiple environments (e.g. development, staging and production).
- Highly configurable.
- The whole stack is open source with no vendor lock-in or pay-per-request restrictions.
Getting Started
Run the shell command:
docker-compose up
By default, the following will be served:
- parse server backend: https://localhost:1337/api
- parse graphql API: https://localhost:1337/graphql
- parse dashboard: https://localhost:1337/dashboard
- frontend local dev server (with HMR): https://localhost:1234
After production build:
- frontend app: https://localhost
When CMS is enabled:
- chisel CMS: https://localhost:1337
Now you can edit/replace the app in the frontend
directory and start building your own app making use of the feature-rich backend.
Deployment
Docker and Docker Compose significantly simplify deployment. All the setup and dependencies are already taken care of in the docker images.
So, in principle, the steps required for deployment are:
- Defining the variables for the deployment environment.
- Building the docker images and verifying them.
- Running the containers on the host server.
Although this can be done manually, it is greatly simplified using the included automated CI/CD setup that uses github actions.
Quick Start
Assuming you can connect using SSH to your server which has Docker and Docker Compose installed (see Server Setup), and that you have a github personal access token (see Container Registry), add the following Github Secrets:
- PROD_DOCKER_REGISTRY_TOKEN: your personal github access token
- PROD_SSH_HOST: your server IP address
- PROD_SSH_KEY: your server SSH private key
- PROD_ENV_VARS: edit the following example with your values
HOST_NAME=mywebsite.com
APP_ID=myappid
MASTER_KEY=mymasterkey
PARSE_DASHBOARD_USER_ID=user
PARSE_DASHBOARD_USER_PASSWORD=pass
Note: The environment variable HOST_NAME
is required for remote deployment.
Now pushing code to main/master branch should trigger build and deploy to your server. Note that you can follow the progress and read logs of CI/CD workflows on the "Actions" tab in the gihub repo.
That's it!
You have launched your powerful backend locally and deployed it within a few minutes.
You can find the documentation and configuration details in the github repo: https://github.com/hatemhosny/parse-starter
This is clearly not the magic bullet that solves all the problems of the world, but it has made my life easier, and I hope it makes yours too.
Please let me know your suggestions/advices/comments, and I would be very grateful for contributions.
Happy coding, go build some great apps!
Posted on November 28, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.