Skip to content

Latest commit

Β 

History

History
111 lines (76 loc) Β· 2.4 KB

File metadata and controls

111 lines (76 loc) Β· 2.4 KB

DatabaseFights Project

This is a full-stack web application consisting of:

  • Backend (Python + FastAPI + PostgreSQL)
  • Frontend (React.js)

πŸ”§ Project Structure

project-root/
β”‚
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ models/         # SQLAlchemy models
β”‚   β”‚   β”œβ”€β”€ routes/         # API routes
β”‚   β”‚   β”œβ”€β”€ schemas/        # Pydantic schemas for request/response validation
β”‚   β”‚   β”œβ”€β”€ app_instance.py # App factory or shared app instance
β”‚   β”‚   β”œβ”€β”€ db.py           # DB connection and session management
β”‚   β”‚   β”œβ”€β”€ Dockerfile      # Docker image for FastAPI backend
β”‚   β”‚   └── main.py         # Main FastAPI app entry point
β”‚   β”œβ”€β”€ db/
β”‚   β”‚   └── init/           # SQL scripts executed when the PostgreSQL DB is initialized
β”‚   β”œβ”€β”€ docker-compose.yml  # Docker Compose config for backend and database
β”‚   └── README.md
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ public/             # Static files
β”‚   β”œβ”€β”€ src/                # React source code
β”‚   β”œβ”€β”€ package.json        # Frontend dependencies and scripts
β”‚   └── README.md
β”‚
└── README.md               # You're here!

πŸš€ Getting Started

1. Backend (FastAPI + PostgreSQL)

Prerequisites

  • Docker + Docker Compose

Start the backend

cd backend
docker compose up

This will:

  • Build the FastAPI backend container
  • Start a PostgreSQL container
  • Initialize the database using SQL files in db/init/

The backend will be available at http://localhost:8000.

FastAPI docs: http://localhost:8000/docs


2. Frontend (React)

Prerequisites

  • Node.js (v18+ recommended)
  • npm

Start the frontend

cd frontend
npm install
npm start

The React app will be available at http://localhost:3000.


πŸ›  Tech Stack

Backend:

  • FastAPI
  • SQLAlchemy
  • PostgreSQL
  • Docker

Frontend:

  • React.js
  • JavaScript

πŸ—‚ Database Initialization

SQL files located in backend/db/init/ are executed automatically the first time the PostgreSQL container is started. These scripts typically:

  • Create tables and schema
  • Insert default or sample data

πŸ“¦ Environment Variables

You can configure the database and app settings via environment variables in the docker-compose.yml. For local development, defaults are usually provided.