Home

Awesome

🚨 DEPRECATION WARNING 🚨

I'm currently not actively using Couchbase nor this generator for any project.

You might still find some internal pieces of code useful for your own use cases, but I won't be able to fix bugs and add features.

If you are starting a new project from scratch, check the alternatives at the FastAPI docs: Project Generation.

You are still free to use this project if you want to, you might still find some internal pieces of code useful for your own use case. And if you already have a project generated with it that's fine as well (and you probably already updated it to suit your needs).

Full Stack FastAPI Couchbase - project generator

Build Status

To have in mind

Here are some extra thoughts you might want to consider if you decide to go with Couchbase and/or this project generator.

Pros

Couchbase has a great set of features that is not easily or commonly found in alternatives.

It's a distributed database, so, if you have a cluster of several nodes with the data replicated, you don't have a single point of failure.

It provides very high performance.

It has built-in full-text search integrated (using Bleve). It's possible to make all the records be automatically indexed in the search engine without additional code or extra components.

It can be connected/integrated with the Couchbase Sync Gateway, that can be used to synchronize a subset of documents (records) with mobile devices. And with some effort, it can be connected with PouchBD for frontend synchronization (although not querying and/or searching from the frontend, as would be possible with CouchDB).

Cons

The documentation is very scarce. This is sadly a big problem. Many features are not well documented, or not documented at all.

Many configurations are not documented and have to be inferred from comments in forums, reading source code, or checking the configurations for the C client and trying different query parameters in URLs, that becomes quite error prone.

Couchbase didn't seem to be designed to be integrated into CI systems as in this project (or alternatives), at least until the last time I used it. It expects all the set up to be done once via the web UI, not automated. The official Docker image can't be configured. So, this project does all the configuration by sending the HTTP requests from the backend code to the container replicating the HTTP requests done in the web UI. But those steps are not documented, there's no "official" way to configure and start it without using the web UI, so the integration with CI could be error prone.

The Couchbase Sync Gateway official Docker image is not designed to be configured much either, so, the Dockerfile included in this project adds a good amount of custom logic to support that, but that's not really official.

As it uses N1QL, a flavor of SQL, and there's no easy integration with Python, you have to do all the operations in N1QL strings and integrate them with your own code. Without editor support, completion, nor syntax checks for N1QL.


Generate a backend and frontend stack using Python, including interactive API documentation.

Screenshot

Features

How to use it

Go to the directory where you want to create your project and run:

pip install cookiecutter
cookiecutter https://github.com/tiangolo/full-stack-fastapi-couchbase

Generate passwords

You will be asked to provide passwords and secret keys for several components. Open another terminal and run:

openssl rand -hex 32
# Outputs something like: 99d3b1f01aa639e4a76f4fc281fc834747a543720ba4c8a8648ba755aef9be7f

Copy the contents and use that as password / secret key. And run that again to generate another secure key.

Input variables

The generator (cookiecutter) will ask you for some data, you might want to have at hand before generating the project.

The input variables, with their default values (some auto generated) are:

How to deploy

This stack can be adjusted and used with several deployment options that are compatible with Docker Compose, but it is designed to be used in a cluster controlled with pure Docker in Swarm Mode with a Traefik main load balancer proxy handling automatic HTTPS certificates, using the ideas from <a href="https://dockerswarm.rocks" target="_blank">DockerSwarm.rocks</a>.

Please refer to <a href="https://dockerswarm.rocks" target="_blank">DockerSwarm.rocks</a> to see how to deploy such a cluster in 20 minutes.

More details

After using this generator, your new project (the directory created) will contain an extensive README.md with instructions for development, deployment, etc. You can pre-read the project README.md template here too.

Sibling project generators

Release Notes

Latest Changes

0.4.0

0.3.0

0.2.1

0.2.0

<a href="https://github.com/tiangolo/full-stack-fastapi-couchbase/pull/7" target="_blank">PR #7</a>:

License

This project is licensed under the terms of the MIT license.