This project is an Android application built with Jetpack Compose, Room DB, and Retrofit for managing user profiles. It follows the MVVM architecture and interacts with the ReqRes API for user data.
You can download the latest APK from the Releases page.
- Fetch and Display Users: Fetch users from the ReqRes API and display them in a list.
- Add User: Add new users via a form and sync with the ReqRes API.
- Offline Storage: Users are stored locally in a Room database.
- Error Handling: Display appropriate messages when there's an issue with the API or database operations.
- MVVM: The project follows the Model-View-ViewModel (MVVM) architecture.
- Room: Used for local database storage.
- Retrofit: Handles network operations for communicating with the ReqRes API.
- Jetpack Compose: UI toolkit used for building the user interface.
- Purpose: Entry point of the app.
- Responsibilities: Displays the home page or the add user page based on the state.
- Purpose: Manages data operations between the local database and the API.
- Functions:
fetchAndStoreUsers(apiService: ApiService)
: Fetches users from the API and stores them in the database.getUsersFromDb()
: Retrieves users from the local database.addUser(apiService: ApiService, user: User)
: Adds a user to the API and database, ensuring synchronization.
- Purpose: Manages UI-related data and business logic.
- Responsibilities:
- Initializes user data from the database.
- Handles user addition and synchronization with the API.
- Provides LiveData for observing changes in user data and error messages.
- AppDatabase: Room database setup with a single entity,
User
. - UserDao: Data Access Object for user-related database operations.
- ApiService: Retrofit interface for API endpoints.
@GET("users?page=2")
: Fetches users.@POST("users")
: Creates a new user.
- Android Studio
- Kotlin
- Basic knowledge of MVVM architecture
-
Clone the Repository:
git clone https://github.com/mishrabiswajit/366pi-roomdb-reqres.git
-
Open Project in Android Studio:
- Open Android Studio and select "Open an existing project."
- Navigate to the cloned repository and open it.
-
Build and Run:
- Ensure that your
gradle
files are up-to-date. - Build and run the application on an emulator or physical device.
- Ensure that your
- Fork the repository and create a pull request for any improvements or bug fixes.
This project is licensed under the MIT License. See the LICENSE file for details.
For any questions or issues, please reach out to [email protected].