- I implemented the backend of this application using Django and the frontend using React.
- I chose to keep the database as Sqlite3 for the sake of simplicity but the database is easily changeable to a more scalable database such as PostgreSQL.
- The frontend connects to the backend over REST APIs. I developed an OpenAPI specification for documenting the API design. The API specification can be viewed here: https://zarifmahfuz.github.io/bike-shop/.
- Python 3.7-3.11
- Node v16+
Clone the repo to begin!
- Start a new virtual environment:
python3 -m venv env
source env/bin/activate # On Windows use `env\Scripts\activate`
- Install dependencies with
pip install -r requirements.txt
- Run the database migrations with
python3 manage.py migrate
- Load the seed data for the app with
python3 manage.py loaddata seed_data.json
- Run the server with
python3 manage.py runserver
. This runs the server on port8000
by default. If you want to run the server on a different port, runpython3 manage.py runserver <port>
- Open a separate terminal and
cd frontend
npm install
- Run the frontend server with
npm run dev
. You should see the url from which you can finally run the application! 🎉 - Note that if you changed the backend server port, you will need to change the
SERVER_PORT
variable infrontend/config.ts
to match your server's port.
If you are unfamiliar with Django, the following is meant to give you a very high-level overview of files in backend/
, in order to make it a little easier for you navigate through the codebase.
urls.py
: This is the entry point to the backend.models.py
: This defines all the entitires for the application and implements parts of the business logic.managers.py
: This implements the other parts of the business logic. The difference betweenmanagers.py
andmodels.py
is thatmanagers.py
operates over the entire entity andmodels.py
operates over a single instance of the entity.views.py
: This connects the API endpoints to the backend logic and returns HTTP responses.serializers.py
: This defines the input and output serializers for the API.tests
: This defines the automated tests for the app.
This is a MVP of the app that I built in a few days! There are so many more things that I would wish to implement over time. Some of them are listed below!
- Implement pagination for the Sales and Bikes pages
- Implement user management and authentication
- Implement caching at the frontend
- Add database indexes to make the app more performant
- Etc.