(you can also use Docker to run the app)
- Install Python 3.11
- Install pip
- Create venv:
python3 -m venv apiVenv - Activate venv:
source apiVenv/bin/activateorapiVenv\Scripts\activate - Install requirements:
pip install -r requirements.txt
- Set up the database connection in
app/config/database.py - Set info about the database in
.envfileDATABASE_URL- database URL for postgresql. Example:postgresql://user:password@localhost:port/dbnameUSE_SQLITE_DB- set toTrueif you want to use SQLite database for testingCORS_ORIGIN_WHITELIST- list of allowed origins for CORS. Example:http://localhost:3000,http://localhost
- Go to app:
cd app - Run server:
uvicorn main:app
You can use tools: docket-tool.ps1 or docker-tool.sh to build and run the docker container.
- Build the container:
./docker-tool.ps1 build - Run the container:
./docker-tool.ps1 run
You can also:
- Check the container status:
./docker-tool.ps1 check - Stop the container:
./docker-tool.ps1 stop - Remove the container and images:
./docker-tool.ps1 rm
- Build the container:
docker build -t larpex-backend . - Run the container:
docker run -d -p 8000:8000 larpex-backend
Follow this steps:
- Create an ORM model in
app/models/directory. - Create a Pydantic schema in
app/schemas/directory. - Create a service in
app/services/directory. - Create a router in
app/routers/directory. - Add the router to the
app/main.pyfile.
Check each folder for README with examples.
Use refference from:
├─ app/
├── config/ # Backend functionality and configs
│ ├── config.py # Configuration settings
│ ├── database.py # Database connection settings
| ├── exceptions.py # Custom exceptions
├── models/ # SQLAlchemy models
│ ├── base.py # Base classes, mixins
│ └── ... # Other service models
├── routers/ # API routes
│ └── ... # Other service routers
├── schemas/ # Pydantic models
│ └── ... # Other service schemas
├── services/ # Business logic
│ └── ... # Other service classes
├── consts.py # Constants
└── main.py # Application runner
── requirements.txt # Python dependencies