This is the backend service for JieNote, built with FastAPI.
- RESTful API endpoints
- Modular structure for scalability
app/
: Contains the main application code.main.py
: Entry point for the FastAPI application.models/
: Database models and schemas.core/
: Core configurations and settings.- include database settings
- include JWT settings
- include CORS settings
- ……
curd/
: CRUD operations for database interactions.db/
: Database connection and session management.schemas/
: Pydantic schemas for data validation.static/
: Static files (e.g., images, CSS).routers/
: API route definitions.
tests/
: Contains test cases for the application.requirements.txt
: List of dependencies.README.md
: Documentation for the project.alembic/
: Database migration scripts and configurations.env/
: Virtual environment (not included in version control).img/
: Images used in the project.
- Create a virtual environment: ✔
python -m venv env
- Activate the virtual environment:
- On Windows:
.\env\Scripts\activate
- On macOS/Linux:
source env/bin/activate
- On Windows:
- Install dependencies:
pip install -r requirements.txt
- freeze requirements(do before commit !!!):
pip freeze > requirements.txt
-
Install Alembic: ✔
pip install alembic
-
Initialize Alembic: ✔
alembic init alembic
-
Configure Alembic: ✔
- Edit
alembic.ini
to set the database URL. - Edit
alembic/env.py
to set up the target metadata.from app.models import Base # Import your models here target_metadata = Base.metadata
- Edit
-
Create a migration script: need to modify the script
alembic revision --autogenerate -m "提交信息"
-
Apply the migration: need to modify the script
alembic upgrade head
uvicorn app.main:app --reload
- Redis is used for caching and session management.
- Make sure to have Redis installed and running.
cd path/to/redis
# Start Redis server
redis-server.exe redis.windows.conf
Attention!!!
- Make sure the port is not occupied by other services.
- If you want to use the default port, please modify the
redis.windows.conf
file. - Must connect Redis before running the application.
‼️ ‼️ ‼️
- JWT (JSON Web Token) is used for authentication.
- Refresh tokens for 7 days and access tokens for 5min.
app/
: Contains the main application code.tests/
: Contains test cases.env/
: Virtual environment (not included in version control).
- Must install Poppler
MIT License