This is a web application that allows users to search for words and get their definitions and examples. It also stores the search history.
- Search for Words: Search for word definitions and examples.
- Search History: Can see their search history.
- Front-end: React, TypeScript
- Back-end: Django, Django REST Framework
- Database: PostgreSQL
Ensure you have the following installed on your local machine:
Follow these steps to set up and run the project locally:
Clone the repository to your local machine:
git clone https://github.com/mokshanirugutti/dictionary_book.git
cd dictionary_book
Important
Make these changes for backend in setting.py during development
Change DEBUG = True
comment out
'OPTIONS': {
'sslmode': 'require',
},
at DATABASES .
Use Docker Compose to build and start the frontend, backend, and database services:
docker-compose up --build
This command will build the Docker images for the frontend and backend, start the services, and initialize the PostgreSQL database.
After the services are up and running, you can check their status and see where they are running by executing:
docker-compose ps
- Frontend: Open your web browser and navigate to http://localhost:3000 to access the React frontend.
- Backend: The Django backend is accessible via http://localhost:8000. This endpoint will be used by the frontend to interact with the backend service.
To stop the services, run:
docker-compose down
This command stops and removes the containers but leaves the volumes intact.
If you need to apply database migrations manually, you can execute:
docker-compose exec backend python manage.py migrate
This will apply any pending migrations to the PostgreSQL database.
- Backend Exits Immediately: Ensure the
start.sh
script is correctly configured and executable. Check the logs withdocker-compose logs backend
for any errors. - Frontend Not Loading: Ensure that the frontend service is correctly building and running. Check the logs with
docker-compose logs frontend
if needed.
To make changes to the code, edit the files in the frontend
or backend
directories. Docker Compose will automatically reflect these changes without needing to rebuild the images, thanks to the volume mounts specified in docker-compose.yml
.
- Node.js and npm installed
- Python and pip installed
- PostgreSQL installed and running
- Navigate to the
frontend
directory:cd frontend
- Install dependencies:
npm install
- Start the development server:
npm start
- Open http://localhost:5173 to view it in the browser.
-
Navigate to the
backend
directory:cd backend
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `env\Scripts\activate`
-
Install dependencies:
pip install -r requirements.txt
-
Set up the PostgreSQL database:
- Create a database in PostgreSQL (e.g., word_search_db).
- Update the DATABASES setting in backend/settings.py with your database credentials:
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'word_search_db', 'USER': 'your_db_user', 'PASSWORD': 'your_db_password', 'HOST': 'localhost', 'PORT': '5432', } }
-
Apply migrations:
python manage.py migrate
-
Start the development server:
python manage.py runserver
This document provides an overview of the RESTful API endpoints, request/response formats, and security schemes implemented in this project.
This project follows the OpenAPI 3.0.3 specification.
Here is the revised documentation with direct schema navigation links for better clarity:
Authenticate a user.
- Request Body: Accepts JSON, x-www-form-urlencoded, or multipart/form-data with fields defined in
UserLogin
. - Security: Requires either
cookieAuth
ortokenAuth
. - Response: Returns
UserLogin
schema in JSON format.
Register a new user.
- Request Body: Accepts JSON, x-www-form-urlencoded, or multipart/form-data with fields defined in
UserCreation
. - Security: Requires either
cookieAuth
ortokenAuth
. - Response: Returns
UserCreation
schema in JSON format.
Request a password reset.
- Request Body: Accepts JSON, x-www-form-urlencoded, or multipart/form-data with fields defined in
RequestPasswordReset
. - Security: Requires either
cookieAuth
ortokenAuth
. - Response: Returns
RequestPasswordReset
schema in JSON format.
Retrieve search history.
- Security: Requires either
cookieAuth
ortokenAuth
. - Response: Returns array of
SearchHistory
schema in JSON format.
Delete a search history entry.
- Path Parameter:
id
(integer) - ID of the search history entry to delete. - Security: Requires either
cookieAuth
ortokenAuth
. - Response: No response body (204 status).
Verify and reset password.
- Request Body: Accepts JSON, x-www-form-urlencoded, or multipart/form-data with fields defined in
VerifyPasswordReset
. - Security: Requires either
cookieAuth
ortokenAuth
. - Response: Returns
VerifyPasswordReset
schema in JSON format.
Verify registration OTP.
- Request Body: Accepts JSON, x-www-form-urlencoded, or multipart/form-data with fields defined in
VerifyRegistration
. - Security: Requires either
cookieAuth
ortokenAuth
. - Response: Returns
VerifyRegistration
schema in JSON format.
Create a new word entry.
- Request Body: Accepts JSON, x-www-form-urlencoded, or multipart/form-data with fields defined in
Word
. - Security: Requires either
cookieAuth
ortokenAuth
. - Response: Returns
Word
schema in JSON format.
Retrieve OpenAPI schema.
- Query Parameters:
format
(string): Format of the schema (json or yaml).lang
(string): Language code for the schema.
- Security: Requires either
cookieAuth
ortokenAuth
. - Response: Returns OpenAPI schema in specified format.
- Json Body:
username
(string).password
(string).
- Json Body:
username
(string).password
(string).email
(email).
- Json Body:
email
(email).
- Security: Requires either
cookieAuth
ortokenAuth
.
- Json Body:
email
(email).otp
(6 digit otp).new_password
(string).
- Json Body:
email
(email).otp
(6 digit otp).
- Json Body:
word
(string).- Security: Requires either
cookieAuth
ortokenAuth
.
- Type: API Key
- Location: Cookie
- Name: sessionid
- Type: API Key
- Location: Header
- Name: Authorization
- Description: Token-based authentication with required prefix "Token"