Guide: Deploying Next.js, FastAPI & Postgres in 10 Minutes
A step-by-step tutorial on deploying a full-stack polyglot application with a managed database using Viduli.


Deploying a full-stack application often requires configuring multiple services, managing containers, and setting up networking between components. This guide demonstrates how to streamline that process using Viduli.
We will walk through deploying a standard monorepo structure containing a Next.js frontend, a FastAPI backend, and a managed PostgreSQL database.
The Project Structure
For this guide, we assume a repository structure similar to this:
my-startup/
├── frontend/ # Next.js Application
│ ├── package.json
│ └── src/
├── backend/ # FastAPI Application
│ ├── requirements.txt
│ └── main.py
└── README.mdStep 1: Create a Project
Before deploying resources, create a project to group them. Projects provide a shared internal network and environment scope for your services. They also provide a built-in API gateway to manage routing.
- From the dashboard, click New Project.
- Name it
My Startup(or your preferred name). - Select a
free tierdeployment for this guide. - Select your team and org. These will be pre-selected depending on where you click the "New Project".
Outcome: You now have an empty environment where all deployed services will be able to communicate securely. The project's API gateway is ready to route traffic to your frontend and backend services as you deploy them.
Step 2: The Database (Orbit)
We recommend starting with the database deployment. When you create a database on Viduli, the connection details are automatically made available to other resources in the same project.
- Navigate to New Resource and select Orbit.
- Engine Selection: Choose PostgreSQL 18 (or the latest stable version).
- Identity: Set the Label to
ProductDB. This name will be used to generate environment variables. - Compute Resources: For a typical starter application, the default
configuration is sufficient:
- CPU:
0.25 vCPU - Memory:
512 MB - Storage:
5 GB(or adjust as needed)
- CPU:
- Scaling: Confirm the Region is set to your preferred location (e.g.,
us-east-1). - Click Launch.
Outcome: Viduli provisions a managed PostgreSQL instance with automated
backups (7-day retention) and high availability. Crucially, it automatically
injects environment variables like PRODUCTDB_DB_URL, PRODUCTDB_DB_USER, and
PRODUCTDB_DB_PASSWORD into your project scope, so your backend can connect
without manual configuration.
Step 3: The Backend (Ignite)
Next, we deploy the Python API. Viduli's Ignite service automatically detects
the project type based on the presence of requirements.txt.
- Select New Resource and choose Ignite.
- Framework: Select FastAPI.
- Source: Connect your GitHub repository and select the repo.
- Build Configuration:
- Root Directory: Set to
./backend. This tells the build system where your Python app lives. - Install Command: Leave as default (Ignite automatically runs
pip install -r requirements.txt). - Run Command: Leave as default (Ignite automatically runs
fastapi run).
- Root Directory: Set to
- Compute Resources: Select
0.125 vCPUand256 MBRAM for a lightweight API. - Networking:
- Public Access: Toggle On.
- Path Prefix: Set to
/api. This ensures requests toyour-domain.com/apiare routed to this service. - Prefix Rewrite: Set to
/. This ensures your FastAPI app receives requests at its root path (e.g.,/usersinstead of/api/users), keeping your internal routing clean. - Expose Port: Ensure this matches your app's port (default
8000).
- Click Launch.
Outcome: The platform builds the Python application, installs dependencies, and configures the runtime. Since it shares the project scope with the database, it automatically inherits the database connection credentials.
Step 4: The Frontend (Ignite)
Finally, we deploy the Next.js application.
- Select New Resource and choose Ignite.
- Framework: Select Next.js.
- Source: Select the same repository.
- Build Configuration:
- Root Directory: Set to
./frontend. - Output Directory: Leave as default (
.nextis handled automatically).
- Root Directory: Set to
- Networking:
- Public Access: Toggle On.
- Path Prefix: Leave as
/(default). This routes all root traffic to your frontend.
- Environment Variables:
- Add a new variable named
NEXT_PUBLIC_API_URL. - Set the value to the URL of your backend. You can construct this using
your project's domain and the
/apiprefix (e.g.,https://my-startup.viduli.app/api).
- Add a new variable named
- Click Launch.
Outcome: The frontend is deployed to the global edge network, serving your application with low latency.
Summary
In a few simple steps, you have deployed a production-ready architecture:
- Managed Postgres: Includes automated backups and high availability.
- Auto-Scaling Backend: The FastAPI service scales based on traffic demand.
- Global Frontend: Next.js is served from locations close to your users.
- Unified Networking: Routing for
/apiand/is handled automatically by the project gateway, eliminating the need for complex proxy configurations.
This approach allows you to focus on building features rather than managing infrastructure.
Join our newsletter
Get the latest updates and insights delivered to your inbox.