A full-stack application for managing a library, built with Django, Django REST Framework, and Angular.
This project was developed as part of a tutorial series:
- Part init environment Django / DRF with virtualenv or Docker https://dev.to/zorky/django-drf-101-initialisation-1e39
- Part 1 Django ORM https://dev.to/zorky/django-drf-101-partie-1-2p2
- Part 2 Django & DRF https://dev.to/zorky/django-drf-101-partie-2-1gp5
- Part 3.1 Angular introduction : API & CORS, components, communication between components https://dev.to/zorky/django-drf-angular-101-partie-3-1-io5
- Part 3.2 Angular routing, forms, data-table mat-table & POO, generic service https://dev.to/zorky/django-drf-angular-101-partie-3-2-4foh
- Part 3.3 Angular authentification & Django & JWT, guards, modules https://dev.to/zorky/django-drf-angular-101-partie-3-3-10fa
- Part 3.4 Angular & dynamic components & data-table https://dev.to/zorky/django-drf-angular-101-partie-3-4-4h7h
- Backend: Django, Django REST Framework
- Frontend: Angular, Angular CLI
- Database: SQLite (default, configurable)
- Containerization: Docker, Docker Compose
- API Documentation: Swagger (auto-generated by drf-yasg)
This project uses Docker to simplify setup. Ensure you have Docker and Docker Compose installed.
The backend is a Django application.
-
Navigate to the
dockerdirectory:cd docker -
Build and run the containers: This will build the
api-plateformimage if it doesn't exist and start the backend API service along with Nginx.docker-compose up --build -d
The backend API will be accessible at
http://localhost:8110(orhttp://localhostif accessed through Nginx as configured indocker-compose.yml).Alternatively, for local development without Docker (ensure Python and pip are installed):
-
Create and activate a virtual environment (optional but recommended):
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Navigate to the
backenddirectory:cd backend -
Install dependencies:
pip install -r ../requirements.txt
(Note: The
requirements.txtin the root seems to be the one used by Docker for the backend. If there's a specific one inside./backend, adjust accordingly.) -
Run database migrations:
python manage.py migrate
-
Start the development server:
python manage.py runserver 8110
The frontend is an Angular application.
-
Navigate to the
frontend/librarydirectory:cd frontend/library -
Install dependencies:
npm install
Note: If you encounter issues with
npm installdue to version conflicts (e.g., with@angular/cli), you might need to use a specific Node.js version or update/downgrade packages as necessary. The project was generated with Angular CLI 9.1.0.
-
If using Docker: The backend service (
api-plateform) and Nginx (nginx-plateform) should already be running if you followed the Docker setup instructions (docker-compose up -d). You can check the status of the containers:cd docker docker-compose psTo view logs:
docker-compose logs api-plateform docker-compose logs nginx-plateform
The API should be accessible at
http://localhost:8110directly orhttp://localhost/via Nginx. -
If running locally (without Docker): Ensure you are in the
backenddirectory and your virtual environment is activated.python manage.py runserver 8110
The API will be available at
http://localhost:8110.
- Navigate to the
frontend/librarydirectory:cd frontend/library - Start the Angular development server:
Navigate to
ng serve
http://localhost:4200/. The app will automatically reload if you change any of the source files.
This project uses drf-yasg to generate API documentation with Swagger/OpenAPI.
Once the backend is running (either via Docker or locally), you can access the API documentation at the following endpoints:
- Swagger UI:
http://localhost:8110/swagger/ - ReDoc UI:
http://localhost:8110/redoc/ - JSON Schema:
http://localhost:8110/swagger.json - YAML Schema:
http://localhost:8110/swagger.yaml
If you are accessing the backend via Nginx through Docker (at http://localhost/), the paths for API documentation are directly at the root:
- Swagger UI:
http://localhost/ - ReDoc UI:
http://localhost/redoc/ - JSON Schema:
http://localhost/swagger.json(The schema is typically available atswagger.jsonrelative to the Swagger UI path) - YAML Schema:
http://localhost/swagger.yaml(The schema is typically available atswagger.yamlrelative to the Swagger UI path)
(Note: The Django application serves Swagger UI at its root (/) and ReDoc at /redoc/. Nginx proxies requests directly to the Django application.)
The frontend application is built with Angular. The source code is located in frontend/library/.
Run ng serve (from the frontend/library directory) for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.
Run ng generate component component-name to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module.
Run ng build to build the project. The build artifacts will be stored in the dist/ directory (within frontend/library). Use the --prod flag for a production build.
Run ng test to execute the unit tests via Karma.
Run ng e2e to execute the end-to-end tests via Protractor.
To get more help on the Angular CLI use ng help or go check out the Angular CLI README.