Mini User API is a portfolio-ready FastAPI backend with PostgreSQL, SQLAlchemy, JWT authentication, role-based access control, Docker support, Swagger documentation, Render deployment, and GitHub Actions CI.
Mini User APIは、FastAPI、PostgreSQL、SQLAlchemy、JWT認証、ロールベースアクセス制御、Docker対応、Swaggerドキュメント、Renderデプロイ、GitHub Actions CIを備えたポートフォリオ用バックエンドAPIです。
| Area | Status |
|---|---|
| Backend API | ✅ Complete |
| PostgreSQL database | ✅ Connected |
| JWT authentication | ✅ Working |
| Role-based access control | ✅ Working |
| Docker support | ✅ Complete |
| Render deployment | ✅ Live |
| Swagger API documentation | ✅ Available |
| GitHub Actions CI | ✅ Passing |
JWT Backend deployed on Render:
Clone the repository:
git clone https://github.com/Iris408/mini-user-apiMove into project folder:
cd mini-user-apiInstall dependencies:
pip install -r requirements.txtStart PostgreSQL:
psql postgresCREATE DATABASE mini_user_api_db;Exit PostgreSQL:
\qRun the FastAPI server locally:
uvicorn app.main:app --reload --port 8002Open Swagger UI:
http://127.0.0.1:8002/docs
When running with Docker Compose, the backend connects to PostgreSQL using the Docker service name:
DATABASE_URL =postgresql://postgres:postgres@db:5432/mini_user_api_dbEnsure Docker Desktop is open and running:
docker compose up --buildOpen Swagger UI:
http://127.0.0.1:8002/docs
If docker compose does not work, try:
docker compose downdocker-compose up --buildIf Docker is not available, the project can still be run manually:
pip install -r requirements.txt
uvicorn app.main:app --reload --port 8002Open Swagger UI:
http://127.0.0.1:8002/docs
This project uses pytest for backend testing.
このプロジェクトでは、バックエンドテストに pytest を使用しています。
Run tests with Docker Compose Make sure the Docker containers are running:
docker compose up -d --buildRun the test suite inside the API container:
docker compose exec api pytestCurrent test coverage / 現在のテスト範囲
Current basic test coverage includes:
- Health check endpoint
- OpenAPI schema availability
現在の基本的なテスト範囲は以下です。
- ヘルスチェックエンドポイント
- OpenAPIスキーマの確認
- RESTful CRUD API
- PostgreSQL database integration
- SQLAlchemy ORM
- Dependency injection
- Modular backend architecture
- JSON request validation
- Swagger API documentation
- Password hashing with bcrypt
- JWT access token generation
- OAuth2 token route for Swagger authorization
- Protected user profile route
- Role-based admin-only user list
- Dockerized FastAPI and PostgreSQL setup
- Backend CI pipeline with GitHub Actions
- Basic backend testing with pytest
- Python
- FastAPI
- PostgreSQL
- SQLAlchemy
- Uvicorn
- Docker
- Docker Compose
- Render deployment
- JWT Authentication
- bcrypt password hashing
- pytest
- Git/GitHub
- GitHub Actions
This project includes basic JWT authentication.
Authentication features include:
- Password hashing before storing user passwords
- Login route for username/password validation
- JWT access token generation
- OAuth2
/tokenroute for Swagger authorization - Protected
/profileroute requiring a valid token
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
API status check |
| POST | /auth/register |
Register a new user |
| POST | /auth/login |
Login and receive JWT token |
| GET | /users/me |
Get current authenticated user |
| GET | /users |
Admin-only user list |
| GET | /docs |
Swagger API documentation |
各エンドポイントはSwagger UIから確認・テストできます。認証が必要なルートでは、JWTアクセストークンを Authorization ヘッダーに付与してリクエストします。
- Expand automated test coverage
- Add authentication route tests
- Add protected route tests
- Add admin-only route tests
- Environment variable documentation cleanup
- Refresh token support
- Improved role-based access control
- Docker production optimisation
- Deployment automation improvements