This project is an Automatic REST API Generator built with FastAPI and SQLAlchemy. It reads a PostgreSQL/MySQL database and generates a fully functional CRUD API automatically.
- 🏗️ Automatic API Generation from a Database
- 🔥 FastAPI for high-performance backend
- 🛠️ SQLAlchemy for ORM and database interaction
- 🐳 Docker & Docker Compose for containerized deployment
- 🛡️ Environment Variable Management using
.env - 🔍 Swagger UI for API Documentation (
/docs)
├── app/
│ ├── models/ # Database models
│ ├── routes/ # API routes
│ ├── database.py # Database connection setup
│ ├── main.py # Main FastAPI app entry point
│
├── .env # Environment variables (ignored in git)
├── .gitignore # Ignore unnecessary files
├── Dockerfile # Docker build configuration
├── docker-compose.yml # Docker Compose setup for API & DB
├── requirements.txt # Python dependencies
├── README.md # Project documentation
git clone https://github.com/yourusername/gerador_api_rest.git
cd gerador_api_restpython -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`pip install -r requirements.txtCreate a .env file with your database credentials:
DATABASE_URL=postgresql://user:password@localhost:5432/gerador_api_restRun the following command to create the tables in the database:
python -c "from app.database import Base, engine; Base.metadata.create_all(bind=engine)"uvicorn app.main:app --reloadNow, open your browser and access:
- 🌍 API Swagger UI: http://127.0.0.1:8000/docs
docker-compose up --build| Method | Endpoint | Description |
|---|---|---|
GET |
/users/ |
Get all users |
POST |
/users/ |
Create a new user |
| Method | Endpoint | Description |
|---|---|---|
GET |
/products/ |
Get all products |
POST |
/products/ |
Create a new product |
- Fork the repository.
- Create a branch (
git checkout -b feature-branch) - Commit changes (
git commit -m "Added feature") - Push to the branch (
git push origin feature-branch) - Create a Pull Request 🚀
This project is MIT Licensed. Feel free to use and modify it!