The Tax Collection System is a FastAPI-based application designed to manage tax records, user assignments, and authentication for a tax collection service. It provides a robust API for managing houses, tax records, user roles, and assignments, with secure authentication and role-based access control.
- Authentication: Implements JWT-based authentication with access and refresh tokens.
- Role-Based Access Control: Supports roles such as
ADMINandCOLLECTORfor secure access to endpoints. - House Management: Create, retrieve, and manage house records.
- Tax Record Management: Insert, retrieve, and update tax records.
- User Management: Register users with role-based permissions.
- Assignment Management: Assign collectors to houses for tax collection.
- Database Integration: Uses SQLModel for ORM and SQLite for database management.
- Unit Tests: Comprehensive test coverage for all major functionalities.
├── auth/ # Authentication utilities ├── controller/ # Business logic for various modules ├── db.py # Database setup and session management ├── main.py # Entry point for the FastAPI application ├── objects/ # Data models for houses, users, tax records, etc. ├── service/ # API routes and handlers ├── tests/ # Unit tests for the application ├── requirements.txt # Python dependencies ├── pyproject.toml # Configuration for code formatting and linting └── README.md # Project documentation
-
Clone the repository:
bash git clone https://github.com/krishnakarthikperi/TaxCollectionSystem-Backend.git cd Tax-Collection -
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate -
Install dependencies:
pip install -r requirements.txt -
Run the application:
uvicorn main:app --reload
POST /token: Authenticate a user and return access and refresh tokens.POST /token/refresh: Refresh an expired access token.POST /logout: Log out the currently authenticated user.
POST /register: Register a new user (Admin-only).
POST /house: Create new house records.GET /households: Retrieve all house records.GET /households/{household_id}: Retrieve house records by household ID.
POST /recordcollections: Insert multiple tax records.GET /gettaxrecords: Retrieve all tax records.GET /tax-records/{houseNumber}: Retrieve tax records for a specific house.PUT /tax-record/{recordId}: Update a specific tax record.
POST /assign-collector: Assign a collector to a house (Admin-only).GET /assignments/{collector_id}: Retrieve assignments for a specific user.
Run the unit tests using pytest:
pytest
The application uses SQLite as the database. The database file is located at taxcollection1.db. To initialize the database and create tables, run:
python db.py
- Black: Code formatter configured in pyproject.toml.
- Ruff: Linter configured in pyproject.toml.
The application uses JWT for authentication. Key configurations include:
- Access Token Expiry: 30 minutes
- Refresh Token Expiry: 7 days
- Algorithm: HS256
- Keys: Update ACCESS_SECRET_KEY and REFRESH_SECRET_KEY in auth/authconstants.py before deployment.
- Explore alternate methods for dependency injection in non-route paths.
- Add more granular role-based permissions for endpoints.
This project is licensed under the MIT License. See the LICENSE file for details.
- Krishna Karthik Peri - Developer