{"id":50695726,"url":"https://github.com/hngprojects/anvila-backend","last_synced_at":"2026-06-09T06:08:26.847Z","repository":{"id":357821027,"uuid":"1238489738","full_name":"hngprojects/anvila-backend","owner":"hngprojects","description":null,"archived":false,"fork":false,"pushed_at":"2026-06-05T19:00:03.000Z","size":1138,"stargazers_count":0,"open_issues_count":13,"forks_count":0,"subscribers_count":0,"default_branch":"dev","last_synced_at":"2026-06-05T20:21:46.309Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hngprojects.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-14T06:59:16.000Z","updated_at":"2026-06-05T19:00:09.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/hngprojects/anvila-backend","commit_stats":null,"previous_names":["hngprojects/anvila-backend"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hngprojects/anvila-backend","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hngprojects%2Fanvila-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hngprojects%2Fanvila-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hngprojects%2Fanvila-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hngprojects%2Fanvila-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hngprojects","download_url":"https://codeload.github.com/hngprojects/anvila-backend/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hngprojects%2Fanvila-backend/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34093840,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-09T06:08:26.034Z","updated_at":"2026-06-09T06:08:26.842Z","avatar_url":"https://github.com/hngprojects.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **FASTAPI Boilerplate**  \nA FastAPI boilerplate for efficient project setup.  \n\n## **Cloning the Repository**  \n\n1. **Fork the repository** and clone it:  \n   ```sh\n   git clone https://github.com/\u003cusername\u003e/hng_boilerplate_python_fastapi_web.git\n   ```\n2. **Navigate into the project directory**:  \n   ```sh\n   cd hng_boilerplate_python_fastapi_web\n   ```\n3. **Switch to the development branch** (if not already on `dev`):  \n   ```sh\n   git checkout dev\n   ```\n\n\n## **Setup Instructions**  \n\n1. **Create a virtual environment**:  \n   ```sh\n   python3 -m venv .venv\n   ```\n2. **Activate the virtual environment**:  \n   - On macOS/Linux:  \n     ```sh\n     source .venv/bin/activate\n     ```\n   - On Windows (PowerShell):  \n     ```sh\n     .venv\\Scripts\\Activate\n     ```\n3. **Install project dependencies**:  \n   ```sh\n   pip install -r requirements.txt\n   ```\n4. **Create a `.env` file** from `.env.sample`:  \n   ```sh\n   cp .env.sample .env\n   ```\n5. **Start the server**:  \n   ```sh\n   python main.py\n   ```\n\n---\n\n## **Database Setup**  \n\n### **Replacing Placeholders in Database Setup**  \n\nWhen setting up the database, you need to replace **placeholders** with your actual values. Below is a breakdown of where to replace them:\n\n---\n\n## **Step 1: Create a Database User**\n```sql\nCREATE USER user WITH PASSWORD 'your_password';\n```\n🔹 **Replace:**  \n- `user` → Your **preferred database username** (e.g., `fastapi_user`).  \n- `'your_password'` → A **secure password** for the user (e.g., `'StrongP@ssw0rd'`).  \n\n✅ **Example:**  \n```sql\nCREATE USER fastapi_user WITH PASSWORD 'StrongP@ssw0rd';\n```\n\n---\n\n## **Step 2: Create the Database**\n```sql\nCREATE DATABASE hng_fast_api;\n```\n🔹 **Replace:**  \n- `hng_fast_api` → Your **preferred database name** (e.g., `fastapi_db`).  \n\n✅ **Example:**  \n```sql\nCREATE DATABASE fastapi_db;\n```\n\n---\n\n## **Step 3: Grant Permissions**\n```sql\nGRANT ALL PRIVILEGES ON DATABASE hng_fast_api TO user;\n```\n🔹 **Replace:**  \n- `hng_fast_api` → The **database name you used** in Step 2.  \n- `user` → The **username you created** in Step 1.  \n\n✅ **Example:**  \n```sql\nGRANT ALL PRIVILEGES ON DATABASE fastapi_db TO fastapi_user;\n```\n\n---\n\n## **Step 4: Update `.env` File**\nEdit the `.env` file to match your setup.\n\n```env\nDATABASE_URL=postgresql://user:your_password@localhost/hng_fast_api\n```\n🔹 **Replace:**  \n- `user` → Your **database username**.  \n- `your_password` → Your **database password**.  \n- `hng_fast_api` → Your **database name**.  \n\n✅ **Example:**  \n```env\nDATABASE_URL=postgresql://fastapi_user:StrongP@ssw0rd@localhost/fastapi_db\n```\n\n---\n\n## **Step 5: Verify Connection**\nAfter setting up the database, test the connection:\n\n```sh\npsql -U user -d hng_fast_api -h localhost\n```\n🔹 **Replace:**  \n- `user` → Your **database username**.  \n- `hng_fast_api` → Your **database name**.  \n\n✅ **Example:**  \n```sh\npsql -U fastapi_user -d fastapi_db -h localhost\n```\n\n## **Step 6: Run database migrations**  \n   ```sh\n   alembic upgrade head\n   ```\n   _Do NOT run `alembic revision --autogenerate -m 'initial migration'` initially!_\n\n## **Step 7: If making changes to database models, update migrations**  \n```sh\n   alembic revision --autogenerate -m 'your migration message'\n   alembic upgrade head\n   ```\n## **Step 8: Seed dummy data**  \n   ```sh\n   python3 seed.py\n   ```\n\n---\n\n## **Adding Tables and Columns**  \n\n1. **After creating new tables or modifying models**:  \n   - Run Alembic migrations:  \n     ```sh\n     alembic revision --autogenerate -m \"Migration message\"\n     alembic upgrade head\n     ```\n   - Ensure you **import new models** into `api/v1/models/__init__.py`.  \n   - You do NOT need to manually import them in `alembic/env.py`.\n\n---\n\n## **Adding New Routes**  \n\n1. **Check if a related route file already exists** in `api/v1/routes/`.  \n   - If yes, add your route inside the existing file.  \n   - If no, create a new file following the naming convention.  \n2. **Define the router** inside the new route file:  \n   - Include the prefix (without `/api/v1` since it's already handled).  \n3. **Register the router in `api/v1/routes/__init__.py`**:  \n   ```python\n   from .new_route import router as new_router\n   api_version_one.include_router(new_router)\n   ```\n\n---\n\n## **Running Tests with Pytest**  \n\n### **Install Pytest**  \nEnsure `pytest` is installed in your virtual environment:  \n```sh\npip install pytest\n```\n\n### **Run all tests in the project**  \nFrom the **project root directory**, run:  \n```sh\npytest\n```\nThis will automatically discover and execute all test files in the `tests/` directory.\n\n### **Run tests in a specific directory**  \nTo run tests in a specific model directory (e.g., `tests/v1/user/`):  \n```sh\npytest tests/v1/user/\n```\n\n### **Run a specific test file**  \nTo run tests from a specific test file (e.g., `test_signup.py` inside `tests/v1/auth/`):  \n```sh\npytest tests/v1/auth/test_signup.py\n```\n\n### **Run a specific test function**  \nIf you want to run a specific test inside a file, use:  \n```sh\npytest tests/v1/auth/test_signup.py::test_user_signup\n```\n\n### **Run tests with detailed output**  \nFor verbose output, add the `-v` flag:  \n```sh\npytest -v\n```\n\n### **Run tests and generate coverage report**  \nTo check test coverage, install `pytest-cov`:  \n```sh\npip install pytest-cov\n```\nThen run:  \n```sh\npytest --cov=api\n```\n\n---\n\n## **Common Migration Issues \u0026 Solutions**  \n\n### **Error: \"Target database is not up to date.\"**  \nIf you encounter this issue when running:  \n```sh\nalembic revision --autogenerate -m 'your migration message'\n```\n#### **Solution**:  \nRun the following command first:  \n```sh\nalembic upgrade head\n```\nThen retry:  \n```sh\nalembic revision --autogenerate -m 'your migration message'\n```\n\n---\n\n## **Contribution Guidelines**  \n\n- **Test your endpoints and models** before pushing changes.  \n- **Push Alembic migrations** if database models are modified.  \n- Ensure your code **follows project standards** and **passes tests** before submitting a pull request.  \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhngprojects%2Fanvila-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhngprojects%2Fanvila-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhngprojects%2Fanvila-backend/lists"}