A FastAPI-based application for managing contacts with authentication support.
It provides RESTful endpoints for creating, retrieving, updating, and deleting contacts, along with user authentication.
- User authentication (JWT-based).
- CRUD operations for managing contacts.
- Database integration with SQLAlchemy.
- Pydantic schemas for validation.
- Dockerized setup for easy deployment.
- Environment-based configuration with
.env.
contacts_api/
│── .env.example # Example environment variables
│── docker-compose.yml # Docker services configuration
│── Dockerfile # Docker build file
│── requirements.txt # Python dependencies
│
├── app/
│ ├── main.py # Application entry point
│ ├── auth.py # Authentication & JWT logic
│ ├── crud.py # CRUD operations
│ ├── database.py # Database configuration
│ ├── models.py # SQLAlchemy models
│ ├── schemas.py # Pydantic schemas
│ ├── utils.py # Helper functions
│ └── __init__.py
git clone https://github.com/yourusername/contacts_api.git
cd contacts_api/contacts_apipython -m venv venv
source venv/bin/activate # On Linux/Mac
venv\Scripts\activate # On Windowspip install -r requirements.txtCopy .env.example to .env and update values as needed (database URL, JWT secret, etc.).
alembic upgrade headuvicorn app.main:app --reloadApp will be available at: http://127.0.0.1:8000
- Build and start containers
docker-compose up --build- API will be available at http://localhost:8000
-
Auth
POST /auth/signup→ Register new userPOST /auth/login→ Login and get JWT token
-
Contacts
GET /contacts/→ List all contactsPOST /contacts/→ Create new contactGET /contacts/{id}→ Retrieve contact by IDPUT /contacts/{id}→ Update contactDELETE /contacts/{id}→ Delete contact
- Backend: FastAPI
- Database: SQLAlchemy (likely PostgreSQL/MySQL/SQLite depending on config)
- Auth: JWT Authentication
- Deployment: Docker & Docker Compose
- Validation: Pydantic