Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Contacts API

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.

Features

  • 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.

Project Structure

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

Installation

1. Clone the repository

git clone https://github.com/yourusername/contacts_api.git
cd contacts_api/contacts_api

2. Create & activate virtual environment

python -m venv venv
source venv/bin/activate   # On Linux/Mac
venv\Scripts\activate    # On Windows

3. Install dependencies

pip install -r requirements.txt

4. Configure environment variables

Copy .env.example to .env and update values as needed (database URL, JWT secret, etc.).

5. Run database migrations (if using Alembic or similar)

alembic upgrade head

6. Start the application

uvicorn app.main:app --reload

App will be available at: http://127.0.0.1:8000

Running with Docker

  1. Build and start containers
docker-compose up --build
  1. API will be available at http://localhost:8000

API Endpoints

  • Auth

    • POST /auth/signup → Register new user
    • POST /auth/login → Login and get JWT token
  • Contacts

    • GET /contacts/ → List all contacts
    • POST /contacts/ → Create new contact
    • GET /contacts/{id} → Retrieve contact by ID
    • PUT /contacts/{id} → Update contact
    • DELETE /contacts/{id} → Delete contact

Tech Stack

  • Backend: FastAPI
  • Database: SQLAlchemy (likely PostgreSQL/MySQL/SQLite depending on config)
  • Auth: JWT Authentication
  • Deployment: Docker & Docker Compose
  • Validation: Pydantic

About

FastAPI service for managing contacts with JWT auth.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages