The backend architecture of the Personal Journal App is structured as follows:
├── app
│ ├── api_v1.py # API version routes
│ ├── config.py # Configuration settings
│ ├── __init__.py # App initialization
│ ├── manage.py # Management script
│ ├── models # Database models
│ │ ├── __init__.py
│ │ ├── journal.py # Journal model
│ │ └── user.py # User model
│ ├── resources # API resources
│ │ ├── auth.py # Authentication endpoints
│ │ ├── errors.py # Error handling
│ │ ├── journal_endpoints.py # Journal endpoints
│ │ └── __init__.py
│ └── utils # Utility functions
│ ├── otp.py # OTP generation and verification
│ └── __init__.py
├── dockerfile # Docker configuration
├── manage.py # Management script
├── migrations # Database migrations
├── migration.sh # Migration script
├── requirements.txt # Python dependencies
├── run.sh # Run script
├── tests # Unit tests
│ ├── test_auth.py # Authentication tests
│ ├── test_journal.py # Journal tests
│ └── __init__.py
Wish to test: try https://www.johnmkagunda.me/api/v2/<endpoint>
-
Register User
- Method:
POST
- Endpoint:
/register
- Description: Registers a new user.
- Importance: Allows new users to create an account in the system.
- Method:
-
Login User
- Method:
POST
- Endpoint:
/#
- Description: Authenticates a user and returns a JWT token.
- Importance: Provides a way for users to log in and access protected routes.
- Method:
-
Logout User
- Method:
POST
- Endpoint:
/logout
- Description: Revokes a users access token thus logging out.
- Importance: Provides a way for users to log out.
- Method:
-
Send OTP
- Method:
POST
- Endpoint:
/send_otp
- Description: Sends OTP to the user's email
- Importance: Ensures that the user has access to the provided email address.
- Method:
-
OTP Verification
- Method:
POST
- Endpoint:
/verify_otp
- Description: Verifies the OTP sent to the user's email.
- Importance: Ensures that the user has access to the provided email address.
- Method:
-
Password Reset
- Method:
POST
- Endpoint:
/update_password
- Description: Allows users to reset their password.
- Importance: Provides a mechanism for users to regain access to their accounts if they forget their password.
- Method:
-
Check User Exists
- Method:
POST
- Endpoint:
/check_user_exists
- Description: Checks if a user exists in the database
- Importance: Maybe used as pings for security purposes
- Method:
-
Create Journal Entry
- Method:
POST
- Endpoint:
/journals
- Description: Creates a new journal entry.
- Importance: Allows users to create and store journal entries.
- Method:
-
Get All Journal Entries
- Method:
GET
- Endpoint:
/journals
- Description: Retrieves all journal entries for the authenticated user.
- Importance: Enables users to view their journal entries.
- Method:
-
Get Single Journal Entry
- Method:
GET
- Endpoint:
/journals/<journal_id>
- Description: Retrieves a single journal entry by its ID.
- Importance: Allows users to view specific journal entries.
- Method:
-
Update Journal Entry
- Method:
PUT
- Endpoint:
/journals/<journal_id>
- Description: Updates an existing journal entry by its ID.
- Importance: Provides functionality for users to edit their journal entries.
- Method:
-
Delete Journal Entry
- Method:
DELETE
- Endpoint:
/journals/<journal_id>
- Description: Deletes a journal entry by its ID.
- Importance: Allows users to remove journal entries they no longer need.
- Method:
- Error Handlers:
- Custom error handlers for various HTTP status codes (e.g., 404, 500).
- Importance: Provides user-friendly error messages and improves the robustness of the API.
- Python 3.10+
- MySQL 5.7+ => storing data
- Redis => storing access tokens and OTP for limited amount of time.
- Docker
- To run the tests, use the following command:
pytest tests