Skip to content

mfafore22/auth-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Authentication API Project

A full-stack authentication system built with FastAPI backend and React frontend, containerized with Docker and deployable to Kubernetes.

Project Structure

.
├── backend/                 # Python FastAPI backend
│   ├── app/
│   │   ├── auth/           # Authentication services
│   │   ├── models/         # Data models
│   │   ├── routes/         # API endpoints
│   │   └── utils/          # Utility functions
│   ├── Dockerfile          # Backend container configuration
│   └── requirements.txt    # Python dependencies
├── frontend/               # React frontend
│   ├── src/
│   │   ├── components/     # Reusable React components
│   │   ├── pages/         # Page components
│   │   └── services/      # API services
│   ├── Dockerfile         # Frontend container configuration
│   └── package.json       # Node.js dependencies
└── k8s/                   # Kubernetes configuration files
    ├── backend-deployment.yaml
    ├── frontend-deployment.yaml
    └── ingress.yaml

Features

  • User authentication with JWT tokens
  • Protected API endpoints
  • React-based frontend with login interface
  • Docker containerization
  • Kubernetes deployment configuration
  • DynamoDB integration for user management

Prerequisites

  • Python 3.12+
  • Node.js and npm
  • Docker and Docker Compose
  • Kubernetes cluster (for deployment)
  • AWS credentials (for DynamoDB)

Getting Started

Backend Setup

  1. Navigate to the backend directory:
cd backend
  1. Create a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Set up environment variables:
# Create a .env file with:
SECRET_KEY=your-secret-key
AWS_ACCESS_KEY_ID=your-aws-access-key
AWS_SECRET_ACCESS_KEY=your-aws-secret-key

Frontend Setup

  1. Navigate to the frontend directory:
cd frontend
  1. Install dependencies:
npm install
  1. Create environment configuration:
# Create .env file with:
VITE_API_URL=http://localhost:8000

Running the Application

Using Docker Compose

docker-compose up

This will start both the frontend and backend services.

Manual Development Setup

  1. Start the backend:
cd backend
uvicorn app.main:app --reload
  1. Start the frontend:
cd frontend
npm run dev

Deployment

Kubernetes Deployment

  1. Apply the namespace:
kubectl apply -f k8s/namespace.yaml
  1. Deploy the backend:
kubectl apply -f k8s/backend-deployment.yaml
kubectl apply -f k8s/backend-service.yaml
  1. Deploy the frontend:
kubectl apply -f k8s/frontend-deployment.yaml
kubectl apply -f k8s/frontend-service.yaml
  1. Configure ingress:
kubectl apply -f k8s/ingress.yaml

API Documentation

Once the backend is running, visit http://localhost:8000/docs for the OpenAPI documentation.

Security Considerations

  • JWT tokens are used for authentication
  • Passwords are hashed before storage
  • Environment variables are used for sensitive data
  • CORS is configured for security
  • Rate limiting is implemented on authentication endpoints

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors