An open API service indexing awesome lists of open source software.

https://github.com/layinded/swx-api

SwX is a modular, full-featured FastAPI starter template designed for building scalable, secure, and production-ready backend or full-stack applications with ease.
https://github.com/layinded/swx-api

alembic api backend boilderplate devtools fastapi fastapi-crud jwt modular-architecture oauth2 postgres postgresql production-ready python sqlalchemy sqlmodel template

Last synced: 3 months ago
JSON representation

SwX is a modular, full-featured FastAPI starter template designed for building scalable, secure, and production-ready backend or full-stack applications with ease.

Awesome Lists containing this project

README

        

# ๐Ÿš€ SwX-API

![Python](https://img.shields.io/badge/Python-3.10%2B-blue)
![FastAPI](https://img.shields.io/badge/FastAPI-๐Ÿš€-brightgreen)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE)
![Docker Ready](https://img.shields.io/badge/Docker-Ready-blue)
![CI/CD](https://img.shields.io/badge/CI%2FCD-GitHub_Actions-success)
![Made with โค๏ธ](https://img.shields.io/badge/Made_with-%E2%9D%A4-red)

**SwX-API** is a Laravel-style, API-first **FastAPI** framework designed for speed, scalability, and maintainability. With a modular architecture, robust authentication (OAuth2, JWT, and social login), and production-grade tooling, it offers everything you need to kickstart your backend project.

> Built with โค๏ธ for developers who value flexibility and structure.

---

## โœจ Features

- โšก **FastAPI** backend with modular folder structure (`core/`, `app/`)
- ๐Ÿ—ƒ๏ธ **SQLModel** ORM with **PostgreSQL** support
- ๐Ÿ”„ **Alembic** migrations with auto-generation
- ๐Ÿ” **OAuth2 + JWT** authentication with refresh tokens
- ๐Ÿ‘ฅ **Social login** support (Google, Facebook)
- ๐Ÿ›ก๏ธ **Role-Based Access Control (RBAC)** & superuser support
- ๐ŸŒ **i18n** with language preference detection
- ๐Ÿง  **Dynamic model loading** & multilingual data seeding
- ๐Ÿ› ๏ธ **CLI Tool**: `swx` for scaffolding and automation
_(e.g., `swx make:resource`, `swx migrate`)_
- ๐Ÿ“š **MkDocs** auto-generated API docs from Python docstrings
- ๐Ÿงช Pre-configured **logging**, **linting**, **formatting**, and **testing**
- ๐Ÿณ **Docker-ready** with `docker-compose.yml`
- โš™๏ธ Optional integration with **Traefik**, **Sentry**, and **GitHub Actions**
- ๐Ÿš€ **CI/CD**-friendly with production-grade deployment tools

---

## ๐Ÿ“ Project Structure

```bash
swx_api/
โ”œโ”€โ”€ app/ # User-defined application logic (routes, services)
โ”œโ”€โ”€ core/ # Core framework logic (auth, db, utils, etc.)
โ”œโ”€โ”€ docs/ # MkDocs documentation
โ”œโ”€โ”€ alembic/ # Alembic migrations
โ”œโ”€โ”€ scripts/ # CLI scripts
โ”œโ”€โ”€ Dockerfile # Docker configuration
โ”œโ”€โ”€ docker-compose.yml # Base Compose config
โ””โ”€โ”€ ...

```
### ๐Ÿ› ๏ธ Installation

### Prerequisites

- Python 3.10+
- Docker & Docker Compose (optional)
- PostgreSQL

### ๐Ÿ“ฆ Clone the Repository

```bash
git clone https://github.com/yourusername/swx-api.git
cd swx-api
```

### ๐Ÿ Create a Virtual Environment

```bash
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
```

### ๐Ÿ“ฅ Install Dependencies

```bash
pip install -r requirements.txt
```

### โš™๏ธ Configure Environment Variables

Create a `.env` file in the project root with the following content:

```env
DATABASE_URL=postgresql+psycopg2://user:password@localhost:5432/swx_db
JWT_SECRET_KEY=your_jwt_secret
```

> Replace `user`, `password`, and `swx_db` with your actual PostgreSQL credentials and database name.

### ๐Ÿ”„ Run Database Migrations

```bash
swx migrate
```

### ๐Ÿš€ Start the Development Server

```bash
uvicorn main:app --reload
```

---

### ๐Ÿณ Run with Docker (Optional)

If you prefer using Docker:

```bash
docker-compose up --build
```

> This will spin up the app along with PostgreSQL using the provided `docker-compose.yml`.

---

## Deployment

Deployment docs: [deployment.md](./deployment.md).

## Development

General development docs: [development.md](./development.md).

This includes using Docker Compose, custom local domains, `.env` configurations, etc.