This is a FastAPI project built for the Blockstak. It exposes a set of secure, token-authenticated REST API endpoints and is designed to run both locally (via uvicorn) and in a Dockerized environment.
GitHub: https://github.com/dkkundu/Blockstak.git
This FastAPI backend service provides a secure, token-based API with 5 endpoints (CRUD operations). It demonstrates proper authentication, environment configuration, Docker usage, and testability. The project is designed to be scalable, secure, and easy to deploy.
-
Clone the Repository
git clone https://github.com/dkkundu/Blockstak.git cd Blockstak -
Copy Environment File
cp example/dot_env .env
-
Edit .env File Update the following values in the
.envfile as per your local setup:PROJECT_NAME="Backend for Blockstak" DEBUG=True SECRET_KEY=mysecretkey WHITE_LIST=http://localhost:8000,http://localhost:9000 # Database Configuration MYSQL_HOST=192.168.55.101 MYSQL_PORT=3306 MYSQL_DB=MYSQL_DB_NAME MYSQL_USER=MYSQL_USER_NAME MYSQL_PASSWORD=MYSQL_USER_PASSWORD # API Key NEWS_API_KEY=NEWS_API_KEY_form_newsapi.org # FastAPI Configuration FASTAPI_HOST_PORT=5000
Refer to
example/dot_envfor additional guidance if needed.
-
Install dependencies:
pip install -r requirements.txt
-
Run the server:
uvicorn main:app --host 0.0.0.0 --port 9000 --reload
-
Build and run the Docker container:
docker-compose up --build
or
docker compose up --build
-
The FastAPI app will be available on the port specified in the
.envfile underFASTAPI_HOST_PORT. By default, this is set to8000.
-
Run the tests:
pytest
-
View the test coverage report:
pytest --cov=app
- Use the
/auth/loginendpoint to authenticate and retrieve a JWT token. - Include the token in the
Authorizationheader for secured endpoints:Authorization: Bearer <your_token>
This project includes 5 main API endpoints, all documented in the provided Postman collection file.
example/Blockstak.postman_collection.json
- Open Postman.
- Go to File > Import.
- Select
example/Blockstak.postman_collection.json.
-
OpenAPI Docs: Once the server is running, you can access the auto-generated API documentation at:
-
The FastAPI app will be available on the port specified in the
.envfile underFASTAPI_HOST_PORT. By default, this is set to8000.- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
-
Postman Collection: Import the Postman collection file located at:
example/Blockstak.postman_collection.json -
Database Schema: Add database schema details here if needed.
- Name: Dipto K Kundu
- GitHub: https://github.com/dkkundu
This project is licensed for evaluation and demonstration purposes only.