Skip to main content

🐍 Cstack - Python made Easy

An Opinionated Full Stack Framework for Web Development. Built on Python, Vite, and Vue.

This stack can be used to create a fullstack application that can be deployed on Deta, or another python hosting. It includes:

  • Monadic Error Handling
  • ORM
  • Testing Library
  • CLI Generator
  • Type Safety

Project Structure

app/
 | api/                  -- Python Project
    | app.py             -- API Entrypoint
    | models/            -- Database ORM Models
    | config/            -- Pydantic Configuration
       | db.py           -- Database Configuration
       | env.py          -- Environment Variables
       | settings.py     -- Application Settings
    | features/          -- Feature Libraries
    | shared/            -- Shared Code
    | tests/             -- Pytest Tests
 | view/                 -- Vue Project
 __init__.py             -- Application File
.env                     -- Env File
cstack                   -- CLI Tool
pyproject.toml           -- Poetry File

Features

This is the lifeblood of a Cstack project. Cstack is feature-driven, rather than layered. The reason is feature code is co-located, rather than spread across directories. A feature includes:

  • __init__.py
  • router.py
  • services/
  • repositories/
  • repositories/mocks/
  • DTOs/

router.py

This is the fastapi router. All endpoints for this function should be defined here.

services/

This is collection of services. These services can be defined as a either a class or as a collection of functions. They should be pure operations, and contain most of the business logic. The reason for purity is testability and portability. If for a reason you move away from Cstack, the code is easily usable again. It also means that the feature logic could be shared if needed.

A service can be generated as well, these are injected into routes through FastAPI's dependency injection. A service includes:

  • {{service_name}}.py
  • test_{{service_name}}.py

repositories/

A repository communicates with the database. The reason for both repositories and an ORM is it allows the business logic to be completely decoupled from the database pattern. This is also means the services are easily testable. A repository includes:

  • {{repository_name}}.py
  • mocks/{{repository_name}}.py

The mocks folder contains dummy implementations of the repo, for use in testing.

DTOs/

This a collection of Pydantic Objects. These are used for communicating data for the given feature.

ORM Models ARE NOT DTOs. Use a Pydantic Model. Leave ORM code in the Repositories.

config/db.py

All the database setup code is contained here. It is exposed to the user if the need arises to modify it. All models should import the declared Database base.

config/settings.py

This includes versioning info, as well as other global settings used in the project. This is instantiated as a singleton, and should only be used through that singleton.

config/env.py

This is influenced by T3-stack's env folder, where they define a runtime schema for Environment Variables. These variables are defined here, and parsed through Pydantic. This is instantiated as a singleton and should only be used through that singleton.

Metadata

Release files for cstack 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cstack 0.1.2
File Size Uploaded
cstack-0.1.2.tar.gz 10.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cstack 0.1.2
File Interpreter ABI Platform
cstack-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 26.0 kB

Release files / cstack-0.1.2.tar.gz

Download URL cstack-0.1.2.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
cee9934b6ab8263a5c70713d10ac081bf4c298d2abad1ae9f99ee5cc51dcba78
BLAKE2b-256 checksum
How to use checksums
22c0091edf73ad3fc8c6ff38a13ed6cd06e0f6f2d30c8da7616d792677d9a112
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.11.0 Linux/6.0.8-300.fc37.x86_64

Release files / cstack-0.1.2-py3-none-any.whl

Download URL cstack-0.1.2-py3-none-any.whl
Size 15.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
af5a9f294ec43f489d3479603756fc947a078b9dd3ab4b8844957845652d5e76
BLAKE2b-256 checksum
How to use checksums
d198b5b72ef464d822c2e5a4c87b2542bdb4578ba58def3c7240c90f3f4bc537
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.11.0 Linux/6.0.8-300.fc37.x86_64

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page