# FastAPI REST API Service This is a FastAPI-based REST API with user authentication, built with SQLite for data storage. ## Features - User registration and authentication with JWT tokens - FastAPI automatic Swagger documentation - SQLAlchemy ORM for database operations - Alembic migrations for database versioning - Password hashing with bcrypt - Health check endpoint ## Getting Started ### Prerequisites - Python 3.8+ - SQLite ### Installation 1. Clone the repository: ```bash git clone cd genericrestapiservice ``` 2. Install the dependencies: ```bash pip install -r requirements.txt ``` 3. Apply the database migrations: ```bash alembic upgrade head ``` 4. Run the application: ```bash uvicorn main:app --reload ``` The API will be available at http://localhost:8000. ## API Documentation Once the application is running, you can access the following documentation: - Swagger UI: http://localhost:8000/docs - ReDoc: http://localhost:8000/redoc ## API Endpoints ### Health Check - `GET /health` - Check if the API is healthy ### Users - `POST /users` - Register a new user - `POST /users/token` - Get an access token (login) - `GET /users/me` - Get the current authenticated user - `GET /users/{user_id}` - Get a user by ID ## Database The application uses SQLite as the database. The database file is stored at `/app/storage/db/db.sqlite`. ### Migrations Database migrations are managed with Alembic. To apply migrations: ```bash alembic upgrade head ``` To create a new migration: ```bash alembic revision -m "description" ``` ## Development ### Code Structure - `app/` - Main application directory - `models/` - SQLAlchemy models - `schemas/` - Pydantic schemas - `routers/` - FastAPI routers - `utils.py` - Utility functions - `database.py` - Database configuration - `alembic/` - Alembic migrations - `main.py` - Application entry point ### Running Tests ```bash pytest ```