A full-stack application with FastAPI backend and React frontend, designed for Smart India Hackathon 2025.
devsters-sih25/
├── backend/
│ ├── __init__.py
│ ├── main.py
│ ├── crud.py
│ ├── database.py
│ ├── schemas.py
│ └── routers/
│ ├── __init__.py
│ └── items.py
├── frontend/
│ ├── src/
│ │ ├── components/
│ │ ├── features/
│ │ └── store/
│ ├── package.json
│ └── vite.config.js
├── static/
│ └── css/
├── docker-compose.yml
├── Dockerfile
├── init-db.sql
├── requirements.txt
├── SECURITY.md
└── README.md
The easiest way to get started is using Docker Compose, which sets up everything including the database:
- Docker Desktop installed
- Git
-
Clone the repository:
git clone <your-repo-url> cd devsters-sih25
-
Start all services:
docker compose up --build
-
Access the application:
- Frontend (served by backend): http://localhost:8000
- Backend API: http://localhost:8000/api
- API Docs (Swagger): http://localhost:8000/docs
- Database (host port): localhost:5433
- PostgreSQL Database: Persistent database (host port 5433 → container 5432)
- Backend API: FastAPI application with auto-reload and SPA static serving
- Frontend: React application built with Vite; build artifacts are served by the backend
- Data Persistence: Database data persists between restarts
The database is automatically configured with (see docker-compose.yml):
- Database Name:
devsters_db - Username:
devsters_user - Password:
sih2025devsters - Container Port:
5432(exposed on host as5433)
- Persistent Storage: Data survives container restarts
- Health Checks: Backend waits for database to be ready
- Sample Data: Pre-populated with test users and items
- Initialization Script:
init-db.sqlruns on first startup
The backend runs with auto-reload when files change. API documentation is available at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
The frontend uses Vite for fast development with hot module replacement.
Connect to the database:
# Using Docker
docker exec -it devsters-db psql -U devsters_user -d devsters_db
# Or using any PostgreSQL client
# Host: localhost
# Port: 5433
# Database: devsters_db
# Username: devsters_user
# Password: sih2025devstersReset the database:
# Stop services
docker compose down
# Remove database volume (WARNING: This deletes all data)
# Volume is named `postgres_data` (Docker may prefix it with the project name)
# Check with: docker volume ls | find "postgres_data"
docker volume rm devsters_sih25_postgres_data
# Start services again
docker compose up --buildEnvironment variables are managed by Docker Compose. Update the environment section in docker-compose.yml to change values such as DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, and DB_NAME.
For local development without Docker, export these variables in your shell before running the backend.
If you prefer to run without Docker:
- Install PostgreSQL locally
- Create database and user matching the values above (
devsters_db/devsters_user/ passwordsih2025devsters) - Install Python dependencies:
pip install -r requirements.txt
- Install Node.js dependencies:
cd frontend npm install - Run backend:
uvicorn backend.main:app --reload
- Run frontend (development):
The production SPA build is generated with
cd frontend npm run devnpm run buildand, in Docker, is served by the backend from thefrontend/distdirectory.
- All API routes are namespaced under
/api(seebackend/routers). - The backend serves the built SPA and falls back to
index.htmlfor unknown routes, enabling client-side routing. - A login endpoint exists at
POST /loginitexpecting form fieldsemailandpassword.
- Full-stack application with FastAPI and React
- Persistent PostgreSQL database with Docker
- CRUD operations (see
backend/routers) - Modern UI with Tailwind CSS and DaisyUI
- Development-friendly with hot reload
- Production-ready with Docker containers
Refer to the SECURITY.md file for best practices and security considerations for this project.