The User Service is a microservice in the Pizza Delivery API system. It is responsible for user authentication, registration, and token management using FastAPI, SQLAlchemy, and JWT authentication. The service is containerized using Docker and connects to a PostgreSQL database.
- User Registration (Signup)
- User Login with JWT authentication
- Token Refresh Mechanism
- Database Integration using PostgreSQL
- Dockerized Deployment
- FastAPI (Backend Framework)
- SQLAlchemy (ORM)
- PostgreSQL (Database)
- Docker & Docker Compose (Containerization)
- Alembic (Database Migrations)
- Pydantic (Data Validation)
- JWT Authentication
git clone https://github.com/your-username/user-service.git
cd user-serviceCreate a .env file in the root directory and define the following variables:
DATABASE_URL=postgresql+psycopg2://username:password@postgres:5433/user_service
SECRET_KEY= Your_JWT_secrete_key
JWT_ALGORITHM=HS256
JWT_ACCESS_TOKEN_EXPIRE_MINUTES=30
JWT_REFRESH_TOKEN_EXPIRE_MINUTES=1400docker-compose up --build -ddocker exec -it user-service-container alembic upgrade headOnce the container is running, you can access the API docs at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
| Endpoint | Method | Description |
|---|---|---|
/signup |
POST | User registration |
/login |
POST | User login and token generation |
/refresh |
POST | Refresh access token |
If you make any changes to your models, run the following command to create a new migration:
docker exec -it user-service-container alembic revision --autogenerate -m "migration message"
docker exec -it user-service-container alembic upgrade headTo stop the running containers:
docker-compose downThis project is licensed under the MIT License.