This project implements a modular and extensible user authentication system based on Hexagonal Architecture (Ports & Adapters Pattern) using Python and FastAPI.
- User Registration and Login
- Email validation
- Exception handling using custom errors
- Database access through clean abstractions
- Designed with Hexagonal Architecture for better testability and scalability
This project follows the Hexagonal Architecture (also known as Ports and Adapters), which ensures a clean separation between:
- Core Domain Logic (Business Rules)
- Inbound Adapters (e.g., REST API)
- Outbound Adapters (e.g., Database Access)
- Application Services (use cases)
+-----------------------+
| REST API (FastAPI)|
+----------+------------+
|
+----------v-----------+
| Application Service |
+----------+-----------+
|
+----------v-----------+
| Domain Logic |
+----------+-----------+
|
+----------v-----------+
| DB Adapter (SQLite) |
+----------------------+
hexagonal_user_auth/
├── app/
│ ├── domain/ # Core domain models & interfaces
│ ├── service/ # Application logic (use cases)
│ ├── adapters/ # Inbound (API) and outbound (DB) adapters
│ ├── main.py # FastAPI entry point
├── user.db # SQLite DB (recommend .gitignore this)
├── requirements.txt # Python dependencies
├── README.md # Project documentation
- Clone the Repository
git clone https://github.com/vijayagopalsb/hexagonal_user_auth.git
cd hexagonal_user_auth
- Create a Virtual Environment
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
- Install Dependencies
pip install -r requirements.txt
- Run the Application
uvicorn app.main:app --reload
Coming soon...
-
JWT-based token authentication
-
Role-based access control
-
OAuth2 or social login
-
Docker support
-
CI/CD pipeline
This project is licensed under the MIT License. See the LICENSE file for details.