# zx-fastapi-cms **Repository Path**: open-php/zx-fastapi-cms ## Basic Information - **Project Name**: zx-fastapi-cms - **Description**: 基于fastapi的 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-04-21 - **Last Updated**: 2026-05-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # napp This project was generated using fastapi_template. ## UV This project uses uv. It's a modern dependency management tool. To run the project use this set of commands: ```bash uv sync --locked uv run -m napp ``` This will start the server on the configured host. You can find swagger documentation at `/api/docs`. You can read more about uv here: https://docs.astral.sh/ruff/ ## Docker You can start the project with docker using this command: ```bash docker compose up --build ``` This command exposes the web application on port 8000, mounts current directory and enables autoreload. But you have to rebuild image every time you modify `uv.lock` or `pyproject.toml` with this command: ```bash docker compose build ``` ## Project structure ```bash $ tree "napp" napp ├── conftest.py # Fixtures for all tests. ├── db # module contains db configurations │   ├── dao # Data Access Objects. Contains different classes to interact with database. │   └── models # Package contains different models for ORMs. ├── __main__.py # Startup script. Starts uvicorn. ├── services # Package for different external services such as rabbit or redis etc. ├── settings.py # Main configuration settings for project. ├── static # Static content. ├── tests # Tests for project. └── web # Package contains web server. Handlers, startup config. ├── api # Package with all handlers. │   └── router.py # Main router. ├── application.py # FastAPI application configuration. └── lifespan.py # Contains actions to perform on startup and shutdown. ``` ## Configuration This application can be configured with environment variables. You can create `.env` file in the root directory and place all environment variables here. All environment variables should start with "NAPP_" prefix. For example if you see in your "napp/settings.py" a variable named like `random_parameter`, you should provide the "NAPP_RANDOM_PARAMETER" variable to configure the value. This behaviour can be changed by overriding `env_prefix` property in `napp.settings.Settings.Config`. An example of .env file: ```bash NAPP_RELOAD="True" NAPP_PORT="8000" NAPP_ENVIRONMENT="dev" ``` You can read more about BaseSettings class here: https://pydantic-docs.helpmanual.io/usage/settings/ ## Pre-commit To install pre-commit simply run inside the shell: ```bash pre-commit install ``` pre-commit is very useful to check your code before publishing it. It's configured using .pre-commit-config.yaml file. By default it runs: * mypy (validates types); * ruff (spots possible bugs); You can read more about pre-commit here: https://pre-commit.com/ ## Migrations If you want to migrate your database, you should run following commands: ```bash # Upgrade database to the last migration. aerich upgrade ``` ### Reverting migrations If you want to revert migrations, you should run: ```bash aerich downgrade ``` ### Migration generation To generate migrations you should run: ```bash aerich migrate ``` ## Running tests If you want to run it in docker, simply run: ```bash docker compose run --build --rm api pytest -vv . docker compose down ``` For running tests on your local machine. 1. you need to start all aux services. We can do so by using our `docker-compose.yaml` configuration. It already has everything we need. ```bash docker compose up -d --wait db redis ``` 2. Run tests. ```bash pytest -vv . ```