- Introduction
- Features
- Technologies Used
- Architecture
- Getting Started
- Usage
- API Documentation
- Testing
- Roadmap
- Contributing
- License
- Acknowledgements
Welcome to the Secure P2P File Sharing Application! This project facilitates decentralized and secure file sharing between users, ensuring data confidentiality, integrity, and privacy. Built with a modern tech stack, it leverages React for the frontend, FastAPI for the backend, and incorporates Celery and Redis for asynchronous task management.
- Decentralized Architecture: Enables direct file sharing between peers without a central server.
- End-to-End Encryption: Protects data during transmission using robust encryption methods.
- User Authentication: Secure user verification with JWT and OAuth2 Authentication.
- Profile Management: Users can manage their profiles and settings.
- Real-time File Transfer: Efficient file sharing with progress tracking and notifications.
- Role-Based Access Control: Manage permissions for shared files.
- Responsive UI: Built with React and ChakraUI for a seamless user experience across devices.
- Frontend: React.js, ChakraUI, Redux, Axios
- Backend: FastAPI, Celery, Redis, PostgreSQL, Postman
- Database and ORM: PostgreSQL, SQLAlchemy
- Others: Docker, Docker Compose, Nginx, GitHub Actions
[Frontend (React + ChakraUI)] <--> [FastAPI Backend] <--> [PostgreSQL Database]
|
--> [Celery Workers] <--> [Redis]
- Frontend: Handles user interactions and communicates with the backend via RESTful APIs.
- Backend: Manages business logic, authentication, and API endpoints.
- Celery & Redis: Handle asynchronous tasks such as file processing and sending notifications.
- Database: Stores user data, file metadata, and other persistent information.
Ensure you have the following installed on your system:
- Python 3.10+
- Node.js 14+ & npm
- PostgreSQL 13+
- Redis 6+
- Docker & Docker Compose (optional, for containerization)
-
Clone the Repository:
git clone https://github.com/eugeneanokye99/directdrop.git cd your-repo
-
Set Up Virtual Environment:
python3 -m venv venv source venv/bin/activate
-
Install Dependencies:
pip install -r requirements.txt
-
Navigate to Backend Directory:
cd Backend/app
-
Run Database Migrations:
alembic upgrade head
-
Start the backend server with uvicorn:
uvicorn main:app --reload
-
Navigate to Frontend Directory:
cd Frontend/directdrop
-
Install Dependencies:
npm install
-
Start the frontend server with:
npm run dev
-
Ensure Redis is Running:
# Using Docker docker run -d -p 6379:6379 redis
-
Start Celery Worker:
celery -A your_project worker --loglevel=info
-
Install PostgreSQL: Follow the official PostgreSQL installation guide for your OS.
-
Create Database and User:
CREATE DATABASE your_db_name; CREATE USER your_db_user WITH PASSWORD 'your_password'; GRANT ALL PRIVILEGES ON DATABASE your_db_name TO your_db_user;
-
Update Database Configuration: Ensure your backend's environment variables point to the correct database URL.
Create a .env
file in the root directory and configure the necessary variables. You can use .env.example
as a template.
Example .env
:
# Backend
DATABASE_URL=postgresql://your_db_user:your_password@localhost:5432/your_db_name
REDIS_URL=redis://localhost:6379/0
SECRET_KEY=your_secret_key
CELERY_BROKER_URL=redis://localhost:6379/0
CELERY_RESULT_BACKEND=redis://localhost:6379/0
# Frontend
REACT_APP_API_URL=http://localhost:8000/api
-
Ensure Docker and Docker Compose are Installed.
-
Build and Start Containers:
docker-compose up --build
-
Access the Application:
- Frontend:
http://localhost:3000
- Backend API:
http://localhost:8000
- Frontend:
-
Start Backend:
cd backend uvicorn main:app --reload
-
Start Frontend:
cd frontend npm start
-
Start Celery Worker:
celery -A your_project worker --loglevel=info
FastAPI automatically generates interactive API docs. Access them at:
- Swagger UI:
http://localhost:8000/docs
- ReDoc:
http://localhost:8000/redoc
Outline to run tests for both frontend and backend.
-
Run Tests with pytest:
pytest
-
Coverage Report:
pytest --cov=your_project tests/
-
Run Tests with Jest:
npm test
-
End-to-End Testing with Cypress:
npx cypress open
Organize your project roadmap into phases, aligning with your 2-week sprints. Here’s a suggested structure:
-
User Authentication and Authorization
- Set up FastAPI backend with user authentication endpoints.
- Implement JWT-based authentication in FastAPI.
- Create React components for login and registration.
- Integrate frontend with backend using Axios for API requests.
- Milestone: User login and registration with authentication.
-
Profile Management
- Develop API endpoints in FastAPI for managing user profiles.
- Create React components for viewing and editing profiles.
- Implement profile update functionality and API integration.
- Milestone: Complete user profile management system.
-
API Development
- Design RESTful API structure for core features.
- Implement API documentation using Swagger (FastAPI).
- Milestone: Finalize core API development and documentation.
-
File Management
- Set up file upload/download API endpoints in FastAPI.
- Integrate S3 (or similar service) with FastAPI for file storage.
- Build React components for file upload and download.
- Implement encryption/decryption of files using Python's
cryptography
library. - Milestone: Secure file management system with encryption.
-
Database Management
- Configure PostgreSQL database and integrate with FastAPI.
- Implement ORM models for storing user and file data.
- Optimize database queries and set up Redis for caching.
- Milestone: Efficient database management with caching.
-
Security Features
- Implement security middleware in FastAPI for CSRF, rate limiting, etc.
- Set up HTTPS with SSL/TLS for secure communication.
- Milestone: Implemented security features and hardened API.
-
Peer-to-Peer Communication
- Integrate WebRTC for peer-to-peer file sharing.
- Set up signaling server using FastAPI or another suitable method.
- Develop React UI for initiating and managing P2P connections.
- Milestone: Fully functional P2P file sharing feature.
-
Notifications
- Implement real-time notifications with WebSockets in FastAPI.
- Develop notification components in React.
- Integrate real-time notifications with file sharing and user activity.
- Milestone: Real-time notification system.
-
Containerization with Docker
- Set up Docker for both frontend and backend.
- Use Docker Compose for environment management.
- Milestone: Containerized application for consistent development and production environments.
-
CI/CD Pipelines
- Configure GitHub Actions for automated testing and deployment.
- Milestone: Continuous Integration and Deployment setup.
- Fork the Repository
- Create a Feature Branch:
git checkout -b feature/YourFeature
- Commit Your Changes:
git commit -m "Add your feature"
- Push to the Branch:
git push origin feature/YourFeature
- Open a Pull Request
Please ensure your code adheres to the project's coding standards and passes all tests.