Skip to content

ADCarthan88/REST_API_CRUD

Repository files navigation

REST API CRUD

A professional-grade REST API built with Django REST Framework for managing products and users with full CRUD operations.

🚀 Features

  • Products Management: Complete CRUD operations for products
  • Users Management: Complete CRUD operations for users
  • SQLite Database: Lightweight development database (PostgreSQL ready)
  • API Documentation: Auto-generated Swagger/OpenAPI docs
  • CORS Support: Cross-origin resource sharing enabled
  • Admin Interface: Django admin for easy data management

🛠️ Tech Stack

  • Backend: Django REST Framework
  • Database: SQLite (Development) / PostgreSQL (Production)
  • Documentation: Swagger (OpenAPI)
  • Deployment: Railway/Render ready

📋 Prerequisites

  • Python 3.8+
  • pip

🔧 Quick Start

  1. Clone the repository
git clone https://github.com/ADCarthan88/REST_API_CRUD.git
cd REST_API_CRUD
  1. Create virtual environment
python -m venv venv
venv\Scripts\activate  # Windows
# source venv/bin/activate  # macOS/Linux
  1. Install dependencies
python -m pip install -r requirements.txt
  1. Setup database
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
  1. Run the server
python manage.py runserver

📚 API Endpoints

Products

  • GET /api/products/ - List all products
  • POST /api/products/ - Create new product
  • GET /api/products/{id}/ - Get specific product
  • PUT /api/products/{id}/ - Update product
  • DELETE /api/products/{id}/ - Delete product

Users

  • GET /api/users/ - List all users
  • POST /api/users/ - Create new user
  • GET /api/users/{id}/ - Get specific user
  • PUT /api/users/{id}/ - Update user
  • DELETE /api/users/{id}/ - Delete user

📖 API Documentation

🧪 Testing with Postman

Create Product

POST http://localhost:8000/api/products/
Content-Type: application/json

{
    "name": "Sample Product",
    "description": "A sample product description",
    "price": "29.99",
    "stock": 100
}

Create User

POST http://localhost:8000/api/users/
Content-Type: application/json

{
    "first_name": "John",
    "last_name": "Doe",
    "email": "john@example.com",
    "phone": "123-456-7890"
}

🗂️ Project Structure

REST_API_CRUD/
├── my_cutsom_api/           # Main Django project
│   ├── settings.py          # Django settings
│   ├── urls.py              # URL routing
│   └── wsgi.py              # WSGI config
├── products/                # Products app
│   ├── models.py            # Product model
│   ├── serializers.py       # API serializers
│   ├── views.py             # API views
│   └── urls.py              # Product URLs
├── users/                   # Users app
│   ├── models.py            # User model
│   ├── serializers.py       # API serializers
│   ├── views.py             # API views
│   └── urls.py              # User URLs
├── requirements.txt         # Dependencies
├── manage.py               # Django management
└── README.md               # This file

🚀 Deployment

Railway

  1. Connect your GitHub repository
  2. Add environment variables
  3. Deploy automatically

Render

  1. Create new Web Service
  2. Connect repository
  3. Add environment variables
  4. Deploy

Environment Variables for Production

SECRET_KEY=your-production-secret-key
DEBUG=False
DB_NAME=your_db_name
DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_HOST=your_db_host
DB_PORT=5432

🤝 Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open Pull Request

📄 License

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

👨‍💻 Author

Adam Carthan

🙏 Acknowledgments

  • Django REST Framework team
  • Django community
  • All contributors

⭐ Star this repo if you find it helpful!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published